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