|
| 1 | +# Unity-focused .editorconfig |
| 2 | +root = true |
| 3 | + |
| 4 | +# Applies to all files |
| 5 | +[*] |
| 6 | +charset = utf-8 |
| 7 | +end_of_line = lf |
| 8 | +indent_style = tab |
| 9 | +indent_size = 4 |
| 10 | +insert_final_newline = true |
| 11 | +trim_trailing_whitespace = true |
| 12 | +max_line_length = 120 |
| 13 | + |
| 14 | +# Applies only to C# scripts |
| 15 | +[*.cs] |
| 16 | + |
| 17 | +# Brace style – Allman (Unity standard) |
| 18 | +csharp_new_line_before_open_brace = all |
| 19 | + |
| 20 | +# Prefer explicit types for clarity |
| 21 | +csharp_style_var_for_built_in_types = false:suggestion |
| 22 | +csharp_style_var_when_type_is_apparent = false:suggestion |
| 23 | +csharp_style_var_elsewhere = false:suggestion |
| 24 | + |
| 25 | +# Expression-bodied members – only for simple properties |
| 26 | +csharp_style_expression_bodied_methods = false:suggestion |
| 27 | +csharp_style_expression_bodied_properties = true:suggestion |
| 28 | + |
| 29 | +# Avoid unnecessary `this.` qualifier |
| 30 | +dotnet_style_qualification_for_field = false:suggestion |
| 31 | +dotnet_style_qualification_for_property = false:suggestion |
| 32 | +dotnet_style_qualification_for_method = false:suggestion |
| 33 | +dotnet_style_qualification_for_event = false:suggestion |
| 34 | + |
| 35 | +# Namespace declaration style – block scoped |
| 36 | +csharp_style_namespace_declarations = block_scoped:suggestion |
| 37 | + |
| 38 | +############### |
| 39 | +# Naming Rules |
| 40 | +############### |
| 41 | + |
| 42 | +# Public fields (Inspector-exposed) – PascalCase |
| 43 | +dotnet_naming_rule.public_fields_should_be_pascal.symbols = public_fields |
| 44 | +dotnet_naming_rule.public_fields_should_be_pascal.style = pascal_case |
| 45 | +dotnet_naming_rule.public_fields_should_be_pascal.severity = warning |
| 46 | + |
| 47 | +dotnet_naming_symbols.public_fields.applicable_kinds = field |
| 48 | +dotnet_naming_symbols.public_fields.applicable_accessibilities = public |
| 49 | +dotnet_naming_style.pascal_case.capitalization = PascalCase |
| 50 | + |
| 51 | +# All private fields – _camelCase (includes [SerializeField] fields) |
| 52 | +dotnet_naming_rule.private_fields_should_be_camelcase.symbols = private_fields |
| 53 | +dotnet_naming_rule.private_fields_should_be_camelcase.style = camel_with_underscore |
| 54 | +dotnet_naming_rule.private_fields_should_be_camelcase.severity = warning |
| 55 | + |
| 56 | +dotnet_naming_symbols.private_fields.applicable_kinds = field |
| 57 | +dotnet_naming_symbols.private_fields.applicable_accessibilities = private |
| 58 | + |
| 59 | +dotnet_naming_style.camel_with_underscore.required_prefix = _ |
| 60 | +dotnet_naming_style.camel_with_underscore.capitalization = camel_case |
| 61 | + |
| 62 | +# Interfaces – PascalCase with 'I' prefix |
| 63 | +dotnet_naming_rule.interfaces_should_start_with_i.symbols = interfaces |
| 64 | +dotnet_naming_rule.interfaces_should_start_with_i.style = interface_prefix_i |
| 65 | +dotnet_naming_rule.interfaces_should_start_with_i.severity = warning |
| 66 | + |
| 67 | +dotnet_naming_symbols.interfaces.applicable_kinds = interface |
| 68 | +dotnet_naming_style.interface_prefix_i.capitalization = PascalCase |
| 69 | +dotnet_naming_style.interface_prefix_i.required_prefix = I |
| 70 | + |
| 71 | +# Methods – PascalCase |
| 72 | +dotnet_naming_rule.methods_should_be_pascal.symbols = methods |
| 73 | +dotnet_naming_rule.methods_should_be_pascal.style = pascal_case |
| 74 | +dotnet_naming_rule.methods_should_be_pascal.severity = warning |
| 75 | + |
| 76 | +dotnet_naming_symbols.methods.applicable_kinds = method |
| 77 | + |
| 78 | +# Method parameters – camelCase |
| 79 | +dotnet_naming_rule.parameters_should_be_camelcase.symbols = parameters |
| 80 | +dotnet_naming_rule.parameters_should_be_camelcase.style = camelcase |
| 81 | +dotnet_naming_rule.parameters_should_be_camelcase.severity = warning |
| 82 | + |
| 83 | +dotnet_naming_symbols.parameters.applicable_kinds = parameter |
| 84 | +dotnet_naming_style.camel_case.capitalization = camelCase |
| 85 | + |
| 86 | +# Constants – ALL_CAPS |
| 87 | +dotnet_naming_rule.constants_should_be_all_caps.symbols = constants |
| 88 | +dotnet_naming_rule.constants_should_be_all_caps.style = all_caps |
| 89 | +dotnet_naming_rule.constants_should_be_all_caps.severity = warning |
| 90 | + |
| 91 | +dotnet_naming_symbols.constants.applicable_kinds = field |
| 92 | +dotnet_naming_symbols.constants.required_modifiers = const |
| 93 | + |
| 94 | +dotnet_naming_style.all_caps.capitalization = all_upper |
| 95 | +dotnet_naming_style.all_caps.word_separator = _ |
| 96 | + |
| 97 | +# Static fields – s_camelCase (optional Unity style) |
| 98 | +dotnet_naming_rule.static_fields_should_be_s_camel.symbols = static_fields |
| 99 | +dotnet_naming_rule.static_fields_should_be_s_camel.style = s_camel |
| 100 | +dotnet_naming_rule.static_fields_should_be_s_camel.severity = warning |
| 101 | + |
| 102 | +dotnet_naming_symbols.static_fields.applicable_kinds = field |
| 103 | +dotnet_naming_symbols.static_fields.required_modifiers = static |
| 104 | +dotnet_naming_style.s_camel.required_prefix = s_ |
| 105 | +dotnet_naming_style.s_camel.capitalization = camelcase |
0 commit comments