Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 1.21 KB

File metadata and controls

40 lines (29 loc) · 1.21 KB

SA1217

TypeName SA1217UsingStaticDirectivesMustBeOrderedAlphabetically
CheckId SA1217
Category Ordering Rules

📝 This rule is new for StyleCop Analyzers, and was not present in StyleCop Classic.

Cause

The using static directives within a C# code file are not sorted alphabetically by full type name.

Rule description

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.

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.

How to fix violations

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

How to suppress violations

#pragma warning disable SA1217 // Using static directives should be ordered alphabetically
using static System.Math;
#pragma warning restore SA1217 // Using static directives should be ordered alphabetically