我看到了很多关于如何解决它的问题,但我想要阻止它.
要使所有字段都是CAMEL_CASE without下划线前缀(或任何匈牙利符号),我应该在.editorconfig文件中设置什么设置?
我看到了很多关于如何解决它的问题,但我想要阻止它.
要使所有字段都是CAMEL_CASE without下划线前缀(或任何匈牙利符号),我应该在.editorconfig文件中设置什么设置?
我自己也在研究下划线规则.似乎将CA1707设置为错误并不能解决问题,因为它只是在组件上发生故障.我可能在文件中遗漏了更多的规格,但当我试图使其工作时,我发现这gist被埋在对这issue的 comments 中.
# Start of NO underscore prefix on private fields
# Define the 'private_fields' symbol group:
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
# Define the 'notunderscored' naming style
dotnet_naming_style.notunderscored.capitalization = camel_case
dotnet_naming_style.notunderscored.required_prefix =
# Define the 'private_fields_notunderscored' naming rule
dotnet_naming_rule.private_fields_notunderscored.symbols = private_fields
dotnet_naming_rule.private_fields_notunderscored.style = notunderscored
dotnet_naming_rule.private_fields_notunderscored.severity = error
# End of No underscore prefix on private fields
要涵盖all个字段,您需要将可访问性更新为:
dotnet_naming_symbols.private_fields.applicable_accessibilities = *
如果您希望更准确地表示所有修改量的所有字段,您可能更喜欢此版本:
# Start of NO underscore prefix on all fields
# Define the 'all_fields' symbol group:
dotnet_naming_symbols.all_fields.applicable_kinds = field
dotnet_naming_symbols.all_fields.applicable_accessibilities = *
# Define the 'notunderscored' naming style
dotnet_naming_style.notunderscored.capitalization = pascal_case
dotnet_naming_style.notunderscored.required_prefix =
# Define the 'all_fields_notunderscored' naming rule
dotnet_naming_rule.all_fields_notunderscored.symbols = all_fields
dotnet_naming_rule.all_fields_notunderscored.style = notunderscored
dotnet_naming_rule.all_fields_notunderscored.severity = error
# End of No underscore prefix on all fields
以下是您将看到的错误:
_someVar
=不需要前缀‘_’someVar
=这些单词必须以大写字符开头_SomeVar
=不需要前缀‘_’SomeVar
=无错误我不能说匈牙利记数法部分;这似乎是一个困难的问题,可能需要一个定制的分析仪或使用R#或StyleCop.