@@ -104,32 +104,22 @@ dotnet_diagnostic.CA2007.severity = none # CA2007: Do not directly await
104104dotnet_diagnostic.CA2234.severity = silent # CA2234: Pass System.Uri objects instead of strings
105105
106106# #########################################
107- # Language Rules
108- # https://docs .microsoft.com/dotnet/fundamentals/ code-analysis/style-rules/language-rules
107+ # .NET code refactoring options
108+ # https://learn .microsoft.com/en-us/visualstudio/ide/reference/ code-styles-refactoring-options?view=vs-2022
109109# #########################################
110- # .NET Style Rules
111- # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#net-style-rules
112110[* .cs ]
113- # Parentheses preferences
114- dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
115- # Expression-level preferences
116- dotnet_diagnostic.IDE0010.severity = silent # Add missing cases to switch statement (IDE0010)
117- dotnet_style_prefer_conditional_expression_over_assignment = true :silent
118- dotnet_diagnostic.IDE0045.severity = suggestion # Use conditional expression for assignment (IDE0045)
119- dotnet_style_prefer_conditional_expression_over_return = true :silent
120- dotnet_diagnostic.IDE0046.severity = none # Use conditional expression for return (IDE0046)
121- # Undocumented
122111dotnet_style_operator_placement_when_wrapping = beginning_of_line
123112
124- # C# Style Rules
125- # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#c-style-rules
113+ # #########################################
114+ # Language and unnecessary rules
115+ # https://learn.microsoft.com/en-gb/dotnet/fundamentals/code-analysis/style-rules/language-rules
116+ # #########################################
126117[* .cs ]
127- # 'var' preferences
128- dotnet_diagnostic.IDE0008.severity = none # IDE0008: Use explicit type instead of ' var'
129- csharp_style_var_for_built_in_types = true :warning
130- csharp_style_var_when_type_is_apparent = true :warning
131- csharp_style_var_elsewhere = true :warning
132- # Expression-bodied members
118+
119+ # Code-block preferences https://learn.microsoft.com/en-gb/dotnet/fundamentals/code-analysis/style-rules/language-rules#code-block-preferences
120+ dotnet_diagnostic.IDE0290.severity = silent # Use primary constructor (IDE0290)
121+
122+ # Expression-bodied members https://learn.microsoft.com/en-gb/dotnet/fundamentals/code-analysis/style-rules/language-rules#expression-bodied-members
133123csharp_style_expression_bodied_methods = true :silent
134124dotnet_diagnostic.IDE0022.severity = silent # Use expression body for methods (IDE0022)
135125csharp_style_expression_bodied_operators = true :silent
@@ -144,18 +134,27 @@ csharp_style_expression_bodied_lambdas = true:silent
144134dotnet_diagnostic.IDE0053.severity = silent # Use expression body for lambdas (IDE0053)
145135csharp_style_expression_bodied_local_functions = true :silent
146136dotnet_diagnostic.IDE0061.severity = silent # Use expression body for local functions (IDE0061)
147- # Expression-level preferences
137+
138+ # Expression-level preferences https://learn.microsoft.com/en-gb/dotnet/fundamentals/code-analysis/style-rules/language-rules#expression-level-preferences
139+ dotnet_diagnostic.IDE0010.severity = silent # Add missing cases to switch statement (IDE0010)
140+ dotnet_style_prefer_conditional_expression_over_assignment = true :silent
141+ dotnet_diagnostic.IDE0045.severity = suggestion # Use conditional expression for assignment (IDE0045)
142+ dotnet_style_prefer_conditional_expression_over_return = true :silent
143+ dotnet_diagnostic.IDE0046.severity = none # Use conditional expression for return (IDE0046)
148144dotnet_diagnostic.IDE0057.severity = none # Use range operator (IDE0057)
145+ csharp_style_unused_value_expression_statement_preference = discard_variable:silent
146+ dotnet_diagnostic.IDE0058.severity = silent # Remove unnecessary expression value (IDE0058)
149147csharp_style_implicit_object_creation_when_type_is_apparent = false :silent
150148dotnet_diagnostic.IDE0090.severity = suggestion # Simplify new expression (IDE0090)
151149
152- # #########################################
153- # Unnecessary Code Rules
154- # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/unnecessary-code-rules
155- # #########################################
156- [* .cs ]
157- csharp_style_unused_value_expression_statement_preference = discard_variable:silent
158- dotnet_diagnostic.IDE0058.severity = silent # Remove unnecessary expression value (IDE0058)
150+ # Parentheses preferences https://learn.microsoft.com/en-gb/dotnet/fundamentals/code-analysis/style-rules/language-rules#parentheses-preferences
151+ dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
152+
153+ # 'var' preferences https://learn.microsoft.com/en-gb/dotnet/fundamentals/code-analysis/style-rules/language-rules#var-preferences
154+ dotnet_diagnostic.IDE0008.severity = none # IDE0008: Use explicit type instead of ' var'
155+ csharp_style_var_for_built_in_types = true :warning
156+ csharp_style_var_when_type_is_apparent = true :warning
157+ csharp_style_var_elsewhere = true :warning
159158
160159# #########################################
161160# Formatting Rules
@@ -498,7 +497,7 @@ dotnet_diagnostic.SA1006.severity = suggestion # SA1006: Preprocessor keywords
498497dotnet_diagnostic.SA1007.severity = suggestion # SA1007: Operator keyword should be followed by space
499498dotnet_diagnostic.SA1008.severity = suggestion # SA1008: Opening parenthesis should be spaced correctly
500499dotnet_diagnostic.SA1009.severity = suggestion # SA1009: Closing parenthesis should be spaced correctly
501- dotnet_diagnostic.SA1010.severity = suggestion # SA1010: Opening square brackets should be spaced correctly
500+ dotnet_diagnostic.SA1010.severity = none # SA1010: Opening square brackets should be spaced correctly # TODO review this, temporarily disabled until https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3687 is resolved. Hopefully soon by merging https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/3729
502501dotnet_diagnostic.SA1011.severity = suggestion # SA1011: Closing square brackets should be spaced correctly
503502dotnet_diagnostic.SA1012.severity = suggestion # SA1012: Opening braces should be spaced correctly
504503dotnet_diagnostic.SA1013.severity = suggestion # SA1013: Closing braces should be spaced correctly
0 commit comments