|
| 1 | +# EditorConfig: https://editorconfig.org |
| 2 | +# Applied by Visual Studio, VS Code, Rider, and `dotnet format`. |
| 3 | + |
| 4 | +root = true |
| 5 | + |
| 6 | +# ----------------------------- |
| 7 | +# All files |
| 8 | +# ----------------------------- |
| 9 | +[*] |
| 10 | +charset = utf-8 |
| 11 | +end_of_line = crlf |
| 12 | +insert_final_newline = true |
| 13 | +trim_trailing_whitespace = true |
| 14 | +indent_style = space |
| 15 | +indent_size = 4 |
| 16 | + |
| 17 | +# ----------------------------- |
| 18 | +# Markdown |
| 19 | +# ----------------------------- |
| 20 | +[*.md] |
| 21 | +trim_trailing_whitespace = false |
| 22 | + |
| 23 | +# ----------------------------- |
| 24 | +# YAML / GitHub Actions |
| 25 | +# ----------------------------- |
| 26 | +[*.{yml,yaml}] |
| 27 | +indent_size = 2 |
| 28 | + |
| 29 | +# ----------------------------- |
| 30 | +# JSON |
| 31 | +# ----------------------------- |
| 32 | +[*.json] |
| 33 | +indent_size = 2 |
| 34 | + |
| 35 | +# ----------------------------- |
| 36 | +# XML / MSBuild project files |
| 37 | +# ----------------------------- |
| 38 | +[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}] |
| 39 | +indent_style = tab |
| 40 | +indent_size = 4 |
| 41 | + |
| 42 | +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] |
| 43 | +indent_style = tab |
| 44 | +indent_size = 4 |
| 45 | + |
| 46 | +[*.{sln,DotSettings}] |
| 47 | +indent_style = tab |
| 48 | +indent_size = 4 |
| 49 | + |
| 50 | +# ----------------------------- |
| 51 | +# Shell / scripts |
| 52 | +# ----------------------------- |
| 53 | +[*.{sh,ps1,cmd,bat}] |
| 54 | +end_of_line = lf |
| 55 | +indent_size = 2 |
| 56 | + |
| 57 | +[*.{cmd,bat,ps1}] |
| 58 | +end_of_line = crlf |
| 59 | + |
| 60 | +# ----------------------------- |
| 61 | +# C# source |
| 62 | +# ----------------------------- |
| 63 | +[*.cs] |
| 64 | +indent_style = space |
| 65 | +indent_size = 4 |
| 66 | + |
| 67 | +#### .NET coding conventions #### |
| 68 | +dotnet_sort_system_directives_first = true |
| 69 | +dotnet_separate_import_directive_groups = false |
| 70 | + |
| 71 | +# this. / Me. preferences |
| 72 | +dotnet_style_qualification_for_field = false:suggestion |
| 73 | +dotnet_style_qualification_for_property = false:suggestion |
| 74 | +dotnet_style_qualification_for_method = false:suggestion |
| 75 | +dotnet_style_qualification_for_event = false:suggestion |
| 76 | + |
| 77 | +# Language keywords vs BCL types |
| 78 | +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion |
| 79 | +dotnet_style_predefined_type_for_member_access = true:suggestion |
| 80 | + |
| 81 | +# Modifier preferences |
| 82 | +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion |
| 83 | +dotnet_style_readonly_field = true:suggestion |
| 84 | + |
| 85 | +# Parentheses preferences |
| 86 | +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent |
| 87 | +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent |
| 88 | +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent |
| 89 | +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent |
| 90 | + |
| 91 | +# Expression-level preferences |
| 92 | +dotnet_style_object_initializer = true:suggestion |
| 93 | +dotnet_style_collection_initializer = true:suggestion |
| 94 | +dotnet_style_explicit_tuple_names = true:suggestion |
| 95 | +dotnet_style_prefer_inferred_tuple_names = true:suggestion |
| 96 | +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion |
| 97 | +dotnet_style_prefer_auto_properties = true:suggestion |
| 98 | +dotnet_style_prefer_conditional_expression_over_assignment = true:silent |
| 99 | +dotnet_style_prefer_conditional_expression_over_return = true:silent |
| 100 | +dotnet_style_prefer_compound_assignment = true:suggestion |
| 101 | +dotnet_style_prefer_simplified_interpolation = true:suggestion |
| 102 | +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion |
| 103 | +dotnet_style_namespace_match_folder = true:suggestion |
| 104 | + |
| 105 | +# Null checking |
| 106 | +dotnet_style_coalesce_expression = true:suggestion |
| 107 | +dotnet_style_null_propagation = true:suggestion |
| 108 | +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion |
| 109 | +dotnet_style_prefer_null_check_over_type_check = true:suggestion |
| 110 | + |
| 111 | +# Parameter preferences |
| 112 | +dotnet_code_quality_unused_parameters = all:suggestion |
| 113 | + |
| 114 | +# Suppression |
| 115 | +dotnet_remove_unnecessary_suppression_exclusions = none |
| 116 | + |
| 117 | +#### C# coding conventions #### |
| 118 | +# var preferences — prefer explicit types (matches existing sample style) |
| 119 | +csharp_style_var_for_built_in_types = false:suggestion |
| 120 | +csharp_style_var_when_type_is_apparent = false:suggestion |
| 121 | +csharp_style_var_elsewhere = false:suggestion |
| 122 | + |
| 123 | +# Expression-bodied members |
| 124 | +csharp_style_expression_bodied_methods = false:silent |
| 125 | +csharp_style_expression_bodied_constructors = false:silent |
| 126 | +csharp_style_expression_bodied_operators = false:silent |
| 127 | +csharp_style_expression_bodied_properties = true:silent |
| 128 | +csharp_style_expression_bodied_indexers = true:silent |
| 129 | +csharp_style_expression_bodied_accessors = true:silent |
| 130 | +csharp_style_expression_bodied_lambdas = true:silent |
| 131 | +csharp_style_expression_bodied_local_functions = false:silent |
| 132 | + |
| 133 | +# Pattern matching |
| 134 | +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion |
| 135 | +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion |
| 136 | +csharp_style_prefer_switch_expression = true:suggestion |
| 137 | +csharp_style_prefer_pattern_matching = true:silent |
| 138 | +csharp_style_prefer_not_pattern = true:suggestion |
| 139 | +csharp_style_prefer_extended_property_pattern = true:suggestion |
| 140 | + |
| 141 | +# Null checking |
| 142 | +csharp_style_throw_expression = true:suggestion |
| 143 | +csharp_style_conditional_delegate_call = true:suggestion |
| 144 | + |
| 145 | +# Modifier preferences |
| 146 | +csharp_prefer_static_local_function = true:suggestion |
| 147 | +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:silent |
| 148 | +csharp_style_prefer_readonly_struct = true:suggestion |
| 149 | +csharp_style_prefer_readonly_struct_member = true:suggestion |
| 150 | + |
| 151 | +# Code-block preferences (Allman / new-line braces — matches this repo) |
| 152 | +csharp_prefer_braces = true:suggestion |
| 153 | +csharp_prefer_simple_using_statement = true:suggestion |
| 154 | +csharp_style_namespace_declarations = block_scoped:suggestion |
| 155 | +csharp_style_prefer_method_group_conversion = true:silent |
| 156 | +csharp_style_prefer_top_level_statements = false:suggestion |
| 157 | +csharp_style_prefer_primary_constructors = false:suggestion |
| 158 | + |
| 159 | +# Expression-level preferences |
| 160 | +csharp_prefer_simple_default_expression = true:suggestion |
| 161 | +csharp_style_deconstructed_variable_declaration = true:suggestion |
| 162 | +csharp_style_inlined_variable_declaration = true:suggestion |
| 163 | +csharp_style_prefer_index_operator = true:suggestion |
| 164 | +csharp_style_prefer_range_operator = true:suggestion |
| 165 | +csharp_style_prefer_local_over_anonymous_function = true:suggestion |
| 166 | +csharp_style_prefer_tuple_swap = true:suggestion |
| 167 | +csharp_style_prefer_utf8_string_literals = true:suggestion |
| 168 | +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion |
| 169 | +csharp_style_prefer_null_check_over_type_check = true:suggestion |
| 170 | + |
| 171 | +# 'using' directive preferences |
| 172 | +csharp_using_directive_placement = outside_namespace:suggestion |
| 173 | + |
| 174 | +# whether to prefer new() without type when type is apparent |
| 175 | +dotnet_style_prefer_collection_expression = when_types_exactly_match:suggestion |
| 176 | + |
| 177 | +#### C# formatting rules #### |
| 178 | +# New line preferences |
| 179 | +csharp_new_line_before_open_brace = all |
| 180 | +csharp_new_line_before_else = true |
| 181 | +csharp_new_line_before_catch = true |
| 182 | +csharp_new_line_before_finally = true |
| 183 | +csharp_new_line_before_members_in_object_initializers = true |
| 184 | +csharp_new_line_before_members_in_anonymous_types = true |
| 185 | +csharp_new_line_between_query_expression_clauses = true |
| 186 | + |
| 187 | +# Indentation preferences |
| 188 | +csharp_indent_case_contents = true |
| 189 | +csharp_indent_switch_labels = true |
| 190 | +csharp_indent_labels = one_less_than_current |
| 191 | +csharp_indent_block_contents = true |
| 192 | +csharp_indent_braces = false |
| 193 | +csharp_indent_case_contents_when_block = true |
| 194 | + |
| 195 | +# Space preferences |
| 196 | +csharp_space_after_cast = false |
| 197 | +csharp_space_after_keywords_in_control_flow_statements = true |
| 198 | +csharp_space_between_method_declaration_parameter_list_parentheses = false |
| 199 | +csharp_space_between_method_call_parameter_list_parentheses = false |
| 200 | +csharp_space_between_parentheses = false |
| 201 | +csharp_space_before_colon_in_inheritance_clause = true |
| 202 | +csharp_space_after_colon_in_inheritance_clause = true |
| 203 | +csharp_space_around_binary_operators = before_and_after |
| 204 | +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false |
| 205 | +csharp_space_between_method_call_name_and_opening_parenthesis = false |
| 206 | +csharp_space_between_method_call_empty_parameter_list_parentheses = false |
| 207 | +csharp_space_after_comma = true |
| 208 | +csharp_space_before_comma = false |
| 209 | +csharp_space_after_dot = false |
| 210 | +csharp_space_before_dot = false |
| 211 | +csharp_space_after_semicolon_in_for_statement = true |
| 212 | +csharp_space_before_semicolon_in_for_statement = false |
| 213 | +csharp_space_around_declaration_statements = false |
| 214 | +csharp_space_before_open_square_brackets = false |
| 215 | +csharp_space_between_empty_square_brackets = false |
| 216 | +csharp_space_between_square_brackets = false |
| 217 | + |
| 218 | +# Wrapping preferences |
| 219 | +csharp_preserve_single_line_statements = true |
| 220 | +csharp_preserve_single_line_blocks = true |
| 221 | + |
| 222 | +#### Naming conventions #### |
| 223 | +dotnet_naming_style.pascal_case_style.capitalization = pascal_case |
| 224 | +dotnet_naming_style.camel_case_style.capitalization = camel_case |
| 225 | +dotnet_naming_style.i_prefix_style.required_prefix = I |
| 226 | +dotnet_naming_style.i_prefix_style.capitalization = pascal_case |
| 227 | +dotnet_naming_style.underscore_camel_case.required_prefix = _ |
| 228 | +dotnet_naming_style.underscore_camel_case.capitalization = camel_case |
| 229 | + |
| 230 | +# Interfaces: IPascalCase |
| 231 | +dotnet_naming_rule.interface_should_be_begins_with_i.severity = true |
| 232 | +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface_symbols |
| 233 | +dotnet_naming_rule.interface_should_be_begins_with_i.style = i_prefix_style |
| 234 | +dotnet_naming_symbols.interface_symbols.applicable_kinds = interface |
| 235 | +dotnet_naming_symbols.interface_symbols.applicable_accessibilities = * |
| 236 | +dotnet_naming_symbols.interface_symbols.required_modifiers = |
| 237 | + |
| 238 | +# Types / non-field members: PascalCase |
| 239 | +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion |
| 240 | +dotnet_naming_rule.types_should_be_pascal_case.symbols = types_and_namespaces |
| 241 | +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case_style |
| 242 | +dotnet_naming_symbols.types_and_namespaces.applicable_kinds = class,struct,interface,enum,delegate,namespace |
| 243 | +dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = * |
| 244 | + |
| 245 | +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion |
| 246 | +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members |
| 247 | +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case_style |
| 248 | +dotnet_naming_symbols.non_field_members.applicable_kinds = property,event,method |
| 249 | +dotnet_naming_symbols.non_field_members.applicable_accessibilities = * |
| 250 | + |
| 251 | +# Constants: PascalCase |
| 252 | +dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion |
| 253 | +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields |
| 254 | +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style |
| 255 | +dotnet_naming_symbols.constant_fields.applicable_kinds = field |
| 256 | +dotnet_naming_symbols.constant_fields.applicable_accessibilities = * |
| 257 | +dotnet_naming_symbols.constant_fields.required_modifiers = const |
| 258 | + |
| 259 | +# Private / internal instance fields: _camelCase |
| 260 | +dotnet_naming_rule.private_fields_should_be_underscore_camel.severity = suggestion |
| 261 | +dotnet_naming_rule.private_fields_should_be_underscore_camel.symbols = private_fields |
| 262 | +dotnet_naming_rule.private_fields_should_be_underscore_camel.style = underscore_camel_case |
| 263 | +dotnet_naming_symbols.private_fields.applicable_kinds = field |
| 264 | +dotnet_naming_symbols.private_fields.applicable_accessibilities = private,private_protected,protected,internal,protected_internal |
| 265 | +dotnet_naming_symbols.private_fields.required_modifiers = |
| 266 | + |
| 267 | +# Static fields (non-const): PascalCase |
| 268 | +dotnet_naming_rule.static_fields_should_be_pascal_case.severity = suggestion |
| 269 | +dotnet_naming_rule.static_fields_should_be_pascal_case.symbols = static_fields |
| 270 | +dotnet_naming_rule.static_fields_should_be_pascal_case.style = pascal_case_style |
| 271 | +dotnet_naming_symbols.static_fields.applicable_kinds = field |
| 272 | +dotnet_naming_symbols.static_fields.applicable_accessibilities = * |
| 273 | +dotnet_naming_symbols.static_fields.required_modifiers = static |
| 274 | + |
| 275 | +# Local variables / parameters: camelCase |
| 276 | +dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion |
| 277 | +dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters |
| 278 | +dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style |
| 279 | +dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter,local |
| 280 | +dotnet_naming_symbols.locals_and_parameters.applicable_accessibilities = * |
0 commit comments