1
+ ; EditorConfig to support per-solution formatting.
2
+ ; Use the EditorConfig VS add-in to make this work.
3
+ ; http://editorconfig.org/
4
+ ;
5
+ ; Here are some resources for what's supported for .NET/C#
6
+ ; https://kent-boogaart.com/blog/editorconfig-reference-for-c-developers
7
+ ; https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017
8
+ ;
9
+ ; Be **careful** editing this because some of the rules don't support adding a severity level
10
+ ; For instance if you change to `dotnet_sort_system_directives_first = true:warning` (adding `:warning`)
11
+ ; then the rule will be silently ignored.
12
+
13
+ ; This is the default for the codeline.
14
+ root = true
15
+
16
+ [* ]
17
+ indent_style = space
18
+ charset = utf-8
19
+ trim_trailing_whitespace = true
20
+ insert_final_newline = true
21
+
22
+ [* .cs ]
23
+ indent_size = 4
24
+ dotnet_sort_system_directives_first = true
25
+
26
+ # Don't use this. qualifier
27
+ dotnet_style_qualification_for_field = false :suggestion
28
+ dotnet_style_qualification_for_property = false :suggestion
29
+
30
+ # use int x = .. over Int32
31
+ dotnet_style_predefined_type_for_locals_parameters_members = true :suggestion
32
+
33
+ # use int.MaxValue over Int32.MaxValue
34
+ dotnet_style_predefined_type_for_member_access = true :suggestion
35
+
36
+ # Require var all the time.
37
+ csharp_style_var_for_built_in_types = true :suggestion
38
+ csharp_style_var_when_type_is_apparent = true :suggestion
39
+ csharp_style_var_elsewhere = true :suggestion
40
+
41
+ # Disallow throw expressions.
42
+ csharp_style_throw_expression = false :suggestion
43
+
44
+ # Newline settings
45
+ csharp_new_line_before_open_brace = all
46
+ csharp_new_line_before_else = true
47
+ csharp_new_line_before_catch = true
48
+ csharp_new_line_before_finally = true
49
+ csharp_new_line_before_members_in_object_initializers = true
50
+ csharp_new_line_before_members_in_anonymous_types = true
51
+
52
+ # Namespace settings
53
+ csharp_style_namespace_declarations = file_scoped
54
+
55
+ [* .{xml,config,* proj,nuspec,props,resx,targets,yml,tasks} ]
56
+ indent_size = 2
57
+
58
+ # Xml config files
59
+ [* .{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct} ]
60
+ indent_size = 2
61
+
62
+ [* .json ]
63
+ indent_size = 2
64
+
65
+ [* .{ps1,psm1} ]
66
+ indent_size = 4
67
+
68
+ [* .sh ]
69
+ indent_size = 4
70
+ end_of_line = lf
71
+
72
+ [* .{razor,cshtml} ]
73
+ charset = utf-8-bom
74
+
75
+ [* .{cs,vb} ]
76
+ # CA1018: Mark attributes with AttributeUsageAttribute
77
+ dotnet_diagnostic.CA1018.severity = warning
78
+
79
+ # CA1047: Do not declare protected member in sealed type
80
+ dotnet_diagnostic.CA1047.severity = warning
81
+
82
+ # CA1305: Specify IFormatProvider
83
+ dotnet_diagnostic.CA1305.severity = warning
84
+
85
+ # CA1507: Use nameof to express symbol names
86
+ dotnet_diagnostic.CA1507.severity = warning
87
+
88
+ # CA1725: Parameter names should match base declaration
89
+ dotnet_diagnostic.CA1725.severity = suggestion
90
+
91
+ # CA1802: Use literals where appropriate
92
+ dotnet_diagnostic.CA1802.severity = warning
93
+
94
+ # CA1805: Do not initialize unnecessarily
95
+ dotnet_diagnostic.CA1805.severity = warning
96
+
97
+ # CA1810: Do not initialize unnecessarily
98
+ dotnet_diagnostic.CA1810.severity = suggestion
99
+
100
+ # CA1821: Remove empty Finalizers
101
+ dotnet_diagnostic.CA1821.severity = warning
102
+
103
+ # CA1822: Make member static
104
+ dotnet_diagnostic.CA1822.severity = suggestion
105
+
106
+ # CA1823: Avoid unused private fields
107
+ dotnet_diagnostic.CA1823.severity = warning
108
+
109
+ # CA1825: Avoid zero-length array allocations
110
+ dotnet_diagnostic.CA1825.severity = warning
111
+
112
+ # CA1826: Do not use Enumerable methods on indexable collections. Instead use the collection directly
113
+ dotnet_diagnostic.CA1826.severity = warning
114
+
115
+ # CA1827: Do not use Count() or LongCount() when Any() can be used
116
+ dotnet_diagnostic.CA1827.severity = warning
117
+
118
+ # CA1828: Do not use CountAsync() or LongCountAsync() when AnyAsync() can be used
119
+ dotnet_diagnostic.CA1828.severity = warning
120
+
121
+ # CA1829: Use Length/Count property instead of Count() when available
122
+ dotnet_diagnostic.CA1829.severity = warning
123
+
124
+ # CA1830: Prefer strongly-typed Append and Insert method overloads on StringBuilder
125
+ dotnet_diagnostic.CA1830.severity = warning
126
+
127
+ # CA1831: Use AsSpan or AsMemory instead of Range-based indexers when appropriate
128
+ # CA1832: Use AsSpan or AsMemory instead of Range-based indexers when appropriate
129
+ # CA1833: Use AsSpan or AsMemory instead of Range-based indexers when appropriate
130
+ dotnet_diagnostic.CA1831.severity = warning
131
+ dotnet_diagnostic.CA1832.severity = warning
132
+ dotnet_diagnostic.CA1833.severity = warning
133
+
134
+ # CA1834: Consider using 'StringBuilder.Append(char)' when applicable
135
+ dotnet_diagnostic.CA1834.severity = warning
136
+
137
+ # CA1835: Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync'
138
+ dotnet_diagnostic.CA1835.severity = warning
139
+
140
+ # CA1836: Prefer IsEmpty over Count
141
+ dotnet_diagnostic.CA1836.severity = warning
142
+
143
+ # CA1837: Use 'Environment.ProcessId'
144
+ dotnet_diagnostic.CA1837.severity = warning
145
+
146
+ # CA1838: Avoid 'StringBuilder' parameters for P/Invokes
147
+ dotnet_diagnostic.CA1838.severity = warning
148
+
149
+ # CA1839: Use 'Environment.ProcessPath'
150
+ dotnet_diagnostic.CA1839.severity = warning
151
+
152
+ # CA1840: Use 'Environment.CurrentManagedThreadId'
153
+ dotnet_diagnostic.CA1840.severity = warning
154
+
155
+ # CA1841: Prefer Dictionary.Contains methods
156
+ dotnet_diagnostic.CA1841.severity = warning
157
+
158
+ # CA1842: Do not use 'WhenAll' with a single task
159
+ dotnet_diagnostic.CA1842.severity = warning
160
+
161
+ # CA1843: Do not use 'WaitAll' with a single task
162
+ dotnet_diagnostic.CA1843.severity = warning
163
+
164
+ # CA1845: Use span-based 'string.Concat'
165
+ dotnet_diagnostic.CA1845.severity = warning
166
+
167
+ # CA1846: Prefer AsSpan over Substring
168
+ dotnet_diagnostic.CA1846.severity = warning
169
+
170
+ # CA2008: Do not create tasks without passing a TaskScheduler
171
+ dotnet_diagnostic.CA2008.severity = warning
172
+
173
+ # CA2009: Do not call ToImmutableCollection on an ImmutableCollection value
174
+ dotnet_diagnostic.CA2009.severity = warning
175
+
176
+ # CA2011: Avoid infinite recursion
177
+ dotnet_diagnostic.CA2011.severity = warning
178
+
179
+ # CA2012: Use ValueTask correctly
180
+ dotnet_diagnostic.CA2012.severity = warning
181
+
182
+ # CA2013: Do not use ReferenceEquals with value types
183
+ dotnet_diagnostic.CA2013.severity = warning
184
+
185
+ # CA2014: Do not use stackalloc in loops.
186
+ dotnet_diagnostic.CA2014.severity = warning
187
+
188
+ # CA2016: Forward the 'CancellationToken' parameter to methods that take one
189
+ dotnet_diagnostic.CA2016.severity = warning
190
+
191
+ # CA2200: Rethrow to preserve stack details
192
+ dotnet_diagnostic.CA2200.severity = warning
193
+
194
+ # CA2208: Instantiate argument exceptions correctly
195
+ dotnet_diagnostic.CA2208.severity = warning
196
+
197
+ # IDE0035: Remove unreachable code
198
+ dotnet_diagnostic.IDE0035.severity = warning
199
+
200
+ # IDE0036: Order modifiers
201
+ csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
202
+ dotnet_diagnostic.IDE0036.severity = warning
203
+
204
+ # IDE0043: Format string contains invalid placeholder
205
+ dotnet_diagnostic.IDE0043.severity = warning
206
+
207
+ # IDE0044: Make field readonly
208
+ dotnet_diagnostic.IDE0044.severity = warning
209
+
210
+ # IDE0073: File header
211
+ dotnet_diagnostic.IDE0073.severity = warning
212
+ file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.
213
+
214
+ # IDE0161: Convert to file-scoped namespace
215
+ dotnet_diagnostic.IDE0161.severity = warning
216
+
217
+ [** /{test,samples,perf}/** .{cs,vb} ]
218
+ # CA1018: Mark attributes with AttributeUsageAttribute
219
+ dotnet_diagnostic.CA1018.severity = suggestion
220
+ # CA1507: Use nameof to express symbol names
221
+ dotnet_diagnostic.CA1507.severity = suggestion
222
+ # CA1802: Use literals where appropriate
223
+ dotnet_diagnostic.CA1802.severity = suggestion
224
+ # CA1805: Do not initialize unnecessarily
225
+ dotnet_diagnostic.CA1805.severity = suggestion
226
+ # CA1823: Avoid zero-length array allocations
227
+ dotnet_diagnostic.CA1825.severity = suggestion
228
+ # CA1826: Do not use Enumerable methods on indexable collections. Instead use the collection directly
229
+ dotnet_diagnostic.CA1826.severity = suggestion
230
+ # CA1827: Do not use Count() or LongCount() when Any() can be used
231
+ dotnet_diagnostic.CA1827.severity = suggestion
232
+ # CA1829: Use Length/Count property instead of Count() when available
233
+ dotnet_diagnostic.CA1829.severity = suggestion
234
+ # CA1834: Consider using 'StringBuilder.Append(char)' when applicable
235
+ dotnet_diagnostic.CA1834.severity = suggestion
236
+ # CA1835: Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync'
237
+ dotnet_diagnostic.CA1835.severity = suggestion
238
+ # CA1837: Use 'Environment.ProcessId'
239
+ dotnet_diagnostic.CA1837.severity = suggestion
240
+ # CA1838: Avoid 'StringBuilder' parameters for P/Invokes
241
+ dotnet_diagnostic.CA1838.severity = suggestion
242
+ # CA1841: Prefer Dictionary.Contains methods
243
+ dotnet_diagnostic.CA1841.severity = suggestion
244
+ # CA1844: Provide memory-based overrides of async methods when subclassing 'Stream'
245
+ dotnet_diagnostic.CA1844.severity = suggestion
246
+ # CA1845: Use span-based 'string.Concat'
247
+ dotnet_diagnostic.CA1845.severity = suggestion
248
+ # CA1846: Prefer AsSpan over Substring
249
+ dotnet_diagnostic.CA1846.severity = suggestion
250
+ # CA2008: Do not create tasks without passing a TaskScheduler
251
+ dotnet_diagnostic.CA2008.severity = suggestion
252
+ # IDE0044: Make field readonly
253
+ dotnet_diagnostic.IDE0044.severity = suggestion
254
+
255
+ # CA2016: Forward the 'CancellationToken' parameter to methods that take one
256
+ dotnet_diagnostic.CA2016.severity = suggestion
257
+
258
+ # Defaults for content in the shared src/ and shared runtime dir
259
+
260
+ [{** /Shared/runtime/** .{cs,vb},** /microsoft.extensions.hostfactoryresolver.sources/** .{cs,vb}} ]
261
+ # IDE0161: Convert to file-scoped namespace
262
+ dotnet_diagnostic.IDE0161.severity = silent
0 commit comments