|
| 1 | +# EditorConfig — portfolio house style (.NET) · https://editorconfig.org |
| 2 | +# Curated from the conventions shared across the reference repos (Koine, |
| 3 | +# DotnetChain, MasterCommander): LF, UTF-8, 4-space indent, file-scoped |
| 4 | +# namespaces, Allman braces, sorted usings, _camelCase private fields. |
| 5 | +# Severities are capped at `warning` — this guides the IDE and `dotnet format`, |
| 6 | +# it never fails a build on its own. |
| 7 | +root = true |
| 8 | + |
| 9 | +# --------------------------------------------------------------------------- |
| 10 | +# All files |
| 11 | +# --------------------------------------------------------------------------- |
| 12 | +[*] |
| 13 | +charset = utf-8 |
| 14 | +end_of_line = lf |
| 15 | +insert_final_newline = true |
| 16 | +trim_trailing_whitespace = true |
| 17 | +indent_style = space |
| 18 | +indent_size = 4 |
| 19 | + |
| 20 | +# Data / project / markup files use 2-space indent |
| 21 | +[*.{json,jsonc,yml,yaml,xml,csproj,fsproj,props,targets,slnx,config,razor}] |
| 22 | +indent_size = 2 |
| 23 | + |
| 24 | +[*.{ts,tsx,js,jsx,css,scss,html}] |
| 25 | +indent_size = 2 |
| 26 | + |
| 27 | +[*.md] |
| 28 | +trim_trailing_whitespace = false # trailing two spaces are meaningful line breaks |
| 29 | + |
| 30 | +[Makefile] |
| 31 | +indent_style = tab |
| 32 | + |
| 33 | +# --------------------------------------------------------------------------- |
| 34 | +# C# conventions |
| 35 | +# --------------------------------------------------------------------------- |
| 36 | +[*.cs] |
| 37 | +indent_size = 4 |
| 38 | +max_line_length = 140 |
| 39 | + |
| 40 | +# --- Language / usings --- |
| 41 | +csharp_using_directive_placement = outside_namespace:warning |
| 42 | +dotnet_sort_system_directives_first = true |
| 43 | +dotnet_separate_import_directive_groups = false |
| 44 | +csharp_style_namespace_declarations = file_scoped:warning |
| 45 | + |
| 46 | +# --- this. qualification (never qualify with this.) --- |
| 47 | +dotnet_style_qualification_for_field = false:warning |
| 48 | +dotnet_style_qualification_for_property = false:warning |
| 49 | +dotnet_style_qualification_for_method = false:warning |
| 50 | +dotnet_style_qualification_for_event = false:warning |
| 51 | + |
| 52 | +# --- var / type preferences --- |
| 53 | +csharp_style_var_for_built_in_types = true:suggestion |
| 54 | +csharp_style_var_when_type_is_apparent = true:suggestion |
| 55 | +csharp_style_var_elsewhere = false:suggestion |
| 56 | + |
| 57 | +# --- expression-bodied members --- |
| 58 | +csharp_style_expression_bodied_methods = when_on_single_line:suggestion |
| 59 | +csharp_style_expression_bodied_constructors = false:suggestion |
| 60 | +csharp_style_expression_bodied_operators = when_on_single_line:suggestion |
| 61 | +csharp_style_expression_bodied_properties = true:suggestion |
| 62 | +csharp_style_expression_bodied_accessors = true:suggestion |
| 63 | +csharp_style_expression_bodied_lambdas = true:suggestion |
| 64 | + |
| 65 | +# --- modern C# idioms --- |
| 66 | +csharp_prefer_braces = true:warning # always brace if/else/for/while, even single-statement bodies |
| 67 | +csharp_style_prefer_switch_expression = true:suggestion |
| 68 | +csharp_style_prefer_pattern_matching = true:suggestion |
| 69 | +csharp_style_pattern_matching_over_is_with_cast_check = true:warning |
| 70 | +csharp_style_pattern_matching_over_as_with_null_check = true:warning |
| 71 | +csharp_style_inlined_variable_declaration = true:suggestion |
| 72 | +csharp_style_throw_expression = true:suggestion |
| 73 | +csharp_style_conditional_delegate_call = true:suggestion |
| 74 | +csharp_prefer_simple_using_statement = true:suggestion |
| 75 | +csharp_style_prefer_index_operator = true:suggestion |
| 76 | +csharp_style_prefer_range_operator = true:suggestion |
| 77 | +dotnet_style_object_initializer = true:suggestion |
| 78 | +dotnet_style_collection_initializer = true:suggestion |
| 79 | +dotnet_style_prefer_auto_properties = true:warning |
| 80 | +dotnet_style_null_propagation = true:suggestion |
| 81 | +dotnet_style_coalesce_expression = true:suggestion |
| 82 | +dotnet_style_prefer_conditional_expression_over_assignment = true:silent |
| 83 | +dotnet_style_prefer_conditional_expression_over_return = true:silent |
| 84 | +dotnet_style_readonly_field = true:warning |
| 85 | + |
| 86 | +# --- accessibility & modifiers --- |
| 87 | +dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning |
| 88 | +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:warning |
| 89 | +dotnet_style_predefined_type_for_locals_parameters_members = true:warning |
| 90 | +dotnet_style_predefined_type_for_member_access = true:warning |
| 91 | + |
| 92 | +# --- new-line / brace formatting (Allman) --- |
| 93 | +csharp_new_line_before_open_brace = all |
| 94 | +csharp_new_line_before_else = true |
| 95 | +csharp_new_line_before_catch = true |
| 96 | +csharp_new_line_before_finally = true |
| 97 | +csharp_new_line_before_members_in_object_initializers = true |
| 98 | +csharp_new_line_before_members_in_anonymous_types = true |
| 99 | +csharp_new_line_between_query_expression_clauses = true |
| 100 | + |
| 101 | +# --- indentation / spacing / wrapping --- |
| 102 | +csharp_indent_case_contents = true |
| 103 | +csharp_indent_switch_labels = true |
| 104 | +csharp_indent_labels = one_less_than_current |
| 105 | +csharp_space_after_cast = false |
| 106 | +csharp_space_after_keywords_in_control_flow_statements = true |
| 107 | +csharp_space_between_method_declaration_parameter_list_parentheses = false |
| 108 | +csharp_space_between_method_call_parameter_list_parentheses = false |
| 109 | +csharp_space_around_binary_operators = before_and_after |
| 110 | +csharp_preserve_single_line_blocks = true |
| 111 | +csharp_preserve_single_line_statements = false |
| 112 | + |
| 113 | +# --- unnecessary-code preferences --- |
| 114 | +dotnet_code_quality_unused_parameters = non_public:suggestion |
| 115 | +csharp_style_unused_value_assignment_preference = discard_variable:suggestion |
| 116 | +csharp_style_unused_value_expression_statement_preference = discard_variable:silent |
| 117 | + |
| 118 | +# --------------------------------------------------------------------------- |
| 119 | +# Naming conventions |
| 120 | +# --------------------------------------------------------------------------- |
| 121 | +# Types & namespaces: PascalCase |
| 122 | +dotnet_naming_rule.types_pascal.severity = warning |
| 123 | +dotnet_naming_rule.types_pascal.symbols = types_and_namespaces |
| 124 | +dotnet_naming_rule.types_pascal.style = pascal_case |
| 125 | +dotnet_naming_symbols.types_and_namespaces.applicable_kinds = namespace,class,struct,interface,enum,delegate |
| 126 | +dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = * |
| 127 | + |
| 128 | +# Interfaces: IPascalCase |
| 129 | +dotnet_naming_rule.interfaces_i_prefix.severity = warning |
| 130 | +dotnet_naming_rule.interfaces_i_prefix.symbols = interfaces |
| 131 | +dotnet_naming_rule.interfaces_i_prefix.style = i_pascal_case |
| 132 | +dotnet_naming_symbols.interfaces.applicable_kinds = interface |
| 133 | +dotnet_naming_style.i_pascal_case.required_prefix = I |
| 134 | +dotnet_naming_style.i_pascal_case.capitalization = pascal_case |
| 135 | + |
| 136 | +# Type parameters: TPascalCase |
| 137 | +dotnet_naming_rule.type_params_t_prefix.severity = warning |
| 138 | +dotnet_naming_rule.type_params_t_prefix.symbols = type_parameters |
| 139 | +dotnet_naming_rule.type_params_t_prefix.style = t_pascal_case |
| 140 | +dotnet_naming_symbols.type_parameters.applicable_kinds = type_parameter |
| 141 | +dotnet_naming_style.t_pascal_case.required_prefix = T |
| 142 | +dotnet_naming_style.t_pascal_case.capitalization = pascal_case |
| 143 | + |
| 144 | +# Public members: PascalCase |
| 145 | +dotnet_naming_rule.public_members_pascal.severity = warning |
| 146 | +dotnet_naming_rule.public_members_pascal.symbols = public_members |
| 147 | +dotnet_naming_rule.public_members_pascal.style = pascal_case |
| 148 | +dotnet_naming_symbols.public_members.applicable_kinds = property,method,field,event |
| 149 | +dotnet_naming_symbols.public_members.applicable_accessibilities = public,internal,protected,protected_internal |
| 150 | + |
| 151 | +# Constants: PascalCase |
| 152 | +dotnet_naming_rule.constants_pascal.severity = warning |
| 153 | +dotnet_naming_rule.constants_pascal.symbols = constants |
| 154 | +dotnet_naming_rule.constants_pascal.style = pascal_case |
| 155 | +dotnet_naming_symbols.constants.applicable_kinds = field |
| 156 | +dotnet_naming_symbols.constants.required_modifiers = const |
| 157 | + |
| 158 | +# Private/internal instance fields: _camelCase |
| 159 | +dotnet_naming_rule.private_fields_underscore.severity = warning |
| 160 | +dotnet_naming_rule.private_fields_underscore.symbols = private_fields |
| 161 | +dotnet_naming_rule.private_fields_underscore.style = underscore_camel_case |
| 162 | +dotnet_naming_symbols.private_fields.applicable_kinds = field |
| 163 | +dotnet_naming_symbols.private_fields.applicable_accessibilities = private,private_protected |
| 164 | +dotnet_naming_style.underscore_camel_case.required_prefix = _ |
| 165 | +dotnet_naming_style.underscore_camel_case.capitalization = camel_case |
| 166 | + |
| 167 | +# Static readonly private fields may be PascalCase — keep lenient |
| 168 | +dotnet_naming_rule.static_private_fields_pascal.severity = silent |
| 169 | +dotnet_naming_rule.static_private_fields_pascal.symbols = static_private_fields |
| 170 | +dotnet_naming_rule.static_private_fields_pascal.style = pascal_case |
| 171 | +dotnet_naming_symbols.static_private_fields.applicable_kinds = field |
| 172 | +dotnet_naming_symbols.static_private_fields.applicable_accessibilities = private |
| 173 | +dotnet_naming_symbols.static_private_fields.required_modifiers = static,readonly |
| 174 | + |
| 175 | +# Locals & parameters: camelCase |
| 176 | +dotnet_naming_rule.locals_camel.severity = suggestion |
| 177 | +dotnet_naming_rule.locals_camel.symbols = locals_and_params |
| 178 | +dotnet_naming_rule.locals_camel.style = camel_case |
| 179 | +dotnet_naming_symbols.locals_and_params.applicable_kinds = parameter,local |
| 180 | + |
| 181 | +# Shared style definitions |
| 182 | +dotnet_naming_style.pascal_case.capitalization = pascal_case |
| 183 | +dotnet_naming_style.camel_case.capitalization = camel_case |
| 184 | + |
| 185 | +# --------------------------------------------------------------------------- |
| 186 | +# Generated code — expected to respect the rules, but analysis is skipped |
| 187 | +# --------------------------------------------------------------------------- |
| 188 | +[**/{Generated,generated}/**.cs] |
| 189 | +generated_code = true |
| 190 | + |
| 191 | +# --------------------------------------------------------------------------- |
| 192 | +# Tests — relax rules that fight common test idioms |
| 193 | +# --------------------------------------------------------------------------- |
| 194 | +[**/*{Tests,Test,Specs}/**.cs] |
| 195 | +dotnet_diagnostic.IDE0058.severity = none # expression value never used (Assert/builder calls) |
0 commit comments