|
| 1 | +# EditorConfig is awesome: http://EditorConfig.org |
| 2 | + |
| 3 | +# Create portable, custom editor settings with EditorConfig |
| 4 | +# https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options |
| 5 | + |
| 6 | +# .NET coding convention settings for EditorConfig |
| 7 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2019 |
| 8 | + |
| 9 | +# Language conventions |
| 10 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019 |
| 11 | + |
| 12 | +# Formatting conventions |
| 13 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019 |
| 14 | + |
| 15 | +# .NET naming conventions for EditorConfig |
| 16 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019 |
| 17 | + |
| 18 | +# Top-most EditorConfig file |
| 19 | +root = true |
| 20 | + |
| 21 | +# Editor default newlines with a newline ending every file |
| 22 | +[*] |
| 23 | +insert_final_newline = true |
| 24 | +charset = utf-8 |
| 25 | +indent_style = space |
| 26 | +indent_size = 2 |
| 27 | +trim_trailing_whitespace = true |
| 28 | + |
| 29 | +[*.json] |
| 30 | +insert_final_newline = false |
| 31 | + |
| 32 | +[*.cs] |
| 33 | +indent_size = 4 |
| 34 | + |
| 35 | +# Do not insert newline for ApiApprovalTests |
| 36 | +[*.txt] |
| 37 | +insert_final_newline = false |
| 38 | + |
| 39 | +# Code files |
| 40 | +[*.{cs,vb}] |
| 41 | + |
| 42 | +# .NET code style settings - "This." and "Me." qualifiers |
| 43 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#this-and-me |
| 44 | +dotnet_style_qualification_for_field = false:warning |
| 45 | +dotnet_style_qualification_for_property = false:warning |
| 46 | +dotnet_style_qualification_for_method = false:warning |
| 47 | +dotnet_style_qualification_for_event = false:warning |
| 48 | + |
| 49 | +# .NET code style settings - Language keywords instead of framework type names for type references |
| 50 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#language-keywords |
| 51 | +dotnet_style_predefined_type_for_locals_parameters_members = true:error |
| 52 | +dotnet_style_predefined_type_for_member_access = true:error |
| 53 | + |
| 54 | +# .NET code style settings - Modifier preferences |
| 55 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#normalize-modifiers |
| 56 | +dotnet_style_require_accessibility_modifiers = always:warning |
| 57 | +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning |
| 58 | +dotnet_style_readonly_field = true:warning |
| 59 | + |
| 60 | +# .NET code style settings - Parentheses preferences |
| 61 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#parentheses-preferences |
| 62 | +dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:suggestion |
| 63 | +dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:suggestion |
| 64 | +dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:suggestion |
| 65 | +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion |
| 66 | + |
| 67 | +# .NET code style settings - Expression-level preferences |
| 68 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#expression-level-preferences |
| 69 | +dotnet_style_object_initializer = true:error |
| 70 | +dotnet_style_collection_initializer = true:error |
| 71 | +dotnet_style_explicit_tuple_names = true:warning |
| 72 | +dotnet_style_prefer_inferred_tuple_names = true:suggestion |
| 73 | +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion |
| 74 | +dotnet_style_prefer_auto_properties = true:warning |
| 75 | +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning |
| 76 | +dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion |
| 77 | +dotnet_style_prefer_conditional_expression_over_return = true:suggestion |
| 78 | +dotnet_style_prefer_compound_assignment = true:warning |
| 79 | + |
| 80 | +# .NET code style settings - Null-checking preferences |
| 81 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#null-checking-preferences |
| 82 | +dotnet_style_coalesce_expression = true:warning |
| 83 | +dotnet_style_null_propagation = true:error |
| 84 | + |
| 85 | +# .NET code quality settings - Parameter preferences |
| 86 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#parameter-preferences |
| 87 | +dotnet_code_quality_unused_parameters = all:warning |
| 88 | + |
| 89 | +# C# code style settings - Implicit and explicit types |
| 90 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#implicit-and-explicit-types |
| 91 | +csharp_style_var_for_built_in_types = false:suggestion |
| 92 | +csharp_style_var_when_type_is_apparent = true:warning |
| 93 | +csharp_style_var_elsewhere = true:suggestion |
| 94 | + |
| 95 | +# C# code style settings - Expression-bodied members |
| 96 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#expression-bodied-members |
| 97 | +csharp_style_expression_bodied_methods = when_on_single_line:suggestion |
| 98 | +csharp_style_expression_bodied_constructors = false:warning |
| 99 | +csharp_style_expression_bodied_operators = when_on_single_line:warning |
| 100 | +csharp_style_expression_bodied_properties = when_on_single_line:warning |
| 101 | +csharp_style_expression_bodied_indexers = when_on_single_line:warning |
| 102 | +csharp_style_expression_bodied_accessors = when_on_single_line:warning |
| 103 | +csharp_style_expression_bodied_lambdas = when_on_single_line:warning |
| 104 | +csharp_style_expression_bodied_local_functions = when_on_single_line:warning |
| 105 | + |
| 106 | +# C# code style settings - Pattern matching |
| 107 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#pattern-matching |
| 108 | +csharp_style_pattern_matching_over_is_with_cast_check = true:error |
| 109 | +csharp_style_pattern_matching_over_as_with_null_check = true:error |
| 110 | + |
| 111 | +# C# code style settings - Inlined variable declaration |
| 112 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#inlined-variable-declarations |
| 113 | +csharp_style_inlined_variable_declaration = true:error |
| 114 | + |
| 115 | +# C# code style settings - C# expression-level preferences |
| 116 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#c-expression-level-preferences |
| 117 | +csharp_prefer_simple_default_expression = true:suggestion |
| 118 | + |
| 119 | +# C# code style settings - C# null-checking preferences |
| 120 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#c-null-checking-preferences |
| 121 | +csharp_style_throw_expression = true:warning |
| 122 | +csharp_style_conditional_delegate_call = true:warning |
| 123 | + |
| 124 | +# C# code style settings - Code block preferences |
| 125 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#code-block-preferences |
| 126 | +csharp_prefer_braces = when_multiline:suggestion |
| 127 | + |
| 128 | +# C# code style - Unused value preferences |
| 129 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#unused-value-preferences |
| 130 | +csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion |
| 131 | +csharp_style_unused_value_assignment_preference = discard_variable:suggestion |
| 132 | + |
| 133 | +# C# code style - Index and range preferences |
| 134 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#index-and-range-preferences |
| 135 | +csharp_style_prefer_index_operator = true:warning |
| 136 | +csharp_style_prefer_range_operator = true:warning |
| 137 | + |
| 138 | +# C# code style - Miscellaneous preferences |
| 139 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#miscellaneous-preferences |
| 140 | +csharp_style_deconstructed_variable_declaration = true:suggestion |
| 141 | +csharp_style_pattern_local_over_anonymous_function = true:suggestion |
| 142 | +csharp_using_directive_placement = outside_namespace:warning |
| 143 | +csharp_prefer_static_local_function = true:suggestion |
| 144 | +csharp_prefer_simple_using_statement = false:suggestion |
| 145 | +csharp_style_prefer_switch_expression = true:suggestion |
| 146 | + |
| 147 | +# .NET formatting settings - Organize using directives |
| 148 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019#organize-using-directives |
| 149 | +dotnet_sort_system_directives_first = true |
| 150 | +dotnet_separate_import_directive_groups = false |
| 151 | + |
| 152 | +# C# formatting settings - New-line options |
| 153 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019#new-line-options |
| 154 | +csharp_new_line_before_open_brace = all |
| 155 | +csharp_new_line_before_else = true |
| 156 | +csharp_new_line_before_catch = true |
| 157 | +csharp_new_line_before_finally = true |
| 158 | +csharp_new_line_before_members_in_object_initializers = true |
| 159 | +csharp_new_line_before_members_in_anonymous_types = true |
| 160 | +csharp_new_line_between_query_expression_clauses = true |
| 161 | + |
| 162 | +# C# formatting settings - Indentation options |
| 163 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019#indentation-options |
| 164 | +csharp_indent_case_contents = true |
| 165 | +csharp_indent_switch_labels = true |
| 166 | +csharp_indent_labels = one_less_than_current |
| 167 | +csharp_indent_block_contents = true |
| 168 | +csharp_indent_braces = false |
| 169 | +csharp_indent_case_contents_when_block = false |
| 170 | + |
| 171 | +# C# formatting settings - Spacing options |
| 172 | +csharp_space_after_cast = false |
| 173 | +csharp_space_after_keywords_in_control_flow_statements = true |
| 174 | +csharp_space_between_parentheses = false |
| 175 | +csharp_space_before_colon_in_inheritance_clause = true |
| 176 | +csharp_space_after_colon_in_inheritance_clause = true |
| 177 | +csharp_space_around_binary_operators = before_and_after |
| 178 | +csharp_space_between_method_declaration_parameter_list_parentheses = false |
| 179 | +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false |
| 180 | +csharp_space_between_method_declaration_name_and_open_parenthesis = false |
| 181 | +csharp_space_between_method_call_parameter_list_parentheses = false |
| 182 | +csharp_space_between_method_call_empty_parameter_list_parentheses = false |
| 183 | +csharp_space_between_method_call_name_and_opening_parenthesis = false |
| 184 | +csharp_space_after_comma = true |
| 185 | +csharp_space_before_comma = false |
| 186 | +csharp_space_after_dot = false |
| 187 | +csharp_space_before_dot = false |
| 188 | +csharp_space_after_semicolon_in_for_statement = true |
| 189 | +csharp_space_before_semicolon_in_for_statement = false |
| 190 | +csharp_space_around_declaration_statements = false |
| 191 | +csharp_space_before_open_square_brackets = false |
| 192 | +csharp_space_between_empty_square_brackets = false |
| 193 | +csharp_space_between_square_brackets = false |
| 194 | + |
| 195 | +# C# formatting settings - Wrap options |
| 196 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019#wrap-options |
| 197 | +csharp_preserve_single_line_blocks = true |
| 198 | +csharp_preserve_single_line_statements = false |
| 199 | + |
| 200 | +# C# formatting settings - Namespace options |
| 201 | +csharp_style_namespace_declarations = file_scoped:suggestion |
| 202 | + |
| 203 | +########## name all private fields using camelCase with underscore prefix ########## |
| 204 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019 |
| 205 | +# dotnet_naming_rule.<namingRuleTitle>.symbols = <symbolTitle> |
| 206 | +dotnet_naming_rule.private_fields_with_underscore.symbols = private_fields |
| 207 | + |
| 208 | +# dotnet_naming_symbols.<symbolTitle>.<property> = <value> |
| 209 | +dotnet_naming_symbols.private_fields.applicable_kinds = field |
| 210 | +dotnet_naming_symbols.private_fields.applicable_accessibilities = private |
| 211 | + |
| 212 | +# dotnet_naming_rule.<namingRuleTitle>.style = <styleTitle> |
| 213 | +dotnet_naming_rule.private_fields_with_underscore.style = prefix_underscore |
| 214 | + |
| 215 | +# dotnet_naming_style.<styleTitle>.<property> = <value> |
| 216 | +dotnet_naming_style.prefix_underscore.capitalization = camel_case |
| 217 | +dotnet_naming_style.prefix_underscore.required_prefix = _ |
| 218 | + |
| 219 | +# dotnet_naming_rule.<namingRuleTitle>.severity = <value> |
| 220 | +dotnet_naming_rule.private_fields_with_underscore.severity = warning |
| 221 | + |
| 222 | +########## name all constant fields using UPPER_CASE ########## |
| 223 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019 |
| 224 | +# dotnet_naming_rule.<namingRuleTitle>.symbols = <symbolTitle> |
| 225 | +dotnet_naming_rule.constant_fields_should_be_upper_case.symbols = constant_fields |
| 226 | + |
| 227 | +# dotnet_naming_symbols.<symbolTitle>.<property> = <value> |
| 228 | +dotnet_naming_symbols.constant_fields.applicable_kinds = field |
| 229 | +dotnet_naming_symbols.constant_fields.applicable_accessibilities = * |
| 230 | +dotnet_naming_symbols.constant_fields.required_modifiers = const |
| 231 | + |
| 232 | +# dotnet_naming_rule.<namingRuleTitle>.style = <styleTitle> |
| 233 | +dotnet_naming_rule.constant_fields_should_be_upper_case.style = upper_case_style |
| 234 | + |
| 235 | +# dotnet_naming_style.<styleTitle>.<property> = <value> |
| 236 | +dotnet_naming_style.upper_case_style.capitalization = all_upper |
| 237 | +dotnet_naming_style.upper_case_style.word_separator = _ |
| 238 | + |
| 239 | +# dotnet_naming_rule.<namingRuleTitle>.severity = <value> |
| 240 | +dotnet_naming_rule.constant_fields_should_be_upper_case.severity = warning |
| 241 | + |
| 242 | +########## Async methods should have "Async" suffix ########## |
| 243 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019 |
| 244 | +# dotnet_naming_rule.<namingRuleTitle>.symbols = <symbolTitle> |
| 245 | +dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods |
| 246 | + |
| 247 | +# dotnet_naming_symbols.<symbolTitle>.<property> = <value> |
| 248 | +dotnet_naming_symbols.any_async_methods.applicable_kinds = method |
| 249 | +dotnet_naming_symbols.any_async_methods.applicable_accessibilities = * |
| 250 | +dotnet_naming_symbols.any_async_methods.required_modifiers = async |
| 251 | + |
| 252 | +# dotnet_naming_rule.<namingRuleTitle>.style = <styleTitle> |
| 253 | +dotnet_naming_rule.async_methods_end_in_async.style = end_in_async_style |
| 254 | + |
| 255 | +# dotnet_naming_style.<styleTitle>.<property> = <value> |
| 256 | +dotnet_naming_style.end_in_async_style.capitalization = pascal_case |
| 257 | +dotnet_naming_style.end_in_async_style.word_separator = |
| 258 | +dotnet_naming_style.end_in_async_style.required_prefix = |
| 259 | +dotnet_naming_style.end_in_async_style.required_suffix = Async |
| 260 | + |
| 261 | +# dotnet_naming_rule.<namingRuleTitle>.severity = <value> |
| 262 | +dotnet_naming_rule.async_methods_end_in_async.severity = warning |
| 263 | + |
| 264 | +# Remove unnecessary import https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0005 |
| 265 | +dotnet_diagnostic.IDE0005.severity = warning |
0 commit comments