|
| 1 | +# EditorConfig is awesome: https://EditorConfig.org |
| 2 | + |
| 3 | +# top-most EditorConfig file |
| 4 | +root = true |
| 5 | + |
| 6 | +# Don't use tabs for indentation. |
| 7 | +[*] |
| 8 | +indent_style = space |
| 9 | +# (Please don't specify an indent_size here; that has too many unintended consequences.) |
| 10 | +charset = utf-8 |
| 11 | +insert_final_newline = true |
| 12 | +trim_trailing_whitespace = true |
| 13 | + |
| 14 | +[.cs] |
| 15 | +indent_size = 4 |
| 16 | + |
| 17 | +# This may not be needed, but kept for compatibility with VS |
| 18 | +[*.{sln,csproj}] |
| 19 | +end_of_line = crlf |
| 20 | +indent_size = 2 |
| 21 | + |
| 22 | +# XML config files |
| 23 | +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] |
| 24 | +indent_size = 2 |
| 25 | + |
| 26 | +# Markdown files allows the use of trailing spaces to denote |
| 27 | +# a line break |
| 28 | +[*.md] |
| 29 | +trim_trailing_whitespace = false |
| 30 | + |
| 31 | +# Batch and powershell files |
| 32 | +[*.{bat,ps1}] |
| 33 | +charset = utf-8-bom |
| 34 | +end_of_line = crlf |
| 35 | +indent_size = 2 |
| 36 | + |
| 37 | +# Shell scripts |
| 38 | +[*.sh] |
| 39 | +end_of_line = lf |
| 40 | +indent_size = 2 |
| 41 | + |
| 42 | +# Dotnet code style settings: |
| 43 | +[*.{cs,vb}] |
| 44 | + |
| 45 | +# IDE0055: Fix formatting |
| 46 | +dotnet_diagnostic.IDE0055.severity = warning |
| 47 | + |
| 48 | +# Sort using and Import directives with System.* appearing first |
| 49 | +dotnet_sort_system_directives_first = true |
| 50 | +dotnet_separate_import_directive_groups = false |
| 51 | +# Avoid "this." and "Me." if not necessary |
| 52 | +dotnet_style_qualification_for_field = false:refactoring |
| 53 | +dotnet_style_qualification_for_property = false:refactoring |
| 54 | +dotnet_style_qualification_for_method = false:refactoring |
| 55 | +dotnet_style_qualification_for_event = false:refactoring |
| 56 | + |
| 57 | +# Use language keywords instead of framework type names for type references |
| 58 | +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion |
| 59 | +dotnet_style_predefined_type_for_member_access = true:suggestion |
| 60 | + |
| 61 | +# Suggest more modern language features when available |
| 62 | +dotnet_style_object_initializer = true:suggestion |
| 63 | +dotnet_style_collection_initializer = true:suggestion |
| 64 | +dotnet_style_coalesce_expression = true:suggestion |
| 65 | +dotnet_style_null_propagation = true:suggestion |
| 66 | +dotnet_style_explicit_tuple_names = true:suggestion |
| 67 | + |
| 68 | +# Whitespace options |
| 69 | +dotnet_style_allow_multiple_blank_lines_experimental = false |
| 70 | + |
| 71 | +# Non-private static fields are PascalCase |
| 72 | +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion |
| 73 | +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields |
| 74 | +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style |
| 75 | + |
| 76 | +dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field |
| 77 | +dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected |
| 78 | +dotnet_naming_symbols.non_private_static_fields.required_modifiers = static |
| 79 | + |
| 80 | +dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case |
| 81 | + |
| 82 | +# Non-private readonly fields are PascalCase |
| 83 | +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion |
| 84 | +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields |
| 85 | +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style |
| 86 | + |
| 87 | +dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field |
| 88 | +dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected |
| 89 | +dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly |
| 90 | + |
| 91 | +dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case |
| 92 | + |
| 93 | +# Constants are PascalCase |
| 94 | +dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion |
| 95 | +dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants |
| 96 | +dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style |
| 97 | + |
| 98 | +dotnet_naming_symbols.constants.applicable_kinds = field, local |
| 99 | +dotnet_naming_symbols.constants.required_modifiers = const |
| 100 | + |
| 101 | +dotnet_naming_style.constant_style.capitalization = pascal_case |
| 102 | + |
| 103 | +# Static fields are camelCase and start with s_ |
| 104 | +dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion |
| 105 | +dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields |
| 106 | +dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style |
| 107 | + |
| 108 | +dotnet_naming_symbols.static_fields.applicable_kinds = field |
| 109 | +dotnet_naming_symbols.static_fields.required_modifiers = static |
| 110 | + |
| 111 | +dotnet_naming_style.static_field_style.capitalization = camel_case |
| 112 | +dotnet_naming_style.static_field_style.required_prefix = s_ |
| 113 | + |
| 114 | +# Instance fields are camelCase and start with _ |
| 115 | +dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion |
| 116 | +dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields |
| 117 | +dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style |
| 118 | + |
| 119 | +dotnet_naming_symbols.instance_fields.applicable_kinds = field |
| 120 | + |
| 121 | +dotnet_naming_style.instance_field_style.capitalization = camel_case |
| 122 | +dotnet_naming_style.instance_field_style.required_prefix = _ |
| 123 | + |
| 124 | +# Locals and parameters are camelCase |
| 125 | +dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion |
| 126 | +dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters |
| 127 | +dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style |
| 128 | + |
| 129 | +dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local |
| 130 | + |
| 131 | +dotnet_naming_style.camel_case_style.capitalization = camel_case |
| 132 | + |
| 133 | +# Local functions are PascalCase |
| 134 | +dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion |
| 135 | +dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions |
| 136 | +dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style |
| 137 | + |
| 138 | +dotnet_naming_symbols.local_functions.applicable_kinds = local_function |
| 139 | + |
| 140 | +dotnet_naming_style.local_function_style.capitalization = pascal_case |
| 141 | + |
| 142 | +# By default, name items with PascalCase |
| 143 | +dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion |
| 144 | +dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members |
| 145 | +dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style |
| 146 | + |
| 147 | +dotnet_naming_symbols.all_members.applicable_kinds = * |
| 148 | + |
| 149 | +dotnet_naming_style.pascal_case_style.capitalization = pascal_case |
| 150 | + |
| 151 | +# error RS2008: Enable analyzer release tracking for the analyzer project containing rule '{0}' |
| 152 | +dotnet_diagnostic.RS2008.severity = none |
| 153 | + |
| 154 | +# IDE0073: File header |
| 155 | +dotnet_diagnostic.IDE0073.severity = warning |
| 156 | +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.\nSee the LICENSE file in the project root for more information. |
| 157 | + |
| 158 | +# IDE0035: Remove unreachable code |
| 159 | +dotnet_diagnostic.IDE0035.severity = warning |
| 160 | + |
| 161 | +# IDE0036: Order modifiers |
| 162 | +dotnet_diagnostic.IDE0036.severity = warning |
| 163 | + |
| 164 | +# IDE0043: Format string contains invalid placeholder |
| 165 | +dotnet_diagnostic.IDE0043.severity = warning |
| 166 | + |
| 167 | +# IDE0044: Make field readonly |
| 168 | +dotnet_diagnostic.IDE0044.severity = warning |
| 169 | + |
| 170 | +# CONSIDER: Are IDE0051 and IDE0052 too noisy to be warnings for IDE editing scenarios? Should they be made build-only warnings? |
| 171 | +# IDE0051: Remove unused private member |
| 172 | +dotnet_diagnostic.IDE0051.severity = warning |
| 173 | + |
| 174 | +# IDE0170: Prefer extended property pattern |
| 175 | +dotnet_diagnostic.IDE0170.severity = warning |
| 176 | + |
| 177 | +# RS0016: Only enable if API files are present |
| 178 | +dotnet_public_api_analyzer.require_api_files = true |
| 179 | + |
| 180 | +# CSharp code style settings: |
| 181 | +[*.cs] |
| 182 | +# Newline settings |
| 183 | +csharp_new_line_before_open_brace = all |
| 184 | +csharp_new_line_before_else = true |
| 185 | +csharp_new_line_before_catch = true |
| 186 | +csharp_new_line_before_finally = true |
| 187 | +csharp_new_line_before_members_in_object_initializers = true |
| 188 | +csharp_new_line_before_members_in_anonymous_types = true |
| 189 | +csharp_new_line_between_query_expression_clauses = true |
| 190 | + |
| 191 | +# Indentation preferences |
| 192 | +csharp_indent_block_contents = true |
| 193 | +csharp_indent_braces = false |
| 194 | +csharp_indent_case_contents = true |
| 195 | +csharp_indent_case_contents_when_block = true |
| 196 | +csharp_indent_switch_labels = true |
| 197 | +csharp_indent_labels = flush_left |
| 198 | + |
| 199 | +# Whitespace options |
| 200 | +csharp_style_allow_embedded_statements_on_same_line_experimental = false |
| 201 | +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false |
| 202 | +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false |
| 203 | + |
| 204 | +# Prefer "var" everywhere |
| 205 | +csharp_style_var_for_built_in_types = true:suggestion |
| 206 | +csharp_style_var_when_type_is_apparent = true:suggestion |
| 207 | +csharp_style_var_elsewhere = true:suggestion |
| 208 | + |
| 209 | +# Prefer method-like constructs to have a block body |
| 210 | +csharp_style_expression_bodied_methods = false:none |
| 211 | +csharp_style_expression_bodied_constructors = false:none |
| 212 | +csharp_style_expression_bodied_operators = false:none |
| 213 | + |
| 214 | +# Prefer property-like constructs to have an expression-body |
| 215 | +csharp_style_expression_bodied_properties = true:none |
| 216 | +csharp_style_expression_bodied_indexers = true:none |
| 217 | +csharp_style_expression_bodied_accessors = true:none |
| 218 | + |
| 219 | +# Suggest more modern language features when available |
| 220 | +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion |
| 221 | +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion |
| 222 | +csharp_style_inlined_variable_declaration = true:suggestion |
| 223 | +csharp_style_throw_expression = true:suggestion |
| 224 | +csharp_style_conditional_delegate_call = true:suggestion |
| 225 | +csharp_style_prefer_extended_property_pattern = true:suggestion |
| 226 | + |
| 227 | +# Space preferences |
| 228 | +csharp_space_after_cast = false |
| 229 | +csharp_space_after_colon_in_inheritance_clause = true |
| 230 | +csharp_space_after_comma = true |
| 231 | +csharp_space_after_dot = false |
| 232 | +csharp_space_after_keywords_in_control_flow_statements = true |
| 233 | +csharp_space_after_semicolon_in_for_statement = true |
| 234 | +csharp_space_around_binary_operators = before_and_after |
| 235 | +csharp_space_around_declaration_statements = do_not_ignore |
| 236 | +csharp_space_before_colon_in_inheritance_clause = true |
| 237 | +csharp_space_before_comma = false |
| 238 | +csharp_space_before_dot = false |
| 239 | +csharp_space_before_open_square_brackets = false |
| 240 | +csharp_space_before_semicolon_in_for_statement = false |
| 241 | +csharp_space_between_empty_square_brackets = false |
| 242 | +csharp_space_between_method_call_empty_parameter_list_parentheses = false |
| 243 | +csharp_space_between_method_call_name_and_opening_parenthesis = false |
| 244 | +csharp_space_between_method_call_parameter_list_parentheses = false |
| 245 | +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false |
| 246 | +csharp_space_between_method_declaration_name_and_open_parenthesis = false |
| 247 | +csharp_space_between_method_declaration_parameter_list_parentheses = false |
| 248 | +csharp_space_between_parentheses = false |
| 249 | +csharp_space_between_square_brackets = false |
| 250 | + |
| 251 | +# Blocks are allowed |
| 252 | +csharp_prefer_braces = true:silent |
| 253 | +csharp_preserve_single_line_blocks = true |
| 254 | +csharp_preserve_single_line_statements = true |
| 255 | + |
| 256 | +[src/{Analyzers,CodeStyle,Features,Workspaces,EditorFeatures,VisualStudio}/**/*.{cs,vb}] |
| 257 | + |
| 258 | +# IDE0011: Add braces |
| 259 | +csharp_prefer_braces = when_multiline:warning |
| 260 | +# NOTE: We need the below severity entry for Add Braces due to https://github.com/dotnet/roslyn/issues/44201 |
| 261 | +dotnet_diagnostic.IDE0011.severity = warning |
| 262 | + |
| 263 | +# IDE0040: Add accessibility modifiers |
| 264 | +dotnet_diagnostic.IDE0040.severity = warning |
| 265 | + |
| 266 | +# IDE0052: Remove unread private member |
| 267 | +dotnet_diagnostic.IDE0052.severity = warning |
| 268 | + |
| 269 | +# IDE0059: Unnecessary assignment to a value |
| 270 | +dotnet_diagnostic.IDE0059.severity = warning |
| 271 | + |
| 272 | +# IDE0060: Remove unused parameter |
| 273 | +dotnet_diagnostic.IDE0060.severity = warning |
| 274 | + |
| 275 | +# CA1012: Abstract types should not have public constructors |
| 276 | +dotnet_diagnostic.CA1012.severity = warning |
| 277 | + |
| 278 | +# CA1822: Make member static |
| 279 | +dotnet_diagnostic.CA1822.severity = warning |
| 280 | + |
| 281 | +# Prefer "var" everywhere |
| 282 | +dotnet_diagnostic.IDE0007.severity = warning |
| 283 | +csharp_style_var_for_built_in_types = true:warning |
| 284 | +csharp_style_var_when_type_is_apparent = true:warning |
| 285 | +csharp_style_var_elsewhere = true:warning |
| 286 | + |
| 287 | +# dotnet_style_allow_multiple_blank_lines_experimental |
| 288 | +dotnet_diagnostic.IDE2000.severity = warning |
| 289 | + |
| 290 | +# csharp_style_allow_embedded_statements_on_same_line_experimental |
| 291 | +dotnet_diagnostic.IDE2001.severity = warning |
| 292 | + |
| 293 | +# csharp_style_allow_blank_lines_between_consecutive_braces_experimental |
| 294 | +dotnet_diagnostic.IDE2002.severity = warning |
| 295 | + |
| 296 | +# dotnet_style_allow_statement_immediately_after_block_experimental |
| 297 | +dotnet_diagnostic.IDE2003.severity = warning |
| 298 | + |
| 299 | +# csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental |
| 300 | +dotnet_diagnostic.IDE2004.severity = warning |
| 301 | + |
| 302 | +[src/{VisualStudio}/**/*.{cs,vb}] |
| 303 | +# CA1822: Make member static |
| 304 | +# There is a risk of accidentally breaking an internal API that partners rely on though IVT. |
| 305 | +dotnet_code_quality.CA1822.api_surface = private |
0 commit comments