EditorConfig naming rule for test classes is ignored, but works for methods.

I'm trying to add underscore delimiter as an allowed word delimiter in a C# project within a solution.
It's only supposed to be allowed in the test project.

But I can't manage to make R# not complain about the class name.

My root file has a general pascal case rule for all identifiers and an overriding one for private fields:

[*.cs]

dotnet_naming_rule.identifiers_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.identifiers_should_be_pascal_case.symbols = identifiers_pascal_case
dotnet_naming_rule.identifiers_should_be_pascal_case.style = pascal_case

dotnet_naming_symbols.identifiers_pascal_case.applicable_kinds = namespace, class, struct, interface, enum, property, method, field, event, delegate
dotnet_naming_symbols.identifiers_pascal_case.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.identifiers_pascal_case.required_modifiers =

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

The test project allows underscore for class, test_type and method:

[*.cs]

# Allow underscores in test classes & methods
dotnet_naming_rule.tests_allow_underscores.symbols = test_members
dotnet_naming_rule.tests_allow_underscores.style = pascal_with_underscores
dotnet_naming_rule.tests_allow_underscores.severity = suggestion
resharper_csharp_naming_rule.tests_allow_underscores = AaBb,AaBb_AaBb

dotnet_naming_symbols.test_members.resharper_applicable_kinds = method,class,test_type
dotnet_naming_symbols.test_members.applicable_kinds = method,class
dotnet_naming_symbols.test_members.applicable_accessibilities = *
dotnet_naming_symbols.test_members.required_modifiers =

dotnet_naming_style.pascal_with_underscores.capitalization = pascal_case
dotnet_naming_style.pascal_with_underscores.word_separator = _
dotnet_naming_style.pascal_with_underscores.resharper_style = AaBb,AaBb_AaBb

It seems to work for methods, but no matter what I try, I can't manage to remove the green squiggly under test class names.
The rule indicated by the lightbulb action menu is `identifiers_should_be_pascal_case`.

What am I missing?

0
1 comment

Hello Lea, 

Sorry for the late response. This ticket has slipped over our radar somehow. 

I've tested this scenario in my environment. To make it work, please add the following to your .editorconfig: dotnet_naming_symbols.test_members.resharper_required_modifiers = any. Please let me know if it doesn't work for you. 

Recommendation:
To ensure all necessary fields are included in your .editorconfig, it’s best to configure the naming rule via UI first, then export it

Thanks,

Tom

0

Please sign in to leave a comment.