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