@@ -5,53 +5,17 @@ root = true
5
5
[* ]
6
6
indent_style = tab
7
7
insert_final_newline = true
8
-
9
- # Build scripts
10
- [* .{yml,yaml} ]
11
- indent_style = spaces
12
- indent_size = 2
13
-
14
- # XML project files
15
- [* .{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct} ]
16
- indent_size = 2
17
-
18
- # Code files
19
- [* .cs ]
20
- indent_size = 4
21
8
tab_width = 4
22
- charset = utf-8-bom
23
-
24
- # # Dotnet code style settings:
25
-
26
- # Sort using and Import directives with System.* appearing first
27
- dotnet_sort_system_directives_first = true
28
- dotnet_separate_import_directive_groups = false
29
-
30
- # require accessibility modifiers
31
- dotnet_style_require_accessibility_modifiers = for_non_interface_members:error
32
-
33
- # Avoid "this." and "Me." if not necessary
34
- dotnet_style_qualification_for_field = false:refactoring
35
- dotnet_style_qualification_for_property = false:refactoring
36
- dotnet_style_qualification_for_method = false:refactoring
37
- dotnet_style_qualification_for_event = false:refactoring
9
+ indent_size = 4
10
+ charset = utf-8
38
11
39
- # Use language keywords instead of framework type names for type references
40
- dotnet_style_predefined_type_for_locals_parameters_members = true :error
41
- dotnet_style_predefined_type_for_member_access = true :suggestion
42
12
43
- # Suggest more modern language features when available
44
- dotnet_style_object_initializer = true :suggestion
45
- dotnet_style_collection_initializer = true :suggestion
46
- dotnet_style_coalesce_expression = true :suggestion
47
- dotnet_style_null_propagation = true :suggestion
48
- dotnet_style_explicit_tuple_names = true :suggestion
49
- dotnet_style_prefer_compound_assignment = true :warning
13
+ # ## Naming rules: ###
50
14
51
15
# Constants are PascalCase
52
16
dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
53
17
dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants
54
- dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style
18
+ dotnet_naming_rule.constants_should_be_pascal_case.style = non_private_static_field_style
55
19
56
20
dotnet_naming_symbols.constants.applicable_kinds = field, local
57
21
dotnet_naming_symbols.constants.required_modifiers = const
@@ -61,7 +25,7 @@ dotnet_naming_style.constant_style.capitalization = pascal_case
61
25
# Non-private readonly fields are PascalCase
62
26
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion
63
27
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
64
- dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style
28
+ dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_static_field_style
65
29
66
30
dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
67
31
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
@@ -113,7 +77,7 @@ dotnet_naming_style.camel_case_style.capitalization = camel_case
113
77
# Local functions are PascalCase
114
78
dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion
115
79
dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions
116
- dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style
80
+ dotnet_naming_rule.local_functions_should_be_pascal_case.style = non_private_static_field_style
117
81
118
82
dotnet_naming_symbols.local_functions.applicable_kinds = local_function
119
83
@@ -122,12 +86,85 @@ dotnet_naming_style.local_function_style.capitalization = pascal_case
122
86
# By default, name items with PascalCase
123
87
dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion
124
88
dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members
125
- dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style
89
+ dotnet_naming_rule.members_should_be_pascal_case.style = non_private_static_field_style
126
90
127
91
dotnet_naming_symbols.all_members.applicable_kinds = *
128
92
129
93
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
130
94
95
+
96
+ # ## Dotnet code style settings: ###
97
+
98
+ # Sort using and Import directives with System.* appearing first
99
+ dotnet_sort_system_directives_first = true
100
+ dotnet_separate_import_directive_groups = false
101
+
102
+ # require accessibility modifiers
103
+ dotnet_style_require_accessibility_modifiers = for_non_interface_members:error
104
+
105
+ # Avoid "this." and "Me." if not necessary
106
+ dotnet_style_qualification_for_field = false:refactoring
107
+ dotnet_style_qualification_for_property = false:refactoring
108
+ dotnet_style_qualification_for_method = false:refactoring
109
+ dotnet_style_qualification_for_event = false:refactoring
110
+
111
+ # Use language keywords instead of framework type names for type references
112
+ dotnet_style_predefined_type_for_locals_parameters_members = true :error
113
+ dotnet_style_predefined_type_for_member_access = true :suggestion
114
+
115
+ # Initializers
116
+ dotnet_style_object_initializer = true :suggestion
117
+ dotnet_style_collection_initializer = true :suggestion
118
+ dotnet_style_prefer_collection_expression = when_types_loosely_match:warning
119
+
120
+ # Null checks
121
+ dotnet_style_coalesce_expression = true :suggestion
122
+ dotnet_style_null_propagation = true :suggestion
123
+ dotnet_style_prefer_is_null_check_over_reference_equality_method = true :warning
124
+
125
+ # Tuple Naming
126
+ dotnet_style_explicit_tuple_names = true :suggestion
127
+ dotnet_style_prefer_inferred_tuple_names = true :suggestion
128
+ dotnet_style_prefer_inferred_anonymous_type_member_names = true :suggestion
129
+
130
+ # Assignments
131
+ dotnet_style_prefer_conditional_expression_over_assignment = true :error
132
+ dotnet_style_prefer_conditional_expression_over_return = true :warning
133
+ dotnet_style_prefer_compound_assignment = true :warning
134
+
135
+ # Parenthesis
136
+ dotnet_code_quality_unused_parameters = all:suggestion
137
+ dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion
138
+ dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
139
+ dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion
140
+ dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
141
+
142
+ # Miscellaneous
143
+ dotnet_style_prefer_auto_properties = true :warning
144
+ dotnet_style_prefer_simplified_boolean_expressions = true :warning
145
+ dotnet_style_prefer_simplified_interpolation = true :warning
146
+ dotnet_style_namespace_match_folder = true :warning
147
+ dotnet_style_operator_placement_when_wrapping = beginning_of_line
148
+ dotnet_style_readonly_field = true :warning
149
+
150
+ # New-line preferences
151
+ dotnet_style_allow_multiple_blank_lines_experimental = false :warning
152
+ dotnet_style_allow_statement_immediately_after_block_experimental = false :warning
153
+ csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false :warning
154
+ csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false :warning
155
+
156
+ # Build scripts
157
+ [* .{yml,yaml} ]
158
+ indent_style = spaces
159
+ indent_size = 2
160
+
161
+ # XML project files
162
+ [* .{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct} ]
163
+ indent_size = 2
164
+
165
+ # Code files
166
+ [* .cs ]
167
+
131
168
# # C# style settings:
132
169
133
170
# Newline settings
@@ -165,16 +202,6 @@ csharp_style_expression_bodied_properties = true:suggestion
165
202
csharp_style_expression_bodied_indexers = true :suggestion
166
203
csharp_style_expression_bodied_accessors = true :suggestion
167
204
168
- # Suggest more modern language features when available
169
- csharp_style_pattern_matching_over_is_with_cast_check = true :warning
170
- csharp_style_pattern_matching_over_as_with_null_check = true :warning
171
- csharp_style_inlined_variable_declaration = true :warning
172
- csharp_style_throw_expression = true :warning
173
- csharp_style_conditional_delegate_call = true :warning
174
- csharp_style_prefer_switch_expression = true :warning
175
- csharp_prefer_simple_using_statement = true :suggestion
176
- csharp_style_namespace_declarations = file_scoped:error
177
-
178
205
# Space preferences
179
206
csharp_space_after_cast = false
180
207
csharp_space_after_colon_in_inheritance_clause = true
@@ -204,12 +231,60 @@ csharp_prefer_braces = when_multiline:silent
204
231
csharp_preserve_single_line_blocks = true :silent
205
232
csharp_preserve_single_line_statements = true :silent
206
233
234
+ # Pattern Matching
235
+ csharp_style_prefer_pattern_matching = true :warning
236
+ csharp_style_prefer_not_pattern = true :warning
237
+ csharp_style_prefer_extended_property_pattern = true :warning
238
+ csharp_style_pattern_matching_over_as_with_null_check = true :warning
239
+ csharp_style_pattern_matching_over_is_with_cast_check = true :warning
240
+
241
+ # Namespace
242
+ csharp_style_namespace_declarations = file_scoped:error
243
+ csharp_using_directive_placement = outside_namespace:warning
244
+
245
+ # Suggest more modern language features when available
246
+ csharp_prefer_simple_default_expression = true :warning
247
+ csharp_prefer_simple_using_statement = true :suggestion
248
+ csharp_prefer_static_local_function = true :suggestion
249
+ csharp_style_conditional_delegate_call = true :warning
250
+ csharp_style_deconstructed_variable_declaration = true :warning
251
+ csharp_style_expression_bodied_lambdas = true :suggestion
252
+ csharp_style_implicit_object_creation_when_type_is_apparent = true :suggestion
253
+ csharp_style_inlined_variable_declaration = true :warning
254
+ csharp_style_prefer_index_operator = true :suggestion
255
+ csharp_style_prefer_local_over_anonymous_function = true :suggestion
256
+ csharp_style_prefer_method_group_conversion = true :silent
257
+ csharp_style_prefer_null_check_over_type_check = true :suggestion
258
+ csharp_style_prefer_primary_constructors = true :warning
259
+ csharp_style_prefer_range_operator = true :suggestion
260
+ csharp_style_prefer_readonly_struct = true :suggestion
261
+ csharp_style_prefer_readonly_struct_member = true :suggestion
262
+ csharp_style_prefer_switch_expression = true :warning
263
+ csharp_style_prefer_top_level_statements = true :silent
264
+ csharp_style_prefer_tuple_swap = true :suggestion
265
+ csharp_style_prefer_utf8_string_literals = true :suggestion
266
+ csharp_style_throw_expression = true :warning
267
+ csharp_style_unused_value_assignment_preference = discard_variable:warning
268
+ csharp_style_unused_value_expression_statement_preference = discard_variable:warning
269
+
270
+ # New Lines
271
+ csharp_style_allow_embedded_statements_on_same_line_experimental = true :silent
272
+ csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true :silent
273
+ csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true :silent
274
+ csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true :silent
275
+ csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true :silent
276
+
277
+
207
278
# Style Analytics
208
279
dotnet_analyzer_diagnostic.category-Style.severity = warning
280
+ dotnet_analyzer_diagnostic.category-Globalization.severity = error
209
281
210
282
dotnet_diagnostic.IDE0011.severity = silent # IDE0011: Add braces
211
283
dotnet_diagnostic.IDE0046.severity = silent # IDE0046: Convert to conditional expression
212
- dotnet_diagnostic.IDE0028.severity = none # IDE0028: Simplify collection initialization
284
+ dotnet_diagnostic.IDE0043.severity = error # IDE0043: Format string contains invalid placeholder
285
+ dotnet_diagnostic.IDE0051.severity = warning # IDE0051: Remove unused private member
286
+ dotnet_diagnostic.IDE0052.severity = warning # IDE0052: Remove unread private member
287
+ dotnet_diagnostic.IDE0076.severity = warning # IDE0076: Remove invalid global ' SuppressMessageAttribute'
213
288
dotnet_diagnostic.IDE0305.severity = none # IDE0305: Simplify collection initialization
214
289
215
290
# XML Documentation
@@ -229,9 +304,6 @@ dotnet_diagnostic.CA2000.severity = error # CA2000: Dispose object
229
304
dotnet_diagnostic.CA2007.severity = none # CA2007: Consider calling ConfigureAwait on the awaited task
230
305
dotnet_diagnostic.CA5394.severity = none # CA5394: Random is an insecure random number generator. Use cryptographically secure random number generators when randomness is required for security.
231
306
232
- # False Positive
233
- dotnet_diagnostic.IDE0251.severity = none # IDE0251: Make member readonly
234
-
235
307
# Public API Documentation
236
308
dotnet_diagnostic.RS0016.severity = error # RS0016: Add public types and members to the declared API
237
309
dotnet_diagnostic.RS0017.severity = error # RS0017: Remove deleted types and members from the declared API
@@ -246,3 +318,32 @@ dotnet_diagnostic.CS9107.severity = error # CS9107: Parameter is captured int
246
318
dotnet_diagnostic.CS9113.severity = error # CS9113: Your class never references the primary constructor
247
319
dotnet_diagnostic.CS9124.severity = error # CS9124: Parameter is captured into the state of the enclosing type and its value is also used to initialize a field, property, or event
248
320
dotnet_diagnostic.CS9179.severity = error # CS9179: Primary constructor parameter is shadowed by a member from base
321
+
322
+ # Regex (can't use generated regex on pre-net7)
323
+ dotnet_diagnostic.SYSLIB1045.severity = none # SYSLIB1045: Use GeneratedRegexAttribute to generate the regular expression implementation at compile time.
324
+
325
+ # Miscellaneous analyzers
326
+ dotnet_diagnostic.CA1051.severity = error # CA1051: Do not declare visible instance fields
327
+ dotnet_diagnostic.CA1307.severity = error # CA1307: Specify StringComparison for clarity
328
+ dotnet_diagnostic.CA1507.severity = warning # CA1507: Use `nameof` in place of string
329
+ dotnet_diagnostic.CA1510.severity = error # CA1510: Use `ArgumentNullException` throw helper
330
+ dotnet_diagnostic.CA1511.severity = error # CA1511: Use `ArgumentException` throw helper
331
+ dotnet_diagnostic.CA1512.severity = error # CA1512: Use `ArgumentOutOfRangeException` throw helper
332
+ dotnet_diagnostic.CA1513.severity = error # CA1513: Use `ObjectDisposedException` throw helper
333
+ dotnet_diagnostic.CA1822.severity = warning # CA1822: Mark members as static
334
+ dotnet_diagnostic.CA1825.severity = error # CA1825: Avoid zero-length array allocations
335
+ dotnet_diagnostic.CA1826.severity = warning # CA1826: Use property instead of Linq Enumerable method
336
+ dotnet_diagnostic.CA1827.severity = warning # CA1827: Do not use Count()/LongCount() when Any() can be used
337
+ dotnet_diagnostic.CA1828.severity = warning # CA1828: Do not use CountAsync/LongCountAsync when AnyAsync can be used
338
+ dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Enumerable.Count method
339
+ dotnet_diagnostic.CA1841.severity = error # CA1841: Prefer Dictionary Contains methods
340
+ dotnet_diagnostic.CA1845.severity = warning # CA1845: Use span-based ' string.Concat'
341
+ dotnet_diagnostic.CA1852.severity = warning # CA1852: CA1852: Seal internal types
342
+ dotnet_diagnostic.CA1853.severity = warning # CA1853: Unnecessary call to ' Dictionary.ContainsKey(key)'
343
+ dotnet_diagnostic.CA1854.severity = warning # CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method
344
+ dotnet_diagnostic.CA1862.severity = warning # CA1862: Use the ' StringComparison' method overloads to perform case-insensitive string comparisons
345
+ dotnet_diagnostic.CA1863.severity = warning # CA1863: Use ' CompositeFormat'
346
+ dotnet_diagnostic.CA1864.severity = warning # CA1864: Prefer the ' IDictionary.TryAdd(TKey, TValue)' method
347
+ dotnet_diagnostic.CA1868.severity = warning # CA1868: Unnecessary call to ' Contains' for sets
348
+ dotnet_diagnostic.CA2014.severity = error # CA2014: Do not use stackalloc in loops
349
+ dotnet_diagnostic.CA2016.severity = error # CA2016: Forward the CancellationToken parameter to methods that take one
0 commit comments