Last active
November 16, 2025 03:47
-
-
Save kurnakovv/b396696805339988a547c6d53a0d0254 to your computer and use it in GitHub Desktop.
Favorite Code-style (IDExxxx) rules in .editorconfig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [*.cs] | |
| ## | |
| ## Code-style (IDExxxx) rules | |
| ## | |
| # All rules here https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules | |
| dotnet_analyzer_diagnostic.category-Style.severity = error | |
| dotnet_analyzer_diagnostic.category-CodeQuality.severity = error | |
| ### ! Language rules ! ### | |
| # Rules that pertain to the C# or Visual Basic language. For example, you can specify rules that regard the use of var when defining variables, or whether expression-bodied members are preferred. This category also includes rules that find unnecessary code, for example, unreachable code within methods or unused private fields, properties, or methods. | |
| # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/language-rules | |
| ### 'using' directive preferences ### | |
| # Require file header (IDE0073) | |
| file_header_template = unset | |
| dotnet_diagnostic.IDE0073.severity = none | |
| # Remove unnecessary using directives (IDE0005) | |
| dotnet_diagnostic.IDE0005.severity = error # >= warning only if <GenerateDocumentationFile>true</GenerateDocumentationFile> in csproj | |
| dotnet_diagnostic.CS1573.severity = none # CS1573: Parameter has no matching param tag in the XML comment (but other parameters do) | |
| dotnet_diagnostic.CS1591.severity = none # CS1591: No XML docs | |
| ### Code-block preferences ### | |
| # Namespace declaration preferences (IDE0160, IDE0161) | |
| csharp_style_namespace_declarations = file_scoped | |
| dotnet_diagnostic.IDE0160.severity = none | |
| # Remove unnecessary lambda expression (IDE0200) | |
| csharp_style_prefer_method_group_conversion = false | |
| dotnet_diagnostic.IDE0200.severity = none | |
| # Convert to top-level statements (IDE0210) / Convert to 'Program.Main' style program (IDE0211) | |
| dotnet_diagnostic.IDE0211.severity = none | |
| csharp_style_prefer_top_level_statements = false | |
| # Use primary constructor (IDE0290) | |
| csharp_style_prefer_primary_constructors = false | |
| dotnet_diagnostic.IDE0290.severity = none | |
| ### Expression-bodied members ### | |
| dotnet_diagnostic.IDE0004.severity = none # Remove unnecessary cast (IDE0004) | |
| # Use expression body for operators (IDE0023, IDE0024) | |
| csharp_style_expression_bodied_operators = when_on_single_line | |
| # Use expression body for indexers (IDE0026) | |
| csharp_style_expression_bodied_indexers = when_on_single_line | |
| # Use expression body for lambdas (IDE0053) | |
| csharp_style_expression_bodied_lambdas = when_on_single_line | |
| ### Expression-level preferences ### | |
| # Use inferred member names (IDE0037) | |
| dotnet_style_prefer_inferred_anonymous_type_member_names = false | |
| # Use conditional expression for assignment (IDE0045) | |
| dotnet_style_prefer_conditional_expression_over_assignment = false | |
| dotnet_diagnostic.IDE0045.severity = none | |
| # Use conditional expression for return (IDE0046) | |
| dotnet_style_prefer_conditional_expression_over_return = false | |
| dotnet_diagnostic.IDE0046.severity = none | |
| dotnet_diagnostic.IDE0050.severity = none # (removed) Convert anonymous type to tuple (IDE0050) | |
| dotnet_diagnostic.IDE0058.severity = none # Remove unnecessary expression value (IDE0058) | |
| dotnet_diagnostic.IDE0059.severity = none # Remove unnecessary value assignment (IDE0059) | |
| # Simplify 'default' expression (IDE0034) | |
| csharp_prefer_simple_default_expression = false | |
| dotnet_diagnostic.IDE0034.severity = none | |
| # Use local function instead of lambda (IDE0039) | |
| csharp_style_prefer_local_over_anonymous_function = false | |
| dotnet_diagnostic.IDE0039.severity = none | |
| # Use index operator (IDE0056) | |
| csharp_style_prefer_index_operator = false | |
| dotnet_diagnostic.IDE0056.severity = none | |
| # Use range operator (IDE0057) | |
| csharp_style_prefer_range_operator = false | |
| dotnet_diagnostic.IDE0057.severity = none | |
| # Add explicit cast in foreach loop (IDE0220) | |
| dotnet_style_prefer_foreach_explicit_cast_in_source = always | |
| # Use collection expression for builder (IDE0304) | |
| dotnet_diagnostic.IDE0304.severity = none | |
| # Use unbound generic type (IDE0340) | |
| csharp_style_prefer_unbound_generic_type_in_nameof = false | |
| dotnet_diagnostic.IDE0340.severity = none | |
| # Use implicitly typed lambda (IDE0350) | |
| csharp_style_prefer_implicitly_typed_lambda_expression = false | |
| dotnet_diagnostic.IDE0350.severity = none | |
| ### Field preferences ### | |
| # Nothing yet | |
| ### Language keyword vs. framework types preferences ### | |
| # Nothing yet | |
| ### Modifier preferences ### | |
| # Make local function static (IDE0062) | |
| csharp_prefer_static_local_function = false | |
| dotnet_diagnostic.IDE0062.severity = none | |
| # Make anonymous function static (IDE0320) | |
| csharp_prefer_static_anonymous_function = false | |
| dotnet_diagnostic.IDE0320.severity = none | |
| ### New-line preferences ### | |
| # Avoid multiple blank lines (IDE2000)┼ | |
| dotnet_style_allow_multiple_blank_lines_experimental = false | |
| # Blank line required between block and subsequent statement (IDE2003)┼ | |
| dotnet_diagnostic.IDE2003.severity = none | |
| # Embedded statements must be on their own line (IDE2001)┼ | |
| dotnet_diagnostic.IDE2001.severity = none | |
| # Consecutive braces must not have blank line between them (IDE2002)┼ | |
| csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false | |
| # Blank line not allowed after constructor initializer colon (IDE2004)┼ | |
| csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false | |
| # Blank line not allowed after conditional expression token (IDE2005)┼ | |
| csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false | |
| # Blank line not allowed after arrow expression clause token (IDE2006)┼ | |
| csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false | |
| dotnet_diagnostic.IDE2006.severity = none | |
| ### Null-checking preferences ### | |
| # Nothing yet | |
| ### Parameter preferences ### | |
| # Nothing yet | |
| ### Parentheses preferences ### | |
| # Nothing yet | |
| ### Pattern-matching preferences ### | |
| # Nothing yet | |
| ### Suppression preferences ### | |
| # this and Me preferences (IDE0003, IDE0009) | |
| dotnet_diagnostic.IDE0009.severity = none # VB | |
| ### var preferences ### | |
| # 'var' preferences (IDE0007, IDE0008) | |
| dotnet_diagnostic.IDE0007.severity = none | |
| ### ! Formatting rules ! ### | |
| # Rules that pertain to the layout and structure of your code in order to make it easier to read. For example, you can specify a formatting option that defines whether spaces in control blocks are preferred or not. | |
| # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0055 | |
| dotnet_diagnostic.IDE0055.severity = error | |
| dotnet_sort_system_directives_first = true | |
| csharp_new_line_before_members_in_anonymous_types = false | |
| csharp_indent_case_contents_when_block = false | |
| ### ! Naming rules ! ### | |
| # Rules that pertain to the naming of code elements. For example, you can specify that async method names must have an "Async" suffix. | |
| # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/naming-rules | |
| dotnet_diagnostic.IDE1006.severity = error | |
| # Asynchronous methods must end with "Async" | |
| # Note: This rule does not work for interface methods, a better solution is https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1046 | |
| dotnet_naming_rule.asynchronous_methods_must_end_with_async.severity = error | |
| dotnet_naming_rule.asynchronous_methods_must_end_with_async.symbols = async_methods | |
| dotnet_naming_rule.asynchronous_methods_must_end_with_async.style = async_method_style | |
| dotnet_naming_symbols.async_methods.applicable_kinds = method | |
| dotnet_naming_symbols.async_methods.required_modifiers = async | |
| dotnet_naming_symbols.async_methods.applicable_accessibilities = * | |
| dotnet_naming_style.async_method_style.required_suffix = Async | |
| dotnet_naming_style.async_method_style.capitalization = pascal_case | |
| # Interfaces must start with "I" | |
| dotnet_naming_rule.interfaces_must_start_with_I.severity = error | |
| dotnet_naming_rule.interfaces_must_start_with_I.symbols = interfaces | |
| dotnet_naming_rule.interfaces_must_start_with_I.style = interface_style | |
| dotnet_naming_symbols.interfaces.applicable_kinds = interface | |
| dotnet_naming_symbols.interfaces.applicable_accessibilities = * | |
| dotnet_naming_style.interface_style.required_prefix = I | |
| dotnet_naming_style.interface_style.capitalization = pascal_case | |
| # Constants are UPPER_CASE | |
| dotnet_naming_rule.constants_are_upper_case.severity = error | |
| dotnet_naming_rule.constants_are_upper_case.symbols = constants | |
| dotnet_naming_rule.constants_are_upper_case.style = constant_style | |
| dotnet_naming_symbols.constants.applicable_kinds = field, local | |
| dotnet_naming_symbols.constants.required_modifiers = const | |
| dotnet_naming_style.constant_style.capitalization = all_upper | |
| # Private instance fields are camelCase and start with "_" | |
| dotnet_naming_rule.private_instance_fields_are_camel_case_and_start_with_.severity = error | |
| dotnet_naming_rule.private_instance_fields_are_camel_case_and_start_with_.symbols = private_instance_fields | |
| dotnet_naming_rule.private_instance_fields_are_camel_case_and_start_with_.style = private_instance_field_style | |
| dotnet_naming_symbols.private_instance_fields.applicable_kinds = field | |
| dotnet_naming_symbols.private_instance_fields.applicable_accessibilities = private | |
| dotnet_naming_style.private_instance_field_style.capitalization = camel_case | |
| dotnet_naming_style.private_instance_field_style.required_prefix = _ | |
| # Static fields must start with "s_" | |
| dotnet_naming_rule.static_fields_must_start_with_s_.severity = error | |
| dotnet_naming_rule.static_fields_must_start_with_s_.symbols = static_fields | |
| dotnet_naming_rule.static_fields_must_start_with_s_.style = static_field_style | |
| dotnet_naming_symbols.static_fields.applicable_kinds = field | |
| dotnet_naming_symbols.static_fields.required_modifiers = static | |
| dotnet_naming_style.static_field_style.capitalization = camel_case | |
| dotnet_naming_style.static_field_style.required_prefix = s_ | |
| # Locals and parameters are camelCase | |
| dotnet_naming_rule.locals_are_camel_case.severity = error | |
| dotnet_naming_rule.locals_are_camel_case.symbols = locals_and_parameters | |
| dotnet_naming_rule.locals_are_camel_case.style = local_and_parameter_style | |
| dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local | |
| dotnet_naming_style.local_and_parameter_style.capitalization = camel_case | |
| # Local functions are PascalCase | |
| dotnet_naming_rule.local_functions_are_pascal_case.severity = error | |
| dotnet_naming_rule.local_functions_are_pascal_case.symbols = local_functions | |
| dotnet_naming_rule.local_functions_are_pascal_case.style = local_function_style | |
| dotnet_naming_symbols.local_functions.applicable_kinds = local_function | |
| dotnet_naming_style.local_function_style.capitalization = pascal_case | |
| # Generic Type parameters are PascalCase and start with "T" | |
| dotnet_naming_rule.generic_type_parameters_are_pascal_case_and_start_with_t.severity = error | |
| dotnet_naming_rule.generic_type_parameters_are_pascal_case_and_start_with_t.symbols = generic_type_parameters | |
| dotnet_naming_rule.generic_type_parameters_are_pascal_case_and_start_with_t.style = generic_type_parameters_style | |
| dotnet_naming_symbols.generic_type_parameters.applicable_kinds = type_parameter | |
| dotnet_naming_style.generic_type_parameters_style.capitalization = pascal_case | |
| dotnet_naming_style.generic_type_parameters_style.required_prefix = T | |
| # All members are PascalCase | |
| dotnet_naming_rule.all_members_are_pascal_case.severity = error | |
| dotnet_naming_rule.all_members_are_pascal_case.symbols = all_members | |
| dotnet_naming_rule.all_members_are_pascal_case.style = all_members_style | |
| dotnet_naming_symbols.all_members.applicable_kinds = * | |
| dotnet_naming_style.all_members_style.capitalization = pascal_case | |
| ### ! Miscellaneous rules ! ### | |
| # Rules that do not belong in other categories. | |
| # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/miscellaneous-rules | |
| # Implement with Copilot (IDE3000) | |
| dotnet_diagnostic.IDE3000.severity = none | |
| [**Controller.cs] | |
| dotnet_naming_symbols.async_methods.applicable_accessibilities = private # This filter doesn't work for Rider | |
| dotnet_diagnostic.CS1573.severity = error # CS1573: Parameter has no matching param tag in the XML comment (but other parameters do) | |
| dotnet_diagnostic.CS1591.severity = error # CS1591: No XML docs |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All the same rules, but clearly written