|
| 1 | +# Remove the line below if you want to inherit .editorconfig settings from higher directories |
| 2 | +root = true |
| 3 | + |
| 4 | +[*] |
| 5 | +charset = utf-8 |
| 6 | +max_line_length = 120 |
| 7 | + |
| 8 | +# Markdown Files |
| 9 | +[*.md] |
| 10 | +trim_trailing_whitespace = false |
| 11 | + |
| 12 | +# C# files |
| 13 | +[*.cs] |
| 14 | +# Indentation options |
| 15 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#indent |
| 16 | + |
| 17 | +indent_size = 2 |
| 18 | +indent_style = space |
| 19 | +tab_width = 2 |
| 20 | + |
| 21 | +csharp_indent_case_contents = true |
| 22 | +csharp_indent_block_contents = true |
| 23 | +csharp_indent_braces = false |
| 24 | +csharp_indent_switch_labels = true |
| 25 | +csharp_indent_labels = one_less_than_current |
| 26 | + |
| 27 | +# New line preferences |
| 28 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#c-formatting-settings |
| 29 | + |
| 30 | +csharp_new_line_before_catch = true |
| 31 | +csharp_new_line_before_finally = true |
| 32 | +csharp_new_line_before_else = true |
| 33 | +csharp_new_line_before_members_in_anonymous_types = true |
| 34 | +csharp_new_line_before_members_in_object_initializers = false |
| 35 | +csharp_new_line_before_open_brace = types,methods |
| 36 | +csharp_new_line_between_query_expression_clauses = true |
| 37 | + |
| 38 | +end_of_line = crlf |
| 39 | +insert_final_newline = false |
| 40 | + |
| 41 | +#### .NET Coding Conventions #### |
| 42 | + |
| 43 | +# Organize usings |
| 44 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#usings |
| 45 | +csharp_using_directive_placement = outside_namespace:silent |
| 46 | +dotnet_sort_system_directives_first = true |
| 47 | + |
| 48 | +# Style - qualification options |
| 49 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#this_and_me |
| 50 | +dotnet_style_qualification_for_field = false:suggestion |
| 51 | +dotnet_style_qualification_for_property = false:suggestion |
| 52 | +dotnet_style_qualification_for_method = false:suggestion |
| 53 | +dotnet_style_qualification_for_event = false:suggestion |
| 54 | + |
| 55 | +# Language keywords instead of framework type names for type references |
| 56 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#language_keywords |
| 57 | +dotnet_style_predefined_type_for_locals_parameters_members = true:warning |
| 58 | +dotnet_style_predefined_type_for_member_access = true:warning |
| 59 | + |
| 60 | +# Parentheses preferences |
| 61 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#parentheses |
| 62 | +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion |
| 63 | +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion |
| 64 | +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion |
| 65 | +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion |
| 66 | + |
| 67 | +# Modifier preferences |
| 68 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#normalize_modifiers |
| 69 | +dotnet_style_require_accessibility_modifiers = always:warning |
| 70 | +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion |
| 71 | +dotnet_style_readonly_field = true:warning |
| 72 | +csharp_prefer_static_local_function = true:suggestion |
| 73 | + |
| 74 | +# Expression-level preferences |
| 75 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#expression_level |
| 76 | + |
| 77 | +dotnet_style_object_initializer = true:suggestion |
| 78 | +dotnet_style_collection_initializer = true:suggestion |
| 79 | +dotnet_style_explicit_tuple_names = true:suggestion |
| 80 | +dotnet_style_prefer_inferred_tuple_names = true:suggestion |
| 81 | +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion |
| 82 | +dotnet_style_prefer_auto_properties = true:suggestion |
| 83 | +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion |
| 84 | +dotnet_style_prefer_conditional_expression_over_assignment = false:suggestion |
| 85 | +dotnet_style_prefer_conditional_expression_over_return = false:suggestion |
| 86 | +csharp_prefer_simple_default_expression = true:suggestion |
| 87 | +csharp_prefer_braces = true:suggestion |
| 88 | +csharp_prefer_simple_using_statement = true:suggestion |
| 89 | + |
| 90 | +# Expression-level preferences |
| 91 | +csharp_style_deconstructed_variable_declaration = true:suggestion |
| 92 | +csharp_style_inlined_variable_declaration = true:suggestion |
| 93 | +csharp_style_pattern_local_over_anonymous_function = true:suggestion |
| 94 | +csharp_style_prefer_index_operator = true:suggestion |
| 95 | +csharp_style_prefer_range_operator = true:suggestion |
| 96 | +csharp_style_unused_value_assignment_preference = discard_variable:suggestion |
| 97 | +csharp_style_unused_value_expression_statement_preference = discard_variable:silent |
| 98 | + |
| 99 | +# Expression-bodied members |
| 100 | +csharp_style_expression_bodied_methods = true:none |
| 101 | +csharp_style_expression_bodied_constructors = false:suggestion |
| 102 | +csharp_style_expression_bodied_operators = true:suggestion |
| 103 | +csharp_style_expression_bodied_properties = true:suggestion |
| 104 | +csharp_style_expression_bodied_indexers = true:suggestion |
| 105 | +csharp_style_expression_bodied_accessors = true:suggestion |
| 106 | + |
| 107 | +# Pattern matching |
| 108 | +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion |
| 109 | +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion |
| 110 | + |
| 111 | +# Parameter preferences |
| 112 | +dotnet_code_quality_unused_parameters = all:suggestion |
| 113 | + |
| 114 | +#### C# Coding Conventions #### |
| 115 | + |
| 116 | +# var preferences |
| 117 | +csharp_style_var_for_built_in_types = true:silent |
| 118 | +csharp_style_var_when_type_is_apparent = true:silent |
| 119 | +csharp_style_var_elsewhere = true:silent |
| 120 | + |
| 121 | +# Null checking preferences |
| 122 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#null_checking |
| 123 | +csharp_style_throw_expression = false:none |
| 124 | +csharp_style_conditional_delegate_call = true:suggestion |
| 125 | + |
| 126 | +#### C# Formatting Rules #### |
| 127 | + |
| 128 | +# Spacing options |
| 129 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#spacing |
| 130 | + |
| 131 | +csharp_space_after_colon_in_inheritance_clause = true |
| 132 | +csharp_space_after_cast = false |
| 133 | +csharp_space_after_comma = true |
| 134 | +csharp_space_after_dot = false |
| 135 | +csharp_space_after_keywords_in_control_flow_statements = true |
| 136 | +csharp_space_before_colon_in_inheritance_clause = true |
| 137 | +csharp_space_between_method_call_empty_parameter_list_parentheses = false |
| 138 | +csharp_space_after_semicolon_in_for_statement = true |
| 139 | +csharp_space_around_binary_operators = before_and_after |
| 140 | +csharp_space_around_declaration_statements = do_not_ignore |
| 141 | +csharp_space_before_comma = false |
| 142 | +csharp_space_before_dot = false |
| 143 | +csharp_space_before_open_square_brackets = false |
| 144 | +csharp_space_before_semicolon_in_for_statement = false |
| 145 | +csharp_space_between_empty_square_brackets = false |
| 146 | +csharp_space_between_method_call_name_and_opening_parenthesis = false |
| 147 | +csharp_space_between_method_call_parameter_list_parentheses = false |
| 148 | +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false |
| 149 | +csharp_space_between_method_declaration_name_and_open_parenthesis = false |
| 150 | +csharp_space_between_method_declaration_parameter_list_parentheses = false |
| 151 | +csharp_space_between_parentheses = false |
| 152 | +csharp_space_between_square_brackets = false |
| 153 | + |
| 154 | +# Wrapping options |
| 155 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#wrapping |
| 156 | + |
| 157 | +csharp_preserve_single_line_blocks = true |
| 158 | +csharp_preserve_single_line_statements = true |
| 159 | + |
| 160 | +#### Naming styles #### |
| 161 | + |
| 162 | +# Naming Conventions |
| 163 | +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions |
| 164 | + |
| 165 | +# Style Definitions |
| 166 | +dotnet_naming_style.pascal_case_style.capitalization = pascal_case |
| 167 | + |
| 168 | +dotnet_naming_style.camel_case_style.capitalization = camel_case |
| 169 | + |
| 170 | +# capital_i_prefix_style - Interfaces must be prefixed with I and be pascal case |
| 171 | +dotnet_naming_style.capital_i_prefix_style.required_prefix = I |
| 172 | +dotnet_naming_style.capital_i_prefix_style.capitalization = pascal_case |
| 173 | + |
| 174 | +# capital_t_prefix_style - Generic Type Parameters must be prefixed with T and be pascal case |
| 175 | +dotnet_naming_style.capital_t_prefix_style.required_prefix = T |
| 176 | +dotnet_naming_style.capital_t_prefix_style.capitalization = pascal_case |
| 177 | + |
| 178 | +dotnet_naming_style.T_prefix_style.required_prefix = T |
| 179 | +dotnet_naming_style.T_prefix_style.capitalization = pascal_case |
| 180 | + |
| 181 | +dotnet_naming_style.underscore_style.required_prefix = _ |
| 182 | +dotnet_naming_style.underscore_style.capitalization = camel_case |
| 183 | + |
| 184 | + |
| 185 | +# Private static must be camelCase |
| 186 | +dotnet_naming_rule.private_naming.severity = suggestion |
| 187 | +dotnet_naming_rule.private_naming.symbols = private_static |
| 188 | +dotnet_naming_rule.private_naming.style = camel_case_style |
| 189 | +dotnet_naming_symbols.private_static.applicable_kinds = property,event,field |
| 190 | +dotnet_naming_symbols.private_static.applicable_accessibilities = private, static |
| 191 | + |
| 192 | +# Use PascalCase for readonly static fields |
| 193 | +dotnet_naming_rule.readonly_fields_should_be_pascal_case.severity = notice |
| 194 | +dotnet_naming_rule.readonly_fields_should_be_pascal_case.symbols = readonly_fields |
| 195 | +dotnet_naming_rule.readonly_fields_should_be_pascal_case.style = pascal_case_style |
| 196 | +dotnet_naming_symbols.readonly_fields.applicable_kinds = field |
| 197 | +dotnet_naming_symbols.readonly_fields.applicable_accessibilities = * |
| 198 | +dotnet_naming_symbols.readonly_fields.required_modifiers = readonly, static |
| 199 | + |
| 200 | +# Use PascalCase for constant fields |
| 201 | +dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion |
| 202 | +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields |
| 203 | +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style |
| 204 | +dotnet_naming_symbols.constant_fields.applicable_kinds = field |
| 205 | +dotnet_naming_symbols.constant_fields.required_modifiers = const |
| 206 | +dotnet_naming_symbols.constant_fields.applicable_accessibilities = * |
| 207 | + |
| 208 | + |
| 209 | +# Use PascalCase for public fields |
| 210 | +dotnet_naming_rule.pascal_case_for_public_fields.severity = warning |
| 211 | +dotnet_naming_rule.pascal_case_for_public_fields.symbols = public_fields |
| 212 | +dotnet_naming_rule.pascal_case_for_public_fields.style = pascal_case_style |
| 213 | +dotnet_naming_symbols.public_fields.applicable_kinds = field |
| 214 | +dotnet_naming_symbols.public_fields.applicable_accessibilities = public |
| 215 | + |
| 216 | +# Classes, structs, methods, enums, events, properties, namespaces, delegates must be PascalCase |
| 217 | +dotnet_naming_rule.general_naming.severity = warning |
| 218 | +dotnet_naming_rule.general_naming.symbols = general |
| 219 | +dotnet_naming_rule.general_naming.style = pascal_case_style |
| 220 | +dotnet_naming_symbols.general.applicable_kinds = class,struct,enum,property,method,event,namespace,delegate |
| 221 | +dotnet_naming_symbols.general.applicable_accessibilities = * |
| 222 | + |
| 223 | +# Interfaces must be PascalCase and have an I prefix |
| 224 | +dotnet_naming_rule.interfaces_start_with_I.severity = warning |
| 225 | +dotnet_naming_rule.interfaces_start_with_I.symbols = any_interface |
| 226 | +dotnet_naming_rule.interfaces_start_with_I.style = capital_i_prefix_style |
| 227 | +dotnet_naming_symbols.any_interface.applicable_kinds = interface |
| 228 | +dotnet_naming_symbols.any_interface.applicable_accessibilities = * |
| 229 | + |
| 230 | +# Generics Type Parameters use PascalCase and are prefixed with uppercase 'T' |
| 231 | +# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces |
| 232 | +dotnet_naming_symbols.type_parameter_group.applicable_kinds = type_parameter |
| 233 | +dotnet_naming_rule.type_parameter_rule.symbols = type_parameter_group |
| 234 | +dotnet_naming_rule.type_parameter_rule.style = capital_t_prefix_style |
| 235 | +dotnet_naming_rule.type_parameter_rule.severity = warning |
| 236 | + |
| 237 | +# Private must be camelCase |
| 238 | +dotnet_naming_rule.private_naming.severity = suggestion |
| 239 | +dotnet_naming_rule.private_naming.symbols = private |
| 240 | +dotnet_naming_rule.private_naming.style = camel_case_style |
| 241 | +dotnet_naming_symbols.private.applicable_kinds = property,event,field |
| 242 | +dotnet_naming_symbols.private.applicable_accessibilities = private |
| 243 | + |
| 244 | +# Internal must be camelCase with underscore |
| 245 | +dotnet_naming_rule.underscore_internal_naming.severity = warning |
| 246 | +dotnet_naming_rule.underscore_internal_naming.symbols = underscore_internal |
| 247 | +dotnet_naming_rule.underscore_internal_naming.style = camel_case_style |
| 248 | +dotnet_naming_symbols.underscore_internal.applicable_kinds = property,event,field |
| 249 | +dotnet_naming_symbols.underscore_internal.applicable_accessibilities = internal |
| 250 | + |
| 251 | +# Type params must be PascalCase with T prefix |
| 252 | +dotnet_naming_rule.T_prefix_naming.severity = warning |
| 253 | +dotnet_naming_rule.T_prefix_naming.symbols = T_prefix |
| 254 | +dotnet_naming_rule.T_prefix_naming.style = T_prefix_style |
| 255 | +dotnet_naming_symbols.T_prefix.applicable_kinds = type_parameter |
| 256 | +dotnet_naming_symbols.T_prefix.applicable_accessibilities = * |
| 257 | + |
| 258 | +# Everything else is camelCase |
| 259 | +#dotnet_naming_rule.everything_else_naming.severity = warning |
| 260 | +#dotnet_naming_rule.everything_else_naming.symbols = everything_else |
| 261 | +#dotnet_naming_rule.everything_else_naming.style = camel_case_style |
| 262 | +#dotnet_naming_symbols.everything_else.applicable_kinds = * |
| 263 | +#dotnet_naming_symbols.everything_else.applicable_accessibilities = * |
0 commit comments