|
| 1 | +# EditorConfig is awesome: https://EditorConfig.org |
| 2 | +# top-most EditorConfig file |
| 3 | +root = true |
| 4 | + |
| 5 | +# DO NOT CHANGE SETTINGS IN THIS FILE. PLEASE CREATE PULL REQUEST IN REPOSITORY `dotnet-engineering`. |
| 6 | + |
| 7 | +# Don't use tabs for indentation. |
| 8 | +[*] |
| 9 | +insert_final_newline = true |
| 10 | +indent_style = space |
| 11 | +trim_trailing_whitespace = true |
| 12 | +charset = utf-8 |
| 13 | +end_of_line = lf |
| 14 | +max_line_length = 120 |
| 15 | + |
| 16 | +# Verify settings |
| 17 | +# https://github.com/VerifyTests/Verify?tab=readme-ov-file#text-file-settings |
| 18 | +[*.{received,verified}.{txt,xml,json}] |
| 19 | +charset = utf-8-bom |
| 20 | +end_of_line = lf |
| 21 | +indent_size = unset |
| 22 | +indent_style = unset |
| 23 | +insert_final_newline = false |
| 24 | +tab_width = unset |
| 25 | +trim_trailing_whitespace = false |
| 26 | + |
| 27 | +# Code files |
| 28 | +[*.{cs,csx,vb,vbx,razor,razor.cs}] |
| 29 | +indent_size = 4 |
| 30 | +insert_final_newline = true |
| 31 | +charset = utf-8-bom |
| 32 | + |
| 33 | +# Razor and cshtml files |
| 34 | +# UTF-8-BOM is set as default, as all official template files use UTF-8-BOM |
| 35 | +# See https://github.com/dotnet/aspnetcore/pull/23502 and https://github.com/dotnet/aspnetcore/issues/22753 |
| 36 | +[*.{razor,cshtml}] |
| 37 | +charset = utf-8-bom |
| 38 | +indent_size = 4 |
| 39 | + |
| 40 | +# Generated code |
| 41 | +[*{_AssemblyInfo.cs,.notsupported.cs,.generated.cs}] |
| 42 | +generated_code = true |
| 43 | + |
| 44 | +# XML project files |
| 45 | +[*.{slnx,csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,nativeproj,locproj}] |
| 46 | +indent_size = 2 |
| 47 | + |
| 48 | +# Xml build files |
| 49 | +[*.builds] |
| 50 | +indent_size = 2 |
| 51 | + |
| 52 | +# Xml files |
| 53 | +[*.{xml,stylecop,resx,ruleset}] |
| 54 | +indent_size = 2 |
| 55 | + |
| 56 | +# XML config files |
| 57 | +[*.{props,targets,ruleset,config,nuspec,vsixmanifest,vsct}] |
| 58 | +indent_size = 2 |
| 59 | + |
| 60 | +# JSON files |
| 61 | +[*.json] |
| 62 | +indent_size = 2 |
| 63 | + |
| 64 | +# YAML files |
| 65 | +[*.{yml,yaml}] |
| 66 | +indent_size = 2 |
| 67 | + |
| 68 | +# Powershell files |
| 69 | +[*.ps1] |
| 70 | +indent_size = 2 |
| 71 | + |
| 72 | +# Shell scripts |
| 73 | +[*.sh] |
| 74 | +indent_size = 2 |
| 75 | + |
| 76 | +# Commandline scripts |
| 77 | +[*.{cmd,bat}] |
| 78 | +end_of_line = crlf |
| 79 | +indent_size = 2 |
| 80 | + |
| 81 | +[*.md] |
| 82 | +trim_trailing_whitespace = false |
| 83 | +insert_final_newline = false |
| 84 | + |
| 85 | +# Visual Studio Solution Files |
| 86 | +[*.sln] |
| 87 | +indent_style = tab |
| 88 | + |
| 89 | +[*.{received,verified}.txt] |
| 90 | +insert_final_newline = false |
| 91 | +trim_trailing_whitespace = false |
| 92 | + |
| 93 | +[*.{cs,csx,vb,vbx}] |
| 94 | +# .NET Code Style Settings |
| 95 | +# See https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference |
| 96 | +dotnet_sort_system_directives_first = true |
| 97 | +dotnet_separate_import_directive_groups = false |
| 98 | + |
| 99 | +# Don't use 'this.'/'Me.' prefix for anything |
| 100 | +dotnet_style_qualification_for_field = false : error |
| 101 | +dotnet_style_qualification_for_property = false : error |
| 102 | +dotnet_style_qualification_for_method = false : error |
| 103 | +dotnet_style_qualification_for_event = false : error |
| 104 | + |
| 105 | +# Use language keywords over framework type names for type references |
| 106 | +# i.e. prefer 'string' over 'String' |
| 107 | +dotnet_style_predefined_type_for_locals_parameters_members = true : error |
| 108 | +dotnet_style_predefined_type_for_member_access = true : error |
| 109 | + |
| 110 | +# Prefer object/collection initializers |
| 111 | +# This is a suggestion because there are cases where this is necessary |
| 112 | +dotnet_style_object_initializer = true : warning |
| 113 | +dotnet_style_collection_initializer = true : warning |
| 114 | + |
| 115 | +# C# 7: Prefer using named tuple names over '.Item1', '.Item2', etc. |
| 116 | +dotnet_style_explicit_tuple_names = true : error |
| 117 | + |
| 118 | +# Prefer using 'foo ?? bar' over 'foo is not null ? foo : bar' |
| 119 | +dotnet_style_coalesce_expression = true : error |
| 120 | + |
| 121 | +# Prefer using '?.' over ternary null checking where possible |
| 122 | +dotnet_style_null_propagation = true : error |
| 123 | + |
| 124 | +# Modifier preferences |
| 125 | +# See https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#normalize-modifiers |
| 126 | +dotnet_style_require_accessibility_modifiers = for_non_interface_members : error |
| 127 | +dotnet_style_readonly_field = true : warning |
| 128 | + |
| 129 | +# Required Styles |
| 130 | +dotnet_naming_style.all_const.capitalization = pascal_case |
| 131 | +dotnet_naming_symbols.all_const.applicable_kinds = field |
| 132 | +dotnet_naming_symbols.all_const.required_modifiers = const |
| 133 | +dotnet_naming_rule.all_const.severity = error |
| 134 | +dotnet_naming_rule.all_const.style = all_elements |
| 135 | +dotnet_naming_rule.all_const.symbols = all_const |
| 136 | + |
| 137 | +dotnet_naming_style.all_fields.required_prefix = _ |
| 138 | +dotnet_naming_style.all_fields.capitalization = camel_case |
| 139 | +dotnet_naming_symbols.all_fields.applicable_kinds = field |
| 140 | +dotnet_naming_rule.all_fields.severity = error |
| 141 | +dotnet_naming_rule.all_fields.style = all_fields |
| 142 | +dotnet_naming_rule.all_fields.symbols = all_fields |
| 143 | + |
| 144 | +dotnet_naming_style.all_interfaces.required_prefix = I |
| 145 | +dotnet_naming_style.all_interfaces.capitalization = pascal_case |
| 146 | +dotnet_naming_symbols.all_interfaces.applicable_kinds = interface |
| 147 | +dotnet_naming_rule.all_interfaces.severity = error |
| 148 | +dotnet_naming_rule.all_interfaces.style = all_interfaces |
| 149 | +dotnet_naming_rule.all_interfaces.symbols = all_interfaces |
| 150 | + |
| 151 | +dotnet_naming_style.all_type_parameter.required_prefix = T |
| 152 | +dotnet_naming_style.all_type_parameter.capitalization = pascal_case |
| 153 | +dotnet_naming_symbols.all_type_parameter.applicable_kinds = type_parameter |
| 154 | +dotnet_naming_rule.all_type_parameter.severity = error |
| 155 | +dotnet_naming_rule.all_type_parameter.style = all_type_parameter |
| 156 | +dotnet_naming_rule.all_type_parameter.symbols = all_type_parameter |
| 157 | + |
| 158 | +dotnet_naming_style.abstract_class.required_suffix = Base |
| 159 | +dotnet_naming_style.abstract_class.capitalization = pascal_case |
| 160 | +dotnet_naming_symbols.abstract_class.applicable_kinds = class |
| 161 | +dotnet_naming_symbols.abstract_class.required_modifiers = abstract |
| 162 | +dotnet_naming_rule.abstract_class.severity = warning |
| 163 | +dotnet_naming_rule.abstract_class.style = abstract_class |
| 164 | +dotnet_naming_rule.abstract_class.symbols = abstract_class |
| 165 | + |
| 166 | +dotnet_naming_style.method_async.required_suffix = Async |
| 167 | +dotnet_naming_style.method_async.capitalization = pascal_case |
| 168 | +dotnet_naming_symbols.method_async.applicable_kinds = method |
| 169 | +dotnet_naming_symbols.method_async.required_modifiers = async |
| 170 | +dotnet_naming_rule.method_async.severity = warning |
| 171 | +dotnet_naming_rule.method_async.style = method_async |
| 172 | +dotnet_naming_rule.method_async.symbols = method_async |
| 173 | + |
| 174 | +dotnet_naming_style.all_elements.capitalization = pascal_case |
| 175 | +dotnet_naming_symbols.all_elements.applicable_kinds = namespace,class,struct,enum,property,method,event,delegate,local_function |
| 176 | +dotnet_naming_rule.all_elements.severity = error |
| 177 | +dotnet_naming_rule.all_elements.style = all_elements |
| 178 | +dotnet_naming_rule.all_elements.symbols = all_elements |
| 179 | + |
| 180 | +dotnet_naming_style.all_parameters.capitalization = camel_case |
| 181 | +dotnet_naming_symbols.all_parameters.applicable_kinds = parameter,local |
| 182 | +dotnet_naming_rule.all_parameters.severity = error |
| 183 | +dotnet_naming_rule.all_parameters.style = all_parameters |
| 184 | +dotnet_naming_rule.all_parameters.symbols = all_parameters |
| 185 | + |
| 186 | +dotnet_style_operator_placement_when_wrapping = beginning_of_line |
| 187 | +dotnet_style_prefer_is_null_check_over_reference_equality_method = true : suggestion |
| 188 | +dotnet_style_prefer_auto_properties = true : silent |
| 189 | + |
| 190 | +# Placement for using directives |
| 191 | +csharp_using_directive_placement = inside_namespace : warning |
| 192 | + |
| 193 | +# Use 'var' in all cases where it can be used |
| 194 | +csharp_style_var_for_built_in_types = true : error |
| 195 | +csharp_style_var_when_type_is_apparent = true : error |
| 196 | +csharp_style_var_elsewhere = true : error |
| 197 | + |
| 198 | +# Unused value preferences |
| 199 | +csharp_style_unused_value_expression_statement_preference = discard_variable : warning |
| 200 | +csharp_style_unused_value_assignment_preference = discard_variable : warning |
| 201 | + |
| 202 | +# C# 7: Prefer using pattern matching over "if(x is T) { var t = (T)x; }" and "var t = x as T; if(t is not null) { ... }" |
| 203 | +csharp_style_pattern_matching_over_is_with_cast_check = true : warning |
| 204 | +csharp_style_pattern_matching_over_as_with_null_check = true : warning |
| 205 | + |
| 206 | +# C# 7: Prefer using 'out var' where possible |
| 207 | +csharp_style_inlined_variable_declaration = true : error |
| 208 | + |
| 209 | +# C# 7: Use throw expressions when null-checking |
| 210 | +csharp_style_throw_expression = false : error |
| 211 | + |
| 212 | +# Prefer using "func?.Invoke(args)" over "if(func is not null) { func(args); }" |
| 213 | +csharp_style_conditional_delegate_call = true : error |
| 214 | + |
| 215 | +# Newline settings |
| 216 | +csharp_indent_braces = false |
| 217 | +csharp_open_brace_on_new_line = all |
| 218 | +csharp_new_line_before_open_brace = all |
| 219 | +csharp_new_line_before_else = true |
| 220 | +csharp_new_line_before_catch = true |
| 221 | +csharp_new_line_before_finally = true |
| 222 | +csharp_new_line_before_members_in_object_initializers = true |
| 223 | +csharp_new_line_before_members_in_anonymous_types = true |
| 224 | + |
| 225 | +# Prefer expression-bodied methods, constructors, operators, etc. |
| 226 | +csharp_style_expression_bodied_methods = true : warning |
| 227 | +csharp_style_expression_bodied_constructors = true : warning |
| 228 | +csharp_style_expression_bodied_operators = true : warning |
| 229 | +csharp_style_expression_bodied_properties = true : warning |
| 230 | +csharp_style_expression_bodied_indexers = true : warning |
| 231 | +csharp_style_expression_bodied_accessors = true : warning |
| 232 | + |
| 233 | +# Prefer Braces even for one line of code, because of |
| 234 | +csharp_prefer_braces = true : error |
| 235 | +csharp_type_declaration_braces = next_line |
| 236 | +csharp_invocable_declaration_braces = next_line |
| 237 | +csharp_anonymous_method_declaration_braces = next_line |
| 238 | +csharp_accessor_owner_declaration_braces = next_line |
| 239 | +csharp_accessor_declaration_braces = next_line |
| 240 | +csharp_case_block_braces = next_line |
| 241 | +csharp_initializer_braces = next_line |
| 242 | +csharp_other_braces = next_line |
| 243 | + |
| 244 | +# Tuple Preferences |
| 245 | +csharp_style_deconstructed_variable_declaration = true : warning |
| 246 | + |
| 247 | +# Simplify new expression (IDE0090) |
| 248 | +csharp_style_implicit_object_creation_when_type_is_apparent = false |
| 249 | +csharp_style_namespace_declarations = file_scoped : warning |
| 250 | +csharp_prefer_simple_using_statement = false : suggestion |
| 251 | +csharp_indent_labels = one_less_than_current |
| 252 | +csharp_style_expression_bodied_lambdas = true : silent |
| 253 | +csharp_style_expression_bodied_local_functions = false : silent |
| 254 | + |
| 255 | +# Use Compound assignment |
| 256 | +dotnet_style_prefer_compound_assignment = false |
| 257 | + |
| 258 | +# Prefer if-else statement |
| 259 | +dotnet_style_prefer_conditional_expression_over_return = false |
| 260 | +dotnet_diagnostic.IDE0046.severity = suggestion |
| 261 | + |
| 262 | +# Prefer standard constructors |
| 263 | +csharp_style_prefer_primary_constructors = false |
| 264 | +dotnet_diagnostic.IDE0290.severity = suggestion |
| 265 | + |
| 266 | +# [CSharpier] Incompatible rules deactivated |
| 267 | +# https://csharpier.com/docs/IntegratingWithLinters#code-analysis-rules |
| 268 | +dotnet_diagnostic.IDE0055.severity = none |
| 269 | +dotnet_diagnostic.SA1000.severity = none |
| 270 | +dotnet_diagnostic.SA1009.severity = none |
| 271 | +dotnet_diagnostic.SA1111.severity = none |
| 272 | +dotnet_diagnostic.SA1118.severity = none |
| 273 | +dotnet_diagnostic.SA1137.severity = none |
| 274 | +dotnet_diagnostic.SA1413.severity = none |
| 275 | +dotnet_diagnostic.SA1500.severity = none |
| 276 | +dotnet_diagnostic.SA1501.severity = none |
| 277 | +dotnet_diagnostic.SA1502.severity = none |
| 278 | +dotnet_diagnostic.SA1504.severity = none |
| 279 | +dotnet_diagnostic.SA1515.severity = none |
| 280 | +dotnet_diagnostic.SA1516.severity = none |
| 281 | + |
| 282 | +# Support for NetEvolve.Arguments Methods |
| 283 | +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1062#null-check-validation-methods |
| 284 | +dotnet_code_quality.CA1062.null_check_validation_methods = M:NetEvolve.Arguments.Argument.ThrowIfNull(System.Object,System.String)|M:NetEvolve.Arguments.Argument.ThrowIfNull(System.Void*,System.String)|M:NetEvolve.Arguments.Argument.ThrowIfNullOrEmpty(System.String,System.String)|M:NetEvolve.Arguments.Argument.ThrowIfNullOrEmpty``1(System.Collections.Generic.IEnumerable{``0},System.String)|M:NetEvolve.Arguments.Argument.ThrowIfNullOrWhiteSpace(System.String,System.String) |
0 commit comments