我正在编写editorconfig文件以强制执行某些编码样式,并且我希望强制常量应为大写,因此我在editorConfig文件中创建了以下规则:
dotnet_naming_rule.constants_must_be_uppercase.symbols = public_constants
dotnet_naming_symbols.public_constants.applicable_kinds = field
dotnet_naming_symbols.public_constants.applicable_accessibilities = *
dotnet_naming_symbols.public_constants.required_modifiers = const
dotnet_naming_rule.constants_must_be_uppercase.style = uppercase_with_underscore_separator
dotnet_naming_style.uppercase_with_underscore_separator.capitalization = all_upper
dotnet_naming_style.uppercase_with_underscore_separator.word_separator = _
dotnet_naming_rule.constants_must_be_uppercase.severity = warning
我正在使用以下代码对此进行测试:
namespace XYZ
{
public class Foo
{
public const string Bar = "bar";
}
}
但是,Visual Studio并不表示该行不正确。是错误还是我的文件不正确?
答案 0 :(得分:0)
如果其他人像我一样偶然发现了这个问题,请留在这里。
这些是我认为用于增强大写常量的.editorconfig行:
# Constants are UPPERCASE
dotnet_naming_rule.constants_should_be_upper_case.severity = suggestion
dotnet_naming_rule.constants_should_be_upper_case.symbols = constants
dotnet_naming_rule.constants_should_be_upper_case.style = constant_style
dotnet_naming_symbols.constants.applicable_kinds = field, local
dotnet_naming_symbols.constants.required_modifiers = const
dotnet_naming_style.constant_style.capitalization = all_upper