1

我正在尝试为 VS 2017 的常量创建命名约定。问题是与规则存在某种冲突,因为当我定义这样的常量时出现此错误:

private const string HOLAMUCHACHO = "1";

“第一个单词“HOLAMUCHACHO”必须以小写字符开头”。

这是我的 .editorconfig:

## Private members must be camelCase
dotnet_naming_style.private_field_style.capitalization = camel_case

dotnet_naming_rule.private_fields_are_camel_case.severity = error
dotnet_naming_rule.private_fields_are_camel_case.symbols = private_field_symbol
dotnet_naming_rule.private_fields_are_camel_case.style = private_field_style

dotnet_naming_symbols.private_field_symbol.applicable_kinds = field
dotnet_naming_symbols.private_field_symbol.applicable_accessibilities = private

## Constants must be UPPER_CASE
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 = error
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

有任何想法吗?提前致谢。

4

1 回答 1

1

好的,因此将 const 规则置于私有成员之上似乎可行:首先是更具体的规则 :)

于 2019-05-15T15:42:25.517 回答