|
| 1 | +# Based on dotnet/roslyn with modifications https://github.com/dotnet/roslyn/blob/main/.editorconfig |
| 2 | + |
| 3 | +# EditorConfig is awesome: https://EditorConfig.org |
| 4 | + |
| 5 | +# top-most EditorConfig file |
| 6 | +root = true |
| 7 | + |
| 8 | +# Default settings: |
| 9 | +# A newline ending every file |
| 10 | +# Use 4 spaces as indentation |
| 11 | +[*] |
| 12 | +indent_style = space |
| 13 | +insert_final_newline = true |
| 14 | +trim_trailing_whitespace = true |
| 15 | + |
| 16 | +# Code files |
| 17 | +[*.{cs,csx,vb,vbx}] |
| 18 | +indent_size = 4 |
| 19 | +insert_final_newline = true |
| 20 | +charset = utf-8-bom |
| 21 | + |
| 22 | +# XML project files |
| 23 | +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] |
| 24 | +indent_size = 2 |
| 25 | + |
| 26 | +# XML config files |
| 27 | +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] |
| 28 | +indent_size = 2 |
| 29 | + |
| 30 | +# JSON files |
| 31 | +[*.json] |
| 32 | +indent_size = 2 |
| 33 | + |
| 34 | +# Powershell files |
| 35 | +[*.ps1] |
| 36 | +indent_size = 2 |
| 37 | + |
| 38 | +# Shell script files |
| 39 | +[*.sh] |
| 40 | +end_of_line = lf |
| 41 | +indent_size = 2 |
| 42 | + |
| 43 | +# C# files |
| 44 | +[*.cs] |
| 45 | + |
| 46 | +# Sort using and Import directives with System.* appearing first |
| 47 | +dotnet_sort_system_directives_first = true |
| 48 | +dotnet_separate_import_directive_groups = false |
| 49 | +# Avoid "this." and "Me." if not necessary |
| 50 | +dotnet_style_qualification_for_field = false:refactoring |
| 51 | +dotnet_style_qualification_for_property = false:refactoring |
| 52 | +dotnet_style_qualification_for_method = false:refactoring |
| 53 | +dotnet_style_qualification_for_event = false:refactoring |
| 54 | + |
| 55 | +# Use language keywords instead of framework type names for type references |
| 56 | +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion |
| 57 | +dotnet_style_predefined_type_for_member_access = true:suggestion |
| 58 | + |
| 59 | +# Suggest more modern language features when available |
| 60 | +dotnet_style_object_initializer = true:suggestion |
| 61 | +dotnet_style_collection_initializer = true:suggestion |
| 62 | +dotnet_style_coalesce_expression = true:suggestion |
| 63 | +dotnet_style_null_propagation = true:suggestion |
| 64 | +dotnet_style_explicit_tuple_names = true:suggestion |
| 65 | + |
| 66 | +# Whitespace options |
| 67 | +dotnet_style_allow_multiple_blank_lines_experimental = false |
| 68 | + |
| 69 | +# Non-private static fields are PascalCase |
| 70 | +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion |
| 71 | +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields |
| 72 | +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style |
| 73 | + |
| 74 | +dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field |
| 75 | +dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected |
| 76 | +dotnet_naming_symbols.non_private_static_fields.required_modifiers = static |
| 77 | + |
| 78 | +dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case |
| 79 | + |
| 80 | +# Non-private readonly fields are PascalCase |
| 81 | +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion |
| 82 | +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields |
| 83 | +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style |
| 84 | + |
| 85 | +dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field |
| 86 | +dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected |
| 87 | +dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly |
| 88 | + |
| 89 | +dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case |
| 90 | + |
| 91 | +# Constants are PascalCase |
| 92 | +dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion |
| 93 | +dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants |
| 94 | +dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style |
| 95 | + |
| 96 | +dotnet_naming_symbols.constants.applicable_kinds = field, local |
| 97 | +dotnet_naming_symbols.constants.required_modifiers = const |
| 98 | + |
| 99 | +dotnet_naming_style.constant_style.capitalization = pascal_case |
| 100 | + |
| 101 | +# Static fields are camelCase and start with s_ |
| 102 | +dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion |
| 103 | +dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields |
| 104 | +dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style |
| 105 | + |
| 106 | +dotnet_naming_symbols.static_fields.applicable_kinds = field |
| 107 | +dotnet_naming_symbols.static_fields.required_modifiers = static |
| 108 | + |
| 109 | +dotnet_naming_style.static_field_style.capitalization = camel_case |
| 110 | +dotnet_naming_style.static_field_style.required_prefix = s_ |
| 111 | + |
| 112 | +# Instance fields are camelCase and start with _ |
| 113 | +dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion |
| 114 | +dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields |
| 115 | +dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style |
| 116 | + |
| 117 | +dotnet_naming_symbols.instance_fields.applicable_kinds = field |
| 118 | + |
| 119 | +dotnet_naming_style.instance_field_style.capitalization = camel_case |
| 120 | +dotnet_naming_style.instance_field_style.required_prefix = _ |
| 121 | + |
| 122 | +# Locals and parameters are camelCase |
| 123 | +dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion |
| 124 | +dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters |
| 125 | +dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style |
| 126 | + |
| 127 | +dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local |
| 128 | + |
| 129 | +dotnet_naming_style.camel_case_style.capitalization = camel_case |
| 130 | + |
| 131 | +# Local functions are PascalCase |
| 132 | +dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion |
| 133 | +dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions |
| 134 | +dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style |
| 135 | + |
| 136 | +dotnet_naming_symbols.local_functions.applicable_kinds = local_function |
| 137 | + |
| 138 | +dotnet_naming_style.local_function_style.capitalization = pascal_case |
| 139 | + |
| 140 | +# By default, name items with PascalCase |
| 141 | +dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion |
| 142 | +dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members |
| 143 | +dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style |
| 144 | + |
| 145 | +dotnet_naming_symbols.all_members.applicable_kinds = * |
| 146 | + |
| 147 | +dotnet_naming_style.pascal_case_style.capitalization = pascal_case |
| 148 | + |
| 149 | +# Newline settings |
| 150 | +csharp_new_line_before_open_brace = all |
| 151 | +csharp_new_line_before_else = true |
| 152 | +csharp_new_line_before_catch = true |
| 153 | +csharp_new_line_before_finally = true |
| 154 | +csharp_new_line_before_members_in_object_initializers = true |
| 155 | +csharp_new_line_before_members_in_anonymous_types = true |
| 156 | +csharp_new_line_between_query_expression_clauses = true |
| 157 | + |
| 158 | +# Indentation preferences |
| 159 | +csharp_indent_block_contents = true |
| 160 | +csharp_indent_braces = false |
| 161 | +csharp_indent_case_contents = true |
| 162 | +csharp_indent_case_contents_when_block = true |
| 163 | +csharp_indent_switch_labels = true |
| 164 | +csharp_indent_labels = flush_left |
| 165 | + |
| 166 | +# Whitespace options |
| 167 | +csharp_style_allow_embedded_statements_on_same_line_experimental = false |
| 168 | +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false |
| 169 | +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false |
| 170 | +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false |
| 171 | +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false |
| 172 | + |
| 173 | +# Prefer "var" everywhere |
| 174 | +csharp_style_var_for_built_in_types = true:suggestion |
| 175 | +csharp_style_var_when_type_is_apparent = true:suggestion |
| 176 | +csharp_style_var_elsewhere = true:suggestion |
| 177 | + |
| 178 | +# Prefer method-like constructs to have a block body |
| 179 | +csharp_style_expression_bodied_methods = false:none |
| 180 | +csharp_style_expression_bodied_constructors = false:none |
| 181 | +csharp_style_expression_bodied_operators = false:none |
| 182 | + |
| 183 | +# Prefer property-like constructs to have an expression-body |
| 184 | +csharp_style_expression_bodied_properties = true:none |
| 185 | +csharp_style_expression_bodied_indexers = true:none |
| 186 | +csharp_style_expression_bodied_accessors = true:none |
| 187 | + |
| 188 | +# Suggest more modern language features when available |
| 189 | +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion |
| 190 | +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion |
| 191 | +csharp_style_inlined_variable_declaration = true:suggestion |
| 192 | +csharp_style_throw_expression = true:suggestion |
| 193 | +csharp_style_conditional_delegate_call = true:suggestion |
| 194 | +csharp_style_prefer_extended_property_pattern = true:suggestion |
| 195 | + |
| 196 | +# Space preferences |
| 197 | +csharp_space_after_cast = false |
| 198 | +csharp_space_after_colon_in_inheritance_clause = true |
| 199 | +csharp_space_after_comma = true |
| 200 | +csharp_space_after_dot = false |
| 201 | +csharp_space_after_keywords_in_control_flow_statements = true |
| 202 | +csharp_space_after_semicolon_in_for_statement = true |
| 203 | +csharp_space_around_binary_operators = before_and_after |
| 204 | +csharp_space_around_declaration_statements = do_not_ignore |
| 205 | +csharp_space_before_colon_in_inheritance_clause = true |
| 206 | +csharp_space_before_comma = false |
| 207 | +csharp_space_before_dot = false |
| 208 | +csharp_space_before_open_square_brackets = false |
| 209 | +csharp_space_before_semicolon_in_for_statement = false |
| 210 | +csharp_space_between_empty_square_brackets = false |
| 211 | +csharp_space_between_method_call_empty_parameter_list_parentheses = false |
| 212 | +csharp_space_between_method_call_name_and_opening_parenthesis = false |
| 213 | +csharp_space_between_method_call_parameter_list_parentheses = false |
| 214 | +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false |
| 215 | +csharp_space_between_method_declaration_name_and_open_parenthesis = false |
| 216 | +csharp_space_between_method_declaration_parameter_list_parentheses = false |
| 217 | +csharp_space_between_parentheses = false |
| 218 | +csharp_space_between_square_brackets = false |
| 219 | + |
| 220 | +# Blocks are allowed |
| 221 | +csharp_prefer_braces = true:silent |
| 222 | +csharp_preserve_single_line_blocks = true |
| 223 | +csharp_preserve_single_line_statements = true |
| 224 | + |
| 225 | +########################################## |
| 226 | +# Custom bits |
| 227 | +########################################## |
| 228 | + |
| 229 | +# Always have accessibility keyword |
| 230 | +dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning |
| 231 | + |
| 232 | +# Use file scoped namespaces |
| 233 | +csharp_style_namespace_declarations = file_scoped:warning |
| 234 | + |
| 235 | +# Verify settings |
| 236 | +[*.{received,verified}.{cs,txt}] |
| 237 | +charset = "utf-8-bom" |
| 238 | +end_of_line = lf |
| 239 | +indent_size = unset |
| 240 | +indent_style = unset |
| 241 | +insert_final_newline = false |
| 242 | +tab_width = unset |
| 243 | +trim_trailing_whitespace = false |
0 commit comments