1
1
# Top-level config file
2
2
root = true
3
3
4
+ # All files
5
+ [* ]
6
+ indent_style = space
7
+
8
+ [* .yml ]
9
+ indent_size = 2
10
+
11
+ [* .md ]
12
+ charset = utf-8
13
+ insert_final_newline = true
14
+ end_of_line = unset # Leave it to git
15
+ indent_style = space
16
+ indent_size = 2
17
+ max_line_length = 80
18
+
19
+ # XML project files
20
+ [* .{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj} ]
21
+ indent_size = 2
22
+
23
+ # XML config files
24
+ [* .{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct} ]
25
+ indent_size = 2
26
+
4
27
# Generic C# files
5
- [* .cs ]
28
+ [* .{cs,vb} ]
6
29
7
30
# # Generic options
8
- charset = utf-8
31
+ charset = utf-8-bom
9
32
indent_size = 4
10
33
indent_style = space
11
34
tab_width = 8
12
35
trim_trailing_whitespace = true
13
- end_of_line = lf
36
+ end_of_line = unset # Leave it to git
14
37
insert_final_newline = true
15
38
16
39
# # .NET style rules
@@ -31,6 +54,7 @@ dotnet_style_predefined_type_for_member_access = true:warning
31
54
32
55
# ## Modifier preferences
33
56
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
57
+ dotnet_diagnostic.SA1400.severity = warning # it doesn't follow the above value
34
58
dotnet_style_readonly_field = true :warning
35
59
36
60
# ## Parentheses preferences
@@ -45,16 +69,16 @@ dotnet_style_collection_initializer = true:warning
45
69
dotnet_style_explicit_tuple_names = true :warning
46
70
dotnet_style_prefer_inferred_tuple_names = true :suggestion
47
71
dotnet_style_prefer_inferred_anonymous_type_member_names = true :suggestion
48
- dotnet_style_prefer_auto_properties = true :warning
72
+ dotnet_style_prefer_auto_properties = true :suggestion
49
73
dotnet_style_prefer_conditional_expression_over_assignment = true :warning
50
- dotnet_style_prefer_conditional_expression_over_return = true :suggestion
51
- dotnet_style_prefer_compound_assignment = true :warning
74
+ dotnet_style_prefer_conditional_expression_over_return = true :warning
75
+ dotnet_style_prefer_compound_assignment = true :suggestion
52
76
dotnet_style_prefer_simplified_interpolation = true :warning
53
77
dotnet_style_prefer_simplified_boolean_expressions = true :warning
54
78
dotnet_style_operator_placement_when_wrapping = end_of_line
55
79
56
80
# ## Null-checking preferences
57
- dotnet_style_coalesce_expression = true :warning
81
+ dotnet_style_coalesce_expression = true :suggestion
58
82
dotnet_style_null_propagation = true :warning
59
83
dotnet_style_prefer_is_null_check_over_reference_equality_method = true :warning
60
84
@@ -67,23 +91,25 @@ dotnet_remove_unnecessary_suppression_exclusions = none
67
91
csharp_style_var_for_built_in_types = false :warning
68
92
csharp_style_var_when_type_is_apparent = true :suggestion
69
93
csharp_style_var_elsewhere = false :suggestion
94
+ dotnet_diagnostic.IDE0008.severity = suggestion # Doesn't follow above values
70
95
71
96
# ## Expression-bodied members
72
- csharp_style_expression_bodied_methods = when_on_single_line:suggestion
97
+ csharp_style_expression_bodied_methods = false
73
98
csharp_style_expression_bodied_constructors = false :suggestion
74
99
csharp_style_expression_bodied_operators = true :suggestion
75
- csharp_style_expression_bodied_properties = when_on_single_line:warning
76
- csharp_style_expression_bodied_indexers = when_on_single_line:warning
77
- csharp_style_expression_bodied_accessors = when_on_single_line:warning
78
- csharp_style_expression_bodied_lambdas = when_on_single_line:warning
100
+ csharp_style_expression_bodied_properties = when_on_single_line:suggestion
101
+ csharp_style_expression_bodied_indexers = when_on_single_line:suggestion
102
+ csharp_style_expression_bodied_accessors = when_on_single_line:suggestion
103
+ csharp_style_expression_bodied_lambdas = when_on_single_line:suggestion
79
104
csharp_style_expression_bodied_local_functions = when_on_single_line:suggestion
80
105
81
106
# ## Pattern matching preferences
82
107
csharp_style_pattern_matching_over_is_with_cast_check = true :warning
83
108
csharp_style_pattern_matching_over_as_with_null_check = true :warning
84
- csharp_style_prefer_switch_expression = true :warning
85
- csharp_style_prefer_pattern_matching = true :warning
109
+ csharp_style_prefer_switch_expression = true :suggestion
110
+ csharp_style_prefer_pattern_matching = true :suggestion
86
111
csharp_style_prefer_not_pattern = true :warning
112
+ csharp_style_prefer_null_check_over_type_check = true :suggestion
87
113
88
114
# ## Expression-level preferences
89
115
csharp_style_inlined_variable_declaration = true :warning
@@ -95,25 +121,36 @@ csharp_style_prefer_range_operator = true:warning
95
121
csharp_style_implicit_object_creation_when_type_is_apparent = true :suggestion
96
122
csharp_style_unused_value_assignment_preference = discard_variable:warning
97
123
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
124
+ csharp_style_prefer_method_group_conversion = true :suggestion
125
+ csharp_style_prefer_local_over_anonymous_function = true :suggestion
98
126
99
127
# ## Null-checking preferences
100
128
csharp_style_throw_expression = true :warning
101
129
csharp_style_conditional_delegate_call = true :warning
102
130
103
131
# ## Code-block preferences
104
- csharp_prefer_braces = when_multiline:error
132
+ csharp_prefer_braces = true :warning
133
+ dotnet_diagnostic.SA1503.severity = warning # Doesn't follow above value
105
134
csharp_prefer_simple_using_statement = true :suggestion
135
+ csharp_style_prefer_tuple_swap = true :suggestion
106
136
107
137
# ## 'using' directive preferences
108
- csharp_using_directive_placement = outside_namespace:warning
138
+ csharp_using_directive_placement = inside_namespace:warning
139
+ dotnet_diagnostic.SA1200.severity = warning # Doesn't follow above value
109
140
110
141
# ## Modifier preferences
111
142
csharp_prefer_static_local_function = true :warning
112
143
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning
113
144
145
+ # ## New C# features
146
+ csharp_style_prefer_primary_constructors = true :suggestion
147
+ csharp_style_prefer_utf8_string_literals = true :suggestion
148
+ csharp_style_prefer_readonly_struct = true :suggestion
149
+ csharp_style_prefer_readonly_struct_member = true :suggestion
150
+
114
151
# # C# formatting rules
115
152
# ## New line preferences
116
- csharp_new_line_before_open_brace = local_functions, methods,types
153
+ csharp_new_line_before_open_brace = methods,types
117
154
csharp_new_line_before_else = false
118
155
csharp_new_line_before_catch = false
119
156
csharp_new_line_before_finally = false
@@ -128,6 +165,7 @@ csharp_indent_labels = one_less_than_current
128
165
csharp_indent_block_contents = true
129
166
csharp_indent_braces = false
130
167
csharp_indent_case_contents_when_block = false
168
+ csharp_style_namespace_declarations = file_scoped
131
169
132
170
# ## Spacing preferences
133
171
csharp_space_after_cast = false
@@ -157,32 +195,65 @@ csharp_space_between_square_brackets = false
157
195
csharp_preserve_single_line_statements = false
158
196
csharp_preserve_single_line_blocks = true
159
197
198
+ # ## Top level statement
199
+ csharp_style_prefer_top_level_statements = true :silent
200
+
160
201
# # Naming styles rules
202
+ dotnet_style_namespace_match_folder = true :warning
161
203
dotnet_diagnostic.IDE1006.severity = warning
162
204
205
+ dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning
206
+ dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
207
+ dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
208
+ dotnet_naming_style.begins_with_i.required_prefix = I
209
+ dotnet_naming_style.begins_with_i.required_suffix =
210
+ dotnet_naming_style.begins_with_i.word_separator =
211
+ dotnet_naming_style.begins_with_i.capitalization = pascal_case
212
+
213
+ dotnet_naming_rule.types_should_be_pascal_case.severity = warning
214
+ dotnet_naming_rule.types_should_be_pascal_case.symbols = types
215
+ dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
216
+ dotnet_naming_style.pascal_case.required_prefix =
217
+ dotnet_naming_style.pascal_case.required_suffix =
218
+ dotnet_naming_style.pascal_case.word_separator =
219
+ dotnet_naming_style.pascal_case.capitalization = pascal_case
220
+
221
+ dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning
222
+ dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
223
+ dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
224
+
225
+ # ## Symbol specifications
226
+ dotnet_naming_symbols.interface.applicable_kinds = interface
227
+ dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
228
+ dotnet_naming_symbols.interface.required_modifiers =
229
+
230
+ dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
231
+ dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
232
+ dotnet_naming_symbols.types.required_modifiers =
233
+
234
+ dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
235
+ dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
236
+ dotnet_naming_symbols.non_field_members.required_modifiers =
237
+
163
238
# # Code analyzers
164
239
# ## .NET SDK
165
240
dotnet_diagnostic.CA1303.severity = none # We don't translate exception and log messages from English
241
+ dotnet_diagnostic.SA1025.severity = none # Allow spaces in comments to structure info
242
+ dotnet_diagnostic.IDE0045.severity = suggestion # Simplify ifs
243
+ dotnet_diagnostic.IDE0046.severity = suggestion # Simplify ifs
166
244
167
245
# ## StyleCop
168
- dotnet_diagnostic.SA1009.severity = none # False positive due to nullables
169
- dotnet_diagnostic.SA1011.severity = none # False positive due to nullables
170
246
dotnet_diagnostic.SA1101.severity = none # Do not force to prefix local calls with ' this'
171
- dotnet_diagnostic.SA1137 .severity = none # False positive due to inline methods
247
+ dotnet_diagnostic.SA1204 .severity = suggestion # Static methods should be before non-static
172
248
dotnet_diagnostic.SA1500.severity = none # Allow inline braces
173
- dotnet_diagnostic.SA1503.severity = suggestion # Braces can be omitted (guards can)
174
249
dotnet_diagnostic.SA1633.severity = none # No XML-format header in source files
175
- dotnet_diagnostic.SA1200.severity = none # Namespace outside
176
-
177
- # ## IDE
178
- dotnet_diagnostic.IDE0058.severity = suggestion # Expression value is never used
179
250
180
251
# ## SonarAnalyzer
252
+ dotnet_diagnostic.S1133.severity = suggestion # Remove deprecated code -.-' I know, some day
181
253
dotnet_diagnostic.S1135.severity = suggestion # It's almost inevitable to have TODO but add bug ID
182
- dotnet_diagnostic.S1172.severity = silent # Buggy
183
254
184
255
# Special rules for test projects
185
- [{* Tests/** ,* Examples/** } ]
256
+ [{src/ * Tests/** ,src/ * Examples/** } ]
186
257
dotnet_diagnostic.CS1591.severity = none # Disable documentation
187
258
dotnet_diagnostic.CA1001.severity = none # No need to implement IDisposable in test classes with cleanup.
188
259
dotnet_diagnostic.CA1034.severity = none # Public types in test classes for testing implementations
@@ -192,11 +263,15 @@ dotnet_diagnostic.CA1305.severity = none # No culture method for quick test code
192
263
dotnet_diagnostic.CA1307.severity = none # No culture method for quick test code
193
264
dotnet_diagnostic.SA0001.severity = none # Disable documentation
194
265
dotnet_diagnostic.SA1600.severity = none # Disable documentation
266
+ dotnet_diagnostic.SA1201.severity = none # Allow enums inside classes
267
+ dotnet_diagnostic.S1144.severity = none # Remove unused setter
268
+ dotnet_diagnostic.S2094.severity = none # Remove empty class
195
269
dotnet_diagnostic.S2699.severity = none # Assert may be in helper methods
196
270
dotnet_diagnostic.S3966.severity = none # Dispose twice to test implementation
271
+ dotnet_code_quality_unused_parameters = all:none # Some test methods may not use all the source args
197
272
198
273
# Special rules for example projects
199
- [* Examples/** ]
274
+ [src/ * Examples/** ]
200
275
dotnet_diagnostic.SA1123.severity = none # We can have regions inside methods
201
276
dotnet_diagnostic.SA1515.severity = none # Allow comment lines after region
202
277
dotnet_diagnostic.S1481.severity = none # Unused variables
0 commit comments