|
| 1 | +# EditorConfig is awesome: https://EditorConfig.org |
| 2 | + |
| 3 | +# top-most EditorConfig file |
| 4 | +root = true |
| 5 | + |
| 6 | +# All files |
| 7 | +[*] |
| 8 | +charset = utf-8 |
| 9 | +indent_style = space |
| 10 | +indent_size = 4 |
| 11 | +insert_final_newline = true |
| 12 | +trim_trailing_whitespace = true |
| 13 | + |
| 14 | +# XML project files |
| 15 | +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] |
| 16 | +indent_size = 2 |
| 17 | + |
| 18 | +# XML config files |
| 19 | +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] |
| 20 | +indent_size = 2 |
| 21 | + |
| 22 | +# JSON files |
| 23 | +[*.json] |
| 24 | +indent_size = 2 |
| 25 | + |
| 26 | +# YAML files |
| 27 | +[*.{yml,yaml}] |
| 28 | +indent_size = 2 |
| 29 | + |
| 30 | +# Markdown files |
| 31 | +[*.md] |
| 32 | +trim_trailing_whitespace = false |
| 33 | + |
| 34 | +# C# files |
| 35 | +[*.cs] |
| 36 | + |
| 37 | +# New line preferences |
| 38 | +end_of_line = crlf |
| 39 | +insert_final_newline = true |
| 40 | + |
| 41 | +# Indentation preferences |
| 42 | +indent_size = 4 |
| 43 | +tab_width = 4 |
| 44 | + |
| 45 | +# Organize usings |
| 46 | +dotnet_sort_system_directives_first = true |
| 47 | +dotnet_separate_import_directive_groups = false |
| 48 | + |
| 49 | +# this. preferences |
| 50 | +dotnet_style_qualification_for_field = false:warning |
| 51 | +dotnet_style_qualification_for_property = false:warning |
| 52 | +dotnet_style_qualification_for_method = false:warning |
| 53 | +dotnet_style_qualification_for_event = false:warning |
| 54 | + |
| 55 | +# Language keywords vs BCL types preferences |
| 56 | +dotnet_style_predefined_type_for_locals_parameters_members = true:warning |
| 57 | +dotnet_style_predefined_type_for_member_access = true:warning |
| 58 | + |
| 59 | +# Modifier preferences |
| 60 | +dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning |
| 61 | +dotnet_style_readonly_field = true:suggestion |
| 62 | +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion |
| 63 | + |
| 64 | +# Expression-level preferences |
| 65 | +dotnet_style_object_initializer = true:suggestion |
| 66 | +dotnet_style_collection_initializer = true:suggestion |
| 67 | +dotnet_style_explicit_tuple_names = true:suggestion |
| 68 | +dotnet_style_prefer_inferred_tuple_names = true:suggestion |
| 69 | +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion |
| 70 | +dotnet_style_prefer_auto_properties = true:suggestion |
| 71 | +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion |
| 72 | +dotnet_style_prefer_conditional_expression_over_assignment = true:silent |
| 73 | +dotnet_style_prefer_conditional_expression_over_return = true:silent |
| 74 | + |
| 75 | +# Null-checking preferences |
| 76 | +dotnet_style_coalesce_expression = true:suggestion |
| 77 | +dotnet_style_null_propagation = true:suggestion |
| 78 | + |
| 79 | +# C# Code Style Rules |
| 80 | + |
| 81 | +# var preferences |
| 82 | +csharp_style_var_for_built_in_types = true:suggestion |
| 83 | +csharp_style_var_when_type_is_apparent = true:suggestion |
| 84 | +csharp_style_var_elsewhere = true:suggestion |
| 85 | + |
| 86 | +# Expression-bodied members |
| 87 | +csharp_style_expression_bodied_methods = when_on_single_line:suggestion |
| 88 | +csharp_style_expression_bodied_constructors = false:silent |
| 89 | +csharp_style_expression_bodied_operators = when_on_single_line:suggestion |
| 90 | +csharp_style_expression_bodied_properties = when_on_single_line:suggestion |
| 91 | +csharp_style_expression_bodied_indexers = when_on_single_line:suggestion |
| 92 | +csharp_style_expression_bodied_accessors = when_on_single_line:suggestion |
| 93 | +csharp_style_expression_bodied_lambdas = when_on_single_line:suggestion |
| 94 | +csharp_style_expression_bodied_local_functions = when_on_single_line:suggestion |
| 95 | + |
| 96 | +# Pattern matching |
| 97 | +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion |
| 98 | +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion |
| 99 | +csharp_style_prefer_switch_expression = true:suggestion |
| 100 | +csharp_style_prefer_pattern_matching = true:suggestion |
| 101 | +csharp_style_prefer_not_pattern = true:suggestion |
| 102 | + |
| 103 | +# Inlined variable declarations |
| 104 | +csharp_style_inlined_variable_declaration = true:suggestion |
| 105 | + |
| 106 | +# Expression preferences |
| 107 | +csharp_prefer_simple_default_expression = true:suggestion |
| 108 | + |
| 109 | +# Null checking preferences |
| 110 | +csharp_style_throw_expression = true:suggestion |
| 111 | +csharp_style_conditional_delegate_call = true:suggestion |
| 112 | + |
| 113 | +# Code block preferences |
| 114 | +csharp_prefer_braces = true:warning |
| 115 | + |
| 116 | +# File scoped namespaces |
| 117 | +csharp_style_namespace_declarations = file_scoped:warning |
| 118 | + |
| 119 | +# Using directive preferences |
| 120 | +csharp_using_directive_placement = outside_namespace:warning |
| 121 | + |
| 122 | +# Formatting Rules |
| 123 | + |
| 124 | +# New line preferences |
| 125 | +csharp_new_line_before_open_brace = all |
| 126 | +csharp_new_line_before_else = true |
| 127 | +csharp_new_line_before_catch = true |
| 128 | +csharp_new_line_before_finally = true |
| 129 | +csharp_new_line_before_members_in_object_initializers = true |
| 130 | +csharp_new_line_before_members_in_anonymous_types = true |
| 131 | +csharp_new_line_between_query_expression_clauses = true |
| 132 | + |
| 133 | +# Indentation preferences |
| 134 | +csharp_indent_case_contents = true |
| 135 | +csharp_indent_switch_labels = true |
| 136 | +csharp_indent_labels = no_change |
| 137 | + |
| 138 | +# Space preferences |
| 139 | +csharp_space_after_cast = false |
| 140 | +csharp_space_after_keywords_in_control_flow_statements = true |
| 141 | +csharp_space_between_method_declaration_parameter_list_parentheses = false |
| 142 | +csharp_space_between_method_call_parameter_list_parentheses = false |
| 143 | +csharp_space_between_parentheses = false |
| 144 | +csharp_space_before_colon_in_inheritance_clause = true |
| 145 | +csharp_space_after_colon_in_inheritance_clause = true |
| 146 | +csharp_space_around_binary_operators = before_and_after |
| 147 | +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false |
| 148 | +csharp_space_between_method_call_name_and_opening_parenthesis = false |
| 149 | +csharp_space_between_method_call_empty_parameter_list_parentheses = false |
| 150 | + |
| 151 | +# Wrapping preferences |
| 152 | +csharp_preserve_single_line_statements = false |
| 153 | +csharp_preserve_single_line_blocks = true |
| 154 | + |
| 155 | +# Naming Conventions |
| 156 | + |
| 157 | +# Constant fields are PascalCase |
| 158 | +dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion |
| 159 | +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields |
| 160 | +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style |
| 161 | +dotnet_naming_symbols.constant_fields.applicable_kinds = field |
| 162 | +dotnet_naming_symbols.constant_fields.applicable_accessibilities = * |
| 163 | +dotnet_naming_symbols.constant_fields.required_modifiers = const |
| 164 | + |
| 165 | +# Private fields are _camelCase |
| 166 | +dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore.severity = suggestion |
| 167 | +dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore.symbols = private_fields |
| 168 | +dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore.style = camel_case_underscore_style |
| 169 | +dotnet_naming_symbols.private_fields.applicable_kinds = field |
| 170 | +dotnet_naming_symbols.private_fields.applicable_accessibilities = private |
| 171 | + |
| 172 | +# Public members are PascalCase |
| 173 | +dotnet_naming_rule.public_members_should_be_pascal_case.severity = suggestion |
| 174 | +dotnet_naming_rule.public_members_should_be_pascal_case.symbols = public_symbols |
| 175 | +dotnet_naming_rule.public_members_should_be_pascal_case.style = pascal_case_style |
| 176 | +dotnet_naming_symbols.public_symbols.applicable_kinds = property,method,field,event,delegate |
| 177 | +dotnet_naming_symbols.public_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected |
| 178 | + |
| 179 | +# Interfaces must be IPascalCase |
| 180 | +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion |
| 181 | +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface |
| 182 | +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i |
| 183 | +dotnet_naming_symbols.interface.applicable_kinds = interface |
| 184 | +dotnet_naming_style.begins_with_i.required_prefix = I |
| 185 | +dotnet_naming_style.begins_with_i.capitalization = pascal_case |
| 186 | + |
| 187 | +# Naming styles |
| 188 | +dotnet_naming_style.pascal_case_style.capitalization = pascal_case |
| 189 | +dotnet_naming_style.camel_case_underscore_style.required_prefix = _ |
| 190 | +dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case |
0 commit comments