|
| 1 | +# see http://editorconfig.org/ for docs on this file |
| 2 | + |
| 3 | +root = true |
| 4 | + |
| 5 | +# _ _ _ |
| 6 | +# | | | | (_) |
| 7 | +# ___ ___ _ __ ___ _ __ ___ ___ _ __ ___ ___| |_| |_ _ _ __ __ _ ___ |
| 8 | +# / __/ _ \| '_ ` _ \| '_ ` _ \ / _ \| '_ \ / __|/ _ \ __| __| | '_ \ / _` / __| |
| 9 | +# | (_| (_) | | | | | | | | | | | (_) | | | | \__ \ __/ |_| |_| | | | | (_| \__ \ |
| 10 | +# \___\___/|_| |_| |_|_| |_| |_|\___/|_| |_| |___/\___|\__|\__|_|_| |_|\__, |___/ |
| 11 | +# __/ | |
| 12 | +# |___/ |
| 13 | + |
| 14 | +[*] |
| 15 | + |
| 16 | +# sanity across platforms |
| 17 | +end_of_line = lf |
| 18 | + |
| 19 | +# this is our general standard: exceptions permitted only when a) required by the format or b) strong de facto convention |
| 20 | +indent_style = space |
| 21 | +indent_size = 4 |
| 22 | + |
| 23 | +# prevent files with BOMs on them coming into the repo |
| 24 | +charset = utf-8 |
| 25 | + |
| 26 | +# other common settings |
| 27 | +trim_trailing_whitespace = true |
| 28 | +insert_final_newline = true |
| 29 | + |
| 30 | +cpp_space_pointer_reference_alignment = left |
| 31 | + |
| 32 | +# _ _ |
| 33 | +# (_) | | |
| 34 | +# _____ _____ _ __ _ __ _ __| | ___ ___ |
| 35 | +# / _ \ \ / / _ \ '__| '__| |/ _` |/ _ \/ __| |
| 36 | +# | (_) \ V / __/ | | | | | (_| | __/\__ \ |
| 37 | +# \___/ \_/ \___|_| |_| |_|\__,_|\___||___/ |
| 38 | +# |
| 39 | +# |
| 40 | + |
| 41 | +[{Makefile,makefile}] |
| 42 | +indent_style = tab |
| 43 | + |
| 44 | +[*.{md,markdown,mdx}] |
| 45 | +# trailing whitespace is significant in markdown (bad choice, bad!) |
| 46 | +trim_trailing_whitespace = false |
| 47 | + |
| 48 | +# crlf because tool expectations (based on experimentation) |
| 49 | +[*.{bat,cmd,xaml,tt,t4,ttinclude}] |
| 50 | +end_of_line = crlf |
| 51 | + |
| 52 | +[*.{json,asmdef}] |
| 53 | +indent_size = 2 |
| 54 | + |
| 55 | +[*.{yaml,yml}] |
| 56 | +indent_size = 2 |
| 57 | + |
| 58 | +# msbuild-related files (these are usually not tool-authored) |
| 59 | +[*.{props,targets,msbuildproj,proj}] |
| 60 | +indent_size = 2 |
| 61 | + |
| 62 | +### visual studio |
| 63 | + |
| 64 | +# these settings are based on experiments to see how vs will modify a file after it has been |
| 65 | +# manually edited. the settings are meant to match what vs does to minimize unnecessary diffs. |
| 66 | + |
| 67 | +# related notes from research: |
| 68 | +# |
| 69 | +# 1. rider tends to preserve existing file settings, but we must go with the more strict vs. |
| 70 | +# |
| 71 | +# 2. file-new templates in vs, rider, and `dotnet new` contain bom's (byte order markers) and |
| 72 | +# crlf. crlf we must preserve because vs, but bom's must be burned with fire. all editors are |
| 73 | +# fine with this. |
| 74 | + |
| 75 | +[*.sln] |
| 76 | +indent_style = tab |
| 77 | +end_of_line = crlf |
| 78 | +insert_final_newline = false |
| 79 | + |
| 80 | +[*.{vcxproj,vcxproj.filters}] |
| 81 | +indent_size = 2 |
| 82 | +end_of_line = crlf |
| 83 | +insert_final_newline = false |
| 84 | + |
| 85 | +[*.vcproj] |
| 86 | +indent_style = tab |
| 87 | +end_of_line = crlf |
| 88 | + |
| 89 | +# csproj is a bit more flexible, in part because VS does some preservation of whitespace. however, |
| 90 | +# lines it adds will get crlf's, and if the rest of the file has lf, we'll get a mixed file. so we |
| 91 | +# must set the whole thing to be crlf. |
| 92 | +[*.csproj] |
| 93 | +indent_size = 2 |
| 94 | +end_of_line = crlf |
| 95 | + |
| 96 | + |
| 97 | +# __ _ _ |
| 98 | +# / _| | | | | |
| 99 | +# | |_ ___ _ __ _ __ ___ __ _| |_ _ __ _ _| | ___ ___ |
| 100 | +# | _/ _ \| '__| '_ ` _ \ / _` | __| | '__| | | | |/ _ \/ __| |
| 101 | +# | || (_) | | | | | | | | (_| | |_ | | | |_| | | __/\__ \ |
| 102 | +# |_| \___/|_| |_| |_| |_|\__,_|\__| |_| \__,_|_|\___||___/ |
| 103 | +# |
| 104 | +# |
| 105 | + |
| 106 | +# http://go/format |
| 107 | +# https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-format |
| 108 | + |
| 109 | + |
| 110 | +[*.cs] |
| 111 | + |
| 112 | +# The entire monorepo has a single standard. |
| 113 | +# |
| 114 | +# if you want to propose changes to the standard, raise it with the people assigned to .editorconfig in |
| 115 | +# .github/UNITY_CODEOWNERS. |
| 116 | + |
| 117 | +# ___ ___ __ __ __ ___ |
| 118 | +# | | |__| | | |__ /__` |__) /\ / ` |__ |
| 119 | +# |/\| | | | | |___ .__/ | /~~\ \__, |___ |
| 120 | + |
| 121 | +# whitespace-only format uses options under IDE0055 (https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0055) |
| 122 | +# |
| 123 | +# IDE0055 is made up of these formatting options: |
| 124 | +# - https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options |
| 125 | +# - https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/dotnet-formatting-options |
| 126 | + |
| 127 | +# to reformat code with these rules, use `dotnet format whitespace <path> --folder`. the rules are exclusively about |
| 128 | +# code structure and do not require symbol awareness. they can be run on any file without needing a project or compile |
| 129 | +# to be done first. |
| 130 | + |
| 131 | +# newline options |
| 132 | +csharp_new_line_before_open_brace = all |
| 133 | +csharp_new_line_before_else = true |
| 134 | +csharp_new_line_before_catch = true |
| 135 | +csharp_new_line_before_finally = true |
| 136 | +csharp_new_line_before_members_in_object_initializers = true |
| 137 | +csharp_new_line_before_members_in_anonymous_types = true |
| 138 | +csharp_new_line_between_query_expression_clauses = true |
| 139 | + |
| 140 | +# indentation options |
| 141 | +csharp_indent_case_contents = true |
| 142 | +csharp_indent_switch_labels = true |
| 143 | +csharp_indent_labels = one_less_than_current |
| 144 | +csharp_indent_block_contents = true |
| 145 | +csharp_indent_braces = false |
| 146 | +csharp_indent_case_contents_when_block = false |
| 147 | + |
| 148 | +# spacing |
| 149 | +csharp_space_after_cast = false |
| 150 | +csharp_space_after_keywords_in_control_flow_statements = true |
| 151 | +csharp_space_between_parentheses = false |
| 152 | +csharp_space_before_colon_in_inheritance_clause = true |
| 153 | +csharp_space_after_colon_in_inheritance_clause = true |
| 154 | +csharp_space_around_binary_operators = before_and_after |
| 155 | +csharp_space_between_method_declaration_parameter_list_parentheses = false |
| 156 | +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false |
| 157 | +csharp_space_between_method_declaration_name_and_open_parenthesis = false |
| 158 | +csharp_space_between_method_call_parameter_list_parentheses = false |
| 159 | +csharp_space_between_method_call_empty_parameter_list_parentheses = false |
| 160 | +csharp_space_between_method_call_name_and_opening_parenthesis = false |
| 161 | +csharp_space_after_comma = true |
| 162 | +csharp_space_before_comma = false |
| 163 | +csharp_space_after_dot = false |
| 164 | +csharp_space_before_dot = false |
| 165 | +csharp_space_after_semicolon_in_for_statement = true |
| 166 | +csharp_space_before_semicolon_in_for_statement = false |
| 167 | +csharp_space_around_declaration_statements = false |
| 168 | +csharp_space_before_open_square_brackets = false |
| 169 | +csharp_space_between_empty_square_brackets = false |
| 170 | +csharp_space_between_square_brackets = false |
| 171 | + |
| 172 | +# wrap options |
| 173 | +csharp_preserve_single_line_statements = true |
| 174 | +csharp_preserve_single_line_blocks = true |
| 175 | +max_line_length = 120 |
| 176 | + |
| 177 | +# using directives |
| 178 | +dotnet_sort_system_directives_first = true |
| 179 | +dotnet_separate_import_directive_groups = false |
| 180 | + |
| 181 | +# __ ___ ___ |
| 182 | +# /__` | \ / | |__ |
| 183 | +# .__/ | | |___ |___ |
| 184 | + |
| 185 | +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ |
| 186 | + |
| 187 | +# Code-style naming rules |
| 188 | +# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/naming-rules |
| 189 | +# A. dotnet_naming_symbols: specify a symbol group |
| 190 | +# B. dotnet_naming_style: specify a naming style |
| 191 | +# C. dotnet_naming_rule: specify a rule that applies a naming style to a symbol group |
| 192 | + |
| 193 | +# 1. General symbol rules |
| 194 | +# 1.1 Namespaces, classes, structs, enumerations, methods, and delegates: PascalCase |
| 195 | +dotnet_naming_symbols.majority_of_symbols.applicable_kinds = namespace, class, struct, enum, method, delegate |
| 196 | +dotnet_naming_symbols.majority_of_symbols.applicable_accessibilities = * |
| 197 | +# 1.2 Modifier preferences |
| 198 | +dotnet_style_require_accessibility_modifiers = omit_if_default:suggestion |
| 199 | +dotnet_style_readonly_field = true:suggestion |
| 200 | + |
| 201 | +# NOTE camelCase vs PascalCase for public fields/properties/events is the only different between |
| 202 | +# UnityEngine/UnityEditor and Unity (non-UnityEngine/UnityEditor to be exact) namespace conventions. |
| 203 | +# Search for "NOTE Unity namespace" to find the appropriate places where to do the adjustments. |
| 204 | +dotnet_naming_style.camel_case_style.capitalization = camel_case |
| 205 | +dotnet_naming_style.pascal_case_style.capitalization = pascal_case |
| 206 | + |
| 207 | +dotnet_naming_rule.majority_of_symbols_should_be_pascal_case.symbols = majority_of_symbols # The symbol group that the rule applies to |
| 208 | +dotnet_naming_rule.majority_of_symbols_should_be_pascal_case.style = pascal_case_style # The naming style to associate with the rule |
| 209 | +dotnet_naming_rule.majority_of_symbols_should_be_pascal_case.severity = suggestion # The severity for enforcing the convention |
| 210 | + |
| 211 | +# 1.2 Interfaces: IPascalCase |
| 212 | +dotnet_naming_symbols.interfaces.applicable_kinds = interface |
| 213 | +dotnet_naming_symbols.interfaces.applicable_accessibilities = * |
| 214 | + |
| 215 | +dotnet_naming_style.ipascal_case_style.capitalization = pascal_case |
| 216 | +dotnet_naming_style.ipascal_case_style.required_prefix = I |
| 217 | + |
| 218 | +dotnet_naming_rule.interfaces_should_begin_with_i.symbols = interfaces |
| 219 | +dotnet_naming_rule.interfaces_should_begin_with_i.style = ipascal_case_style |
| 220 | +dotnet_naming_rule.interfaces_should_begin_with_i.severity = suggestion |
| 221 | + |
| 222 | +# 1.3 Type parameters: TPascalCase |
| 223 | +dotnet_naming_symbols.type_parameters.applicable_kinds = type_parameter |
| 224 | +dotnet_naming_symbols.type_parameters.applicable_accessibilities = * |
| 225 | + |
| 226 | +dotnet_naming_style.tpascal_case_style.capitalization = pascal_case |
| 227 | +dotnet_naming_style.tpascal_case_style.required_prefix = T |
| 228 | + |
| 229 | +dotnet_naming_rule.type_parameters_should_beging_with_t.symbols = type_parameters |
| 230 | +dotnet_naming_rule.type_parameters_should_beging_with_t.style = tpascal_case_style |
| 231 | +dotnet_naming_rule.type_parameters_should_beging_with_t.severity = suggestion |
| 232 | + |
| 233 | +# 2. Public fields, including events, all properties: |
| 234 | + |
| 235 | +# Public fields and properties case depends on the namespace and can't be generalized. |
| 236 | +# Public fields and properties in UnityEngine and UnityEditor namespaces should use camelCase, |
| 237 | +# and they should PascalCase in other namespaces. |
| 238 | + |
| 239 | +# To enforce this another .editorconfig file will be needed in the subfolders containing either |
| 240 | +# UnityEngine and UnityEditor code or other namespace code. |
| 241 | +# See /Modules/HierarchyCore/.editorconfig for an example of overriden rules for specific namespaces. |
| 242 | + |
| 243 | +# 2.1 fields |
| 244 | +dotnet_naming_symbols.public_fields.applicable_kinds = field, event |
| 245 | +dotnet_naming_symbols.public_fields.applicable_accessibilities = public |
| 246 | + |
| 247 | +dotnet_naming_rule.public_fields_use_correct_case.symbols = public_fields |
| 248 | +dotnet_naming_rule.public_fields_use_correct_case.style = pascal_case_style |
| 249 | +dotnet_naming_rule.public_fields_use_correct_case.severity = none |
| 250 | + |
| 251 | +# 2.2 properties |
| 252 | +dotnet_naming_symbols.properties.applicable_kinds = property |
| 253 | +dotnet_naming_symbols.properties.applicable_accessibilities = * |
| 254 | + |
| 255 | +dotnet_naming_rule.properties_use_correct_case.symbols = properties |
| 256 | +dotnet_naming_rule.properties_use_correct_case.style = pascal_case_style |
| 257 | +dotnet_naming_rule.properties_use_correct_case.severity = none |
| 258 | + |
| 259 | +# 3. Non-public fields, including events: m_PascalCase |
| 260 | +dotnet_naming_symbols.nonpublic_fields.applicable_kinds = field, event |
| 261 | +dotnet_naming_symbols.nonpublic_fields.applicable_accessibilities = internal, private, protected, protected_internal, private_protected |
| 262 | + |
| 263 | +dotnet_naming_style.m_pascal_case_style.capitalization = pascal_case |
| 264 | +dotnet_naming_style.m_pascal_case_style.required_prefix = m_ |
| 265 | + |
| 266 | +dotnet_naming_rule.nonpublic_fields_must_be_prefixed.symbols = nonpublic_fields |
| 267 | +dotnet_naming_rule.nonpublic_fields_must_be_prefixed.style = m_pascal_case_style |
| 268 | +dotnet_naming_rule.nonpublic_fields_must_be_prefixed.severity = suggestion |
| 269 | + |
| 270 | +# 4. Non-public static fields: s_PascalCase |
| 271 | +dotnet_naming_symbols.nonpublic_static_fields.applicable_kinds = field, event |
| 272 | +dotnet_naming_symbols.nonpublic_static_fields.applicable_accessibilities = internal, private, protected, protected_internal, private_protected |
| 273 | +dotnet_naming_symbols.nonpublic_static_fields.required_modifiers = static |
| 274 | + |
| 275 | +dotnet_naming_style.s_pascal_case_style.capitalization = pascal_case |
| 276 | +dotnet_naming_style.s_pascal_case_style.required_prefix = s_ |
| 277 | + |
| 278 | +dotnet_naming_rule.nonpublic_static_fields_must_be_prefixed.symbols = nonpublic_static_fields |
| 279 | +dotnet_naming_rule.nonpublic_static_fields_must_be_prefixed.style = s_pascal_case_style |
| 280 | +dotnet_naming_rule.nonpublic_static_fields_must_be_prefixed.severity = suggestion |
| 281 | + |
| 282 | +# 5. Non-public const fields: k_PascalCase |
| 283 | +dotnet_naming_symbols.nonpublic_const_fields.applicable_kinds = field, event |
| 284 | +dotnet_naming_symbols.nonpublic_const_fields.applicable_accessibilities = internal, private, protected, protected_internal, private_protected |
| 285 | +dotnet_naming_symbols.nonpublic_const_fields.required_modifiers = const |
| 286 | + |
| 287 | +dotnet_naming_style.k_pascal_case_style.capitalization = pascal_case |
| 288 | +dotnet_naming_style.k_pascal_case_style.required_prefix = k_ |
| 289 | + |
| 290 | +dotnet_naming_rule.nonpublic_const_fields_must_be_prefixed.symbols = nonpublic_const_fields |
| 291 | +dotnet_naming_rule.nonpublic_const_fields_must_be_prefixed.style = k_pascal_case_style |
| 292 | +dotnet_naming_rule.nonpublic_const_fields_must_be_prefixed.severity = suggestion |
| 293 | + |
| 294 | +# 6. Non-public static readonly fields: k_PascalCase |
| 295 | +dotnet_naming_symbols.nonpublic_static_readonly_fields.applicable_kinds = field |
| 296 | +dotnet_naming_symbols.nonpublic_static_readonly_fields.applicable_accessibilities = internal, private, protected, protected_internal, private_protected |
| 297 | +dotnet_naming_symbols.nonpublic_static_readonly_fields.required_modifiers = static, readonly |
| 298 | + |
| 299 | +dotnet_naming_rule.nonpublic_static_readonly_fields_must_be_prefixed.symbols = nonpublic_static_readonly_fields |
| 300 | +dotnet_naming_rule.nonpublic_static_readonly_fields_must_be_prefixed.style = k_pascal_case_style |
| 301 | +dotnet_naming_rule.nonpublic_static_readonly_fields_must_be_prefixed.severity = suggestion |
| 302 | + |
| 303 | +# 7. Parameters and local variables: camelCase |
| 304 | +# 7.1 parameters |
| 305 | +dotnet_naming_symbols.parameters.applicable_kinds = parameter |
| 306 | + |
| 307 | +dotnet_naming_rule.parameters_must_be_camel_case.symbols = parameters |
| 308 | +dotnet_naming_rule.parameters_must_be_camel_case.style = camel_case_style |
| 309 | +dotnet_naming_rule.parameters_must_be_camel_case.severity = suggestion |
| 310 | + |
| 311 | +# 7.2 local variables |
| 312 | +dotnet_naming_symbols.local_variables.applicable_kinds = local |
| 313 | + |
| 314 | +dotnet_naming_rule.local_variables_must_be_camel_case.symbols = local_variables |
| 315 | +dotnet_naming_rule.local_variables_must_be_camel_case.style = camel_case_style |
| 316 | +dotnet_naming_rule.local_variables_must_be_camel_case.severity = suggestion |
0 commit comments