From 9b77acafe6ca1175d54ca12f6eef51de6070c0b9 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Wed, 25 Sep 2024 19:27:11 +0300 Subject: [PATCH] Updates the .editconfig naming rules for static fields --- .editorconfig | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.editorconfig b/.editorconfig index b45eeb55..028900f4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -271,16 +271,29 @@ dotnet_naming_symbols.local_functions.applicable_kinds = local_function dotnet_naming_style.local_function_style.capitalization = pascal_case -# readonly fields are camelCase and they begin with underscore -dotnet_naming_symbols.readonly_fields.applicable_kinds = field -dotnet_naming_symbols.readonly_fields.required_modifiers = readonly +# readonly instance fields are camelCase and begin with underscore +dotnet_naming_symbols.readonly_instance_fields.applicable_kinds = field +dotnet_naming_symbols.readonly_instance_fields.required_modifiers = readonly +dotnet_naming_symbols.readonly_instance_fields.required_modifiers_style = exclude_any +dotnet_naming_symbols.readonly_instance_fields.required_modifiers = static dotnet_naming_style.underscore_camel_case_style.capitalization = camel_case dotnet_naming_style.underscore_camel_case_style.required_prefix = _ -dotnet_naming_rule.readonly_fields_should_be_underscore_camel_case.symbols = readonly_fields -dotnet_naming_rule.readonly_fields_should_be_underscore_camel_case.style = underscore_camel_case_style -dotnet_naming_rule.readonly_fields_should_be_underscore_camel_case.severity = warning +dotnet_naming_rule.readonly_instance_fields_should_be_underscore_camel_case.symbols = readonly_instance_fields +dotnet_naming_rule.readonly_instance_fields_should_be_underscore_camel_case.style = underscore_camel_case_style +dotnet_naming_rule.readonly_instance_fields_should_be_underscore_camel_case.severity = warning + +# static readonly fields start with s_ and use camelCase +dotnet_naming_symbols.static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.static_readonly_fields.required_modifiers = static, readonly + +dotnet_naming_style.s_prefix_camel_case_style.capitalization = camel_case +dotnet_naming_style.s_prefix_camel_case_style.required_prefix = s_ + +dotnet_naming_rule.static_readonly_fields_should_be_s_prefix_camel_case.symbols = static_readonly_fields +dotnet_naming_rule.static_readonly_fields_should_be_s_prefix_camel_case.style = s_prefix_camel_case_style +dotnet_naming_rule.static_readonly_fields_should_be_s_prefix_camel_case.severity = warning # Additional C# style preferences csharp_style_namespace_declarations = file_scoped:error # no need for an extra indentation for namespace, when a single type per file rule is enforced.