I'm new to FxCop. I have some constants that have underscores in the name. The name of these constants are somewhat long and can't be shortened. We don't use Pascal Case for constants - they are all uppercase.
I'm trying to figure out how to disable CA1707 (https://learn.microsoft.com/en-us/visualstudio/code-quality/ca1707?view=vs-2019) for just constants in the .editorconfig and am having no luck. I can disable CA1707 for everything, but I don't want that as regular variables should not have underscores.
I've tried setting some naming styles in the .editorconfig, but I don't know if I'm doing it right or if CA1707 overrules the naming styles anyway. I've tried search for how to accomplish this, but my Google-fu is weak today for some reason.
Here's what I have come up with thus far:
# Use Upper Case for constant fields
#dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
#dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
#dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_style.upper_case_style.capitalization = all_upper
dotnet_naming_style.upper_case_style.word_separator = _
dotnet_naming_rule.constant_fields_should_be_upper_case.severity = warning
dotnet_naming_rule.constant_fields_should_be_upper_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_upper_case.style = upper_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const
Any help or a point in the right direction would be greatly appreciated.
So after some more digging I found that in VS 2019, I can set the color of constants in the Fonts and Colors under the "User Members - Constants".
I still like all caps for constants to make them easy to spot in code, but changing the color achieves the same thing. So I made mine green, and now I can just make them pascal case like FxCop is demanding anyway.
I'd still be interested if there is a way to configure FxCop to not scream about the underscore for constants, but I no longer need the answer.