Skip to content

Commit 44710e1

Browse files
committed
Update documentation to reflect the new behavior
1 parent 16cc59d commit 44710e1

File tree

7 files changed

+14
-0
lines changed

7 files changed

+14
-0
lines changed

documentation/SA1200.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ A C# using directive is placed outside of a namespace element.
2525

2626
A violation of this rule occurs when a using directive or a using-alias directive is placed outside of a namespace element, unless the file does not contain any namespace elements.
2727

28+
> :memo: Global using directives (C# 10) are always outside namespaces, and the compiler produces an error if they are placed inside. SA1200 does not report diagnostics for the placement of global using directives.
29+
2830
For example, the following code would result in two violations of this rule.
2931

3032
```csharp

documentation/SA1208.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ A using directive which declares a member of the *System* namespace appears afte
2323

2424
A violation of this rule occurs when a using directive for the *System* namespace is placed after a non-*System* using directive. Placing all *System* using directives at the top of the using directives can make the code cleaner and easier to read, and can help make it easier to identify the namespaces that are being used by the code.
2525

26+
Global using directives (C# 10) are analyzed independently from local using directives. Diagnostics and fixes compare only directives which both use, or both omit, the `global` modifier.
27+
2628
## How to fix violations
2729

2830
To fix an instance of this violation, place the *System* using directive above all using directives for other namespaces.

documentation/SA1209.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ A using-alias directive is positioned before a regular using directive.
2323

2424
A violation of this rule occurs when a using-alias directive is placed before a normal using directive. Using-alias directives have special behavior which can alter the meaning of the rest of the code within the file or namespace. Placing the using-alias directives together below all other using-directives can make the code cleaner and easier to read, and can help make it easier to identify the types used throughout the code.
2525

26+
Global using directives (C# 10) are analyzed independently from local using directives. Diagnostics and fixes compare only directives which both use, or both omit, the `global` modifier.
27+
2628
## How to fix violations
2729

2830
To fix an instance of this violation, place all using-alias directives beneath all normal using directives.

documentation/SA1210.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ The using directives within a C# code file are not sorted alphabetically by name
2323

2424
A violation of this rule occurs when the using directives are not sorted alphabetically by namespace. Sorting the using directives alphabetically makes the code cleaner and easier to read, and can help make it easier to identify the namespaces that are being used by the code. The System namespaces are an exception to this rule and will always precede all other namespaces. See SA1208 for more details.
2525

26+
Global using directives (C# 10) are analyzed independently from local using directives. Diagnostics and fixes compare only directives which both use, or both omit, the `global` modifier.
27+
2628
## How to fix violations
2729

2830
To fix an instance of this violation, order the using directives alphabetically by namespace with all the System namespace entries first.

documentation/SA1211.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ The using-alias directives within a C# code file are not sorted alphabetically b
2323

2424
A violation of this rule occurs when the using-alias directives are not sorted alphabetically by alias name. Sorting the using-alias directives alphabetically can make the code cleaner and easier to read, and can help make it easier to identify the namespaces that are being used by the code.
2525

26+
Global using directives (C# 10) are analyzed independently from local using directives. Diagnostics and fixes compare only directives which both use, or both omit, the `global` modifier.
27+
2628
## How to fix violations
2729

2830
To fix an instance of this violation, order the using-alias directives alphabetically by alias name.

documentation/SA1216.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ A `using static` directive is positioned at the wrong location (before a regular
2525

2626
A violation of this rule occurs when a using static directive is placed before a normal or after an alias using directive. Placing the using static directives together below normal and before alias using-directives can make the code cleaner and easier to read, and can help make it easier to identify the static members used throughout the code.
2727

28+
Global using directives (C# 10) are analyzed independently from local using directives. Diagnostics and fixes compare only directives which both use, or both omit, the `global` modifier.
29+
2830
## How to fix violations
2931

3032
The fix an instance of this violation, place the `using static` directive after regular and before alias using directives.

documentation/SA1217.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ The `using static` directives within a C# code file are not sorted alphabeticall
2525

2626
A violation of this rule occurs when the `using static` directives are not sorted alphabetically by full type name. Sorting the `using static` directives alphabetically makes the code cleaner and easier to read.
2727

28+
Global using directives (C# 10) are analyzed independently from local using directives. Diagnostics and fixes compare only directives which both use, or both omit, the `global` modifier.
29+
2830
## How to fix violations
2931

3032
To fix an instance of this violation, order the `using static` directives alphabetically by full type name.

0 commit comments

Comments
 (0)