Skip to content

Instantly share code, notes, and snippets.

@kurnakovv
Last active December 10, 2025 11:19
Show Gist options
  • Select an option

  • Save kurnakovv/cd01734d1775a1d53951d106f9ecf5b7 to your computer and use it in GitHub Desktop.

Select an option

Save kurnakovv/cd01734d1775a1d53951d106f9ecf5b7 to your computer and use it in GitHub Desktop.
Favorite StyleCop.Analyzers rules in .editorconfig
# https://gist.github.com/kurnakovv/70a5d76dc5f3eb9ef114b182283cb407
##
## StyleCop.Analyzers
##
# All rules here https://github.com/DotNetAnalyzers/StyleCopAnalyzers/tree/master/documentation
# Disable all rules
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.AlternativeRules.severity = none
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.DocumentationRules.severity = none
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.LayoutRules.severity = none
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.MaintainabilityRules.severity = none
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.NamingRules.severity = none
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.OrderingRules.severity = none
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.ReadabilityRules.severity = none
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.SpacingRules.severity = none
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.SpecialRules.severity = none
dotnet_diagnostic.SA1001.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md Use <GenerateDocumentationFile>true</GenerateDocumentationFile>
dotnet_diagnostic.SA1002.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1002.md
dotnet_diagnostic.SA1003.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1003.md
dotnet_diagnostic.SA1004.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1004.md
dotnet_diagnostic.SA1005.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1005.md
dotnet_diagnostic.SA1007.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1007.md
dotnet_diagnostic.SA1012.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1012.md
dotnet_diagnostic.SA1013.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1013.md
dotnet_diagnostic.SA1014.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1014.md
dotnet_diagnostic.SA1015.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1015.md
dotnet_diagnostic.SA1016.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1016.md
dotnet_diagnostic.SA1017.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1017.md
dotnet_diagnostic.SA1018.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1018.md
dotnet_diagnostic.SA1019.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1019.md
dotnet_diagnostic.SA1020.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1020.md
dotnet_diagnostic.SA1021.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1021.md
dotnet_diagnostic.SA1022.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1022.md
dotnet_diagnostic.SA1023.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1023.md
dotnet_diagnostic.SA1024.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1024.md
dotnet_diagnostic.SA1025.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1025.md
dotnet_diagnostic.SA1026.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1026.md
dotnet_diagnostic.SA1028.severity = error # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md
### Readability Rules (SA1100-)
# Rules which ensure that the code is well-formatted and readable.
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/ReadabilityRules.md
dotnet_diagnostic.SA1102.severity = error # A C# query clause does not begin on the same line as the previous clause, or on the next line.
dotnet_diagnostic.SA1103.severity = error # The clauses within a C# query expression are not all placed on the same line, and each clause is not placed on its own line.
dotnet_diagnostic.SA1104.severity = error # A clause within a C# query expression begins on the same line as the previous clause, when the previous clause spans across multiple lines.
dotnet_diagnostic.SA1105.severity = error # A clause within a C# query expression spans across multiple lines, and does not begin on its own line.
dotnet_diagnostic.SA1107.severity = error # The C# code contains more than one statement on a single line.
dotnet_diagnostic.SA1108.severity = error # A C# statement contains a comment between the declaration of the statement and the opening brace of the statement.
dotnet_diagnostic.SA1109.severity = error # A C# statement contains a region tag between the declaration of the statement and the opening brace of the statement.
dotnet_diagnostic.SA1112.severity = error # The closing parenthesis or bracket in a call to a C# method or indexer, or the declaration of a method or indexer, is not placed on the same line as the opening bracket when the element does not take any parameters.
dotnet_diagnostic.SA1113.severity = error # A comma between two parameters in a call to a C# method or indexer, or in the declaration of a method or indexer, is not placed on the same line as the previous parameter.
dotnet_diagnostic.SA1117.severity = error # The parameters to a C# method or indexer call or declaration are not all on the same line or each on a separate line.
dotnet_diagnostic.SA1119.severity = error # A C# statement contains parenthesis which are unnecessary and should be removed.
dotnet_diagnostic.SA1120.severity = error # The C# comment does not contain any comment text.
dotnet_diagnostic.SA1121.severity = error # The code uses one of the basic C# types, but does not use the built-in alias for the type.
dotnet_diagnostic.SA1122.severity = error # The C# code includes an empty string, written as `"`.
dotnet_diagnostic.SA1125.severity = error # The Nullable type has been defined not using the C# shorthand.
dotnet_diagnostic.SA1126.severity = error # A call to a member is not prefixed with the 'this.', 'base.', 'object.' or 'typename.' prefix to indicate the intended method call, within a C# code file.
# dotnet_diagnostic.SA1127.severity = error # A generic constraint on a type or method declaration is on the same line as the declaration, within a C# code file.
dotnet_diagnostic.SA1130.severity = error # An anonymous method was declared using the form `delegate (parameters) { }`, when a lambda expression would provide equivalent behavior with the syntax `(parameters) => { }`.
dotnet_diagnostic.SA1131.severity = error # A comparison was made between a variable and a literal or constant value, and the variable appeared on the right-hand side of the expression.
dotnet_diagnostic.SA1132.severity = error # Two or more fields were declared in the same field declaration syntax.
dotnet_diagnostic.SA1134.severity = error # An attribute is placed on the same line of code as another attribute or element.
dotnet_diagnostic.SA1135.severity = error # A using directive is not qualified.
dotnet_diagnostic.SA1136.severity = error # Multiple enum values are placed on the same line of code.
dotnet_diagnostic.SA1137.severity = error # Two sibling elements which each start on their own line have different levels of indentation.
dotnet_diagnostic.SA1139.severity = error # Use literal suffix notation instead of casting.
dotnet_diagnostic.SA1141.severity = error # Use tuple syntax instead of the underlying ValueTuple implementation type.
### Ordering Rules (SA1200-)
# Rules which enforce a standard ordering scheme for code contents.
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/OrderingRules.md
dotnet_diagnostic.SA1201.severity = error # An element within a C# code file is out of order in relation to the other elements in the code.
dotnet_diagnostic.SA1202.severity = error # An element within a C# code file is out of order within regard to access level, in relation to other elements in the code.
dotnet_diagnostic.SA1203.severity = error # A constant field is placed beneath a non-constant field.
dotnet_diagnostic.SA1205.severity = error # The partial element does not have an access modifier defined.
dotnet_diagnostic.SA1207.severity = error # The keyword *protected* is positioned after the keyword *internal* within the declaration of a protected internal C# element.
dotnet_diagnostic.SA1209.severity = error # A using-alias directive is positioned before a regular using directive.
dotnet_diagnostic.SA1212.severity = error # A get accessor appears after a set accessor within a property or indexer.
dotnet_diagnostic.SA1213.severity = error # An add accessor appears after a remove accessor within an event.
dotnet_diagnostic.SA1214.severity = error # A readonly field is positioned beneath a non-readonly field.
dotnet_diagnostic.SA1215.severity = error # An instance readonly element is positioned beneath an instance non-readonly element of the same type.
dotnet_diagnostic.SA1216.severity = error # A `using static` directive is positioned at the wrong location (before a regular using directive or after an alias using directive).
dotnet_diagnostic.SA1217.severity = error # The `using static` directives within a C# code file are not sorted alphabetically by full type name.
### Naming Rules (SA1300-)
# Rules which enforce naming requirements for members, types, and variables.
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/NamingRules.md
dotnet_diagnostic.SA1300.severity = error # The name of a C# element does not begin with an upper-case letter.
dotnet_diagnostic.SA1302.severity = error # The name of a C# interface does not begin with the capital letter I.
dotnet_diagnostic.SA1304.severity = error # The name of a non-private readonly C# field should being with an upper-case letter.
dotnet_diagnostic.SA1306.severity = error # The name of a field in C# does not begin with a lower-case letter.
dotnet_diagnostic.SA1307.severity = error # The name of a public or internal field in C# does not begin with an upper-case letter.
dotnet_diagnostic.SA1314.severity = error # The name of a C# type parameter does not begin with the capital letter T.
dotnet_diagnostic.SA1316.severity = error # Element names within a tuple type should have the correct casing.
### Maintainability Rules (SA1400-)
# Rules which improve code maintainability.
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/MaintainabilityRules.md
dotnet_diagnostic.SA1400.severity = error # The access modifier for a C# element has not been explicitly defined.
dotnet_diagnostic.SA1401.severity = error # A field within a C# class has an access modifier other than private.
dotnet_diagnostic.SA1403.severity = error # A C# code file contains more than one namespace.
dotnet_diagnostic.SA1404.severity = error # A Code Analysis SuppressMessage attribute does not include a justification.
dotnet_diagnostic.SA1405.severity = error # A call to Debug.Assert in C# code does not include a descriptive message.
dotnet_diagnostic.SA1406.severity = error # A call to Debug.Fail in C# code does not include a descriptive message.
dotnet_diagnostic.SA1409.severity = error # A C# file contains code which is unnecessary and can be removed without changing the overall logic of the code.
dotnet_diagnostic.SA1410.severity = error # A call to a C# anonymous method does not contain any method parameters, yet the statement still includes parenthesis.
dotnet_diagnostic.SA1411.severity = error # An attribute declaration does not contain any parameters, yet it still includes parenthesis.
dotnet_diagnostic.SA1413.severity = error # A multi-line initializer should use a comma on the last item.
dotnet_diagnostic.SA1414.severity = error # Tuple types appearing in member declarations should have explicitly named tuple elements.
### Layout Rules (SA1500-)
# Rules which enforce code layout and line spacing.
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/LayoutRules.md
dotnet_diagnostic.SA1500.severity = error # The opening or closing brace within a C# statement, element, or expression is not placed on its own line.
dotnet_diagnostic.SA1502.severity = error # A C# element containing opening and closing braces is written completely on a single line.
dotnet_diagnostic.SA1503.severity = error # The opening and closing braces for a C# statement have been omitted.
dotnet_diagnostic.SA1505.severity = error # An opening brace within a C# element, statement, or expression is followed by a blank line.
dotnet_diagnostic.SA1506.severity = error # An element documentation header above a C# element is followed by a blank line.
dotnet_diagnostic.SA1507.severity = error # The C# code contains multiple blank lines in a row.
dotnet_diagnostic.SA1508.severity = error # A closing brace within a C# element, statement, or expression is preceded by a blank line.
dotnet_diagnostic.SA1509.severity = error # An opening brace within a C# element, statement, or expression is preceded by a blank line.
dotnet_diagnostic.SA1510.severity = error # Chained C# statements are separated by a blank line.
dotnet_diagnostic.SA1511.severity = error # The while footer at the bottom of a do-while statement is separated from the statement by a blank line.
dotnet_diagnostic.SA1514.severity = error # An element documentation header above a C# element is not preceded by a blank line.
dotnet_diagnostic.SA1517.severity = error # The code file has blank lines at the start.
dotnet_diagnostic.SA1518.severity = error # The line endings at the end of a file do not match the settings for the project.
dotnet_diagnostic.SA1519.severity = error # The opening and closing braces for a multi-line C# statement have been omitted.
dotnet_diagnostic.SA1520.severity = error # The opening and closing braces of a chained `if`/`else if`/`else` construct were included for some clauses, but omitted for others.
### Documentation Rules (SA1600-)
# Rules which verify the content and formatting of code documentation.
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/DocumentationRules.md
dotnet_diagnostic.SA1603.severity = error # The Xml within a C# element's document header is badly formed.
dotnet_diagnostic.SA1604.severity = error # The Xml header documentation for a C# element is missing a `<summary>` tag.
dotnet_diagnostic.SA1606.severity = error # The `<summary>` tag within the documentation header for a C# code element is empty.
dotnet_diagnostic.SA1607.severity = error # The `<summary>` or `<content>` tag within the documentation header for a C# code element is empty.
dotnet_diagnostic.SA1608.severity = error # The `<summary>` tag within an element's Xml header documentation contains the default text generated by Visual Studio during the creation of the element.
dotnet_diagnostic.SA1610.severity = error # The Xml header documentation for a C# property contains an empty `<value>` tag.
dotnet_diagnostic.SA1611.severity = error # A C# method, constructor, delegate or indexer element is missing documentation for one or more of its parameters.
dotnet_diagnostic.SA1612.severity = error # The documentation describing the parameters to a C# method, constructor, delegate or indexer element does not match the actual parameters on the element.
dotnet_diagnostic.SA1613.severity = error # A `<param>` tag within a C# element's documentation header is missing a name attribute containing the name of the parameter.
dotnet_diagnostic.SA1614.severity = error # A `<param>` tag within a C# element's documentation header is empty.
dotnet_diagnostic.SA1615.severity = error # A C# element is missing documentation for its return value.
dotnet_diagnostic.SA1616.severity = error # The `<returns>` tag within a C# element's documentation header is empty.
dotnet_diagnostic.SA1618.severity = error # A generic C# element is missing documentation for one or more of its generic type parameters.
dotnet_diagnostic.SA1619.severity = error # A generic, partial C# element is missing documentation for one or more of its generic type parameters, and the documentation for the element contains a `<summary>` tag.
dotnet_diagnostic.SA1620.severity = error # The `<typeparam>` tags within the Xml header documentation for a generic C# element do not match the generic type parameters on the element.
dotnet_diagnostic.SA1621.severity = error # A `<typeparam>` tag within the Xml header documentation for a generic C# element is missing a name attribute, or contains an empty name attribute.
dotnet_diagnostic.SA1622.severity = error # A `<typeparam>` tag within the Xml header documentation for a generic C# element is empty.
dotnet_diagnostic.SA1625.severity = error # The Xml documentation for a C# element contains two or more identical entries, indicating that the documentation has been copied and pasted.
dotnet_diagnostic.SA1626.severity = error # The C# code contains a single-line comment which begins with three forward slashes in a row.
dotnet_diagnostic.SA1627.severity = error # The Xml header documentation for a C# code element contains an empty tag.
dotnet_diagnostic.SA1628.severity = error # A section of the Xml header documentation for a C# element does not begin with a capital letter.
dotnet_diagnostic.SA1629.severity = error # A section of the Xml header documentation for a C# element does not end with a period (also known as a full stop).
dotnet_diagnostic.SA1633.severity = warning # A C# code file is missing a standard file header.
dotnet_diagnostic.SA1634.severity = warning # The file header at the top of a C# code file is missing a copyright tag.
dotnet_diagnostic.SA1635.severity = warning # The file header at the top of a C# code file is missing copyright text.
dotnet_diagnostic.SA1636.severity = warning # The file header at the top of a C# code file does not contain the appropriate copyright text.
dotnet_diagnostic.SA1639.severity = warning # The file header at the top of a C# code file does not contain a filled-in summary tag.
dotnet_diagnostic.SA1640.severity = warning # The file header at the top of a C# code file does not contain company name text.
dotnet_diagnostic.SA1641.severity = warning # The file header at the top of a C# code file does not contain the appropriate company name text.
dotnet_diagnostic.SA1643.severity = error # The Xml documentation header for a C# finalizer does not contain the appropriate summary text.
dotnet_diagnostic.SA1644.severity = error # A section within the Xml documentation header for a C# element contains blank lines.
dotnet_diagnostic.SA1645.severity = error # An included Xml documentation file does not exist.
dotnet_diagnostic.SA1646.severity = error # An included Xml documentation link contains an invalid path.
dotnet_diagnostic.SA1647.severity = error # An include tag within an Xml documentation header does not contain valid file and path attribute.
dotnet_diagnostic.SA1648.severity = error # `<inheritdoc>` has been used on an element that doesn't inherit from a base class or implement an interface.
### Alternative Rules (SX0000-)
# Rules which are non-standard extensions to the default StyleCop behavior, and represent an alternative style which is adopted by some projects. Alternative rules are known to directly conflict with standard StyleCop rules.
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/AlternativeRules.md
dotnet_diagnostic.SX1101.severity = error # A call to an instance member of the local class or a base class is prefixed with 'this.', within a C# code file.
dotnet_diagnostic.SX1309.severity = none # A field name does not begin with an underscore.
dotnet_diagnostic.SX1309S.severity = none # A static field name does not begin with an underscore.
## **END** StyleCop.Analyzers **END**
@kurnakovv
Copy link
Author

Description

In this file I have collected all my favorite StyleCop rules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment