我正在将这个.editorconfig文件用于组项目,我们正在使用的命名约定之一是私有成员应该是带有下划线的camelCase。
问题是,由于某种原因,规则与我项目中的类中的私有成员不匹配。有什么想法吗?
# top-most EditorConfig file
root = true
# Don't use tabs for indentation.
[*]
indent_style = space
# Code files
[*.{cs,csx}]
indent_size = 4
insert_final_newline = true
charset = utf-8-bom
# Xml project files
[*.csproj]
indent_size = 2
# JSON files
[*.json]
indent_size = 4
# Dotnet code style settings:
[*.cs]
# TRUE
csharp_style_expression_bodied_properties = true:suggestion
csharp_space_after_keywords_in_control_flow_statements = true:suggestion
csharp_preserve_single_line_blocks = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_prefer_braces = true:suggestion
csharp_new_line_before_members_in_object_initializers = true:suggestion
csharp_new_line_before_members_in_anonymous_types = true:suggestion
csharp_indent_case_contents = true:suggestion
csharp_indent_switch_labels = true:suggestion
# FALSE
csharp_style_expression_bodied_constructors = false:suggestion
csharp_style_expression_bodied_operators = false:suggestion
csharp_style_expression_bodied_indexers = false:suggestion
csharp_style_expression_bodied_accessors = false:suggestion
csharp_space_after_cast = false:suggestion
csharp_space_between_method_declaration_parameter_list_parentheses = false:suggestion
csharp_space_between_method_call_parameter_list_parentheses = false:suggestion
csharp_preserve_single_line_statements = false:suggestion
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_when_type_is_apparent = false:suggestion
csharp_style_var_elsewhere = false:suggestion
csharp_style_inlined_variable_declaration = false:suggestion
csharp_style_pattern_local_over_anonymous_function = false:suggestion
csharp_new_line_before_else = false:suggestion
csharp_new_line_before_catch = false:suggestion
csharp_new_line_before_finally = false:suggestion
# PARAMETERS
csharp_space_between_parentheses = NONE
dotnet_style_require_accessibility_modifiers = always
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
csharp_new_line_before_open_brace = all
csharp_indent_labels = flush_left
# BEGIN NAMING
# Naming Rules
# Private fields must be camelCase prefixed with underscore
dotnet_naming_rule.private_members_with_underscore.severity = warning
dotnet_naming_rule_private_members_with_underscore.symbols = private_fields
dotnet_naming_rule.private_members_with_underscore.style = underscore_prefix
# Constant fields must be PascalCase
dotnet_naming_rule.constant_fields_must_be_pascal_case.severity = warning
dotnet_naming_rule.constant_fields_must_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_must_be_pascal_case.style = pascal_case
# Public, internal and protected readonly fields must be PascalCase
dotnet_naming_rule.non_private_readonly_fields_must_be_pascal_case.severity = warning
dotnet_naming_rule.non_private_readonly_fields_must_be_pascal_case.symbols = non_private_readonly_fields
dotnet_naming_rule.non_private_readonly_fields_must_be_pascal_case.style = pascal_case
# Static readonly fields must be PascalCase
dotnet_naming_rule.static_readonly_fields_must_be_pascal_case.severity = warning
dotnet_naming_rule.static_readonly_fields_must_be_pascal_case.symbols = static_readonly_fields
dotnet_naming_rule.static_readonly_fields_must_be_pascal_case.style = pascal_case
# Private readonly fields must be camelCase
dotnet_naming_rule.private_readonly_fields_must_be_camel_case.severity = warning
dotnet_naming_rule.private_readonly_fields_must_be_camel_case.symbols = private_readonly_fields
dotnet_naming_rule.private_readonly_fields_must_be_camel_case.style = underscore_prefix
# Public and internal fields must be PascalCase
dotnet_naming_rule.public_internal_fields_must_be_pascal_case.severity = warning
dotnet_naming_rule.public_internal_fields_must_be_pascal_case.symbols = public_internal_fields
dotnet_naming_rule.public_internal_fields_must_be_pascal_case.style = pascal_case
# Public members must be capitalized
dotnet_naming_rule.public_members_must_be_capitalized.severity = warning
dotnet_naming_rule.public_members_must_be_capitalized.symbols = public_symbols
dotnet_naming_rule.public_members_must_be_capitalized.style = first_upper
# Parameters must be camelCase
dotnet_naming_rule.parameters_must_be_camel_case.severity = warning
dotnet_naming_rule.parameters_must_be_camel_case.symbols = parameters
dotnet_naming_rule.parameters_must_be_camel_case.style = camel_case
# Class, struct, enum and delegates must be PascalCase
dotnet_naming_rule.non_interface_types_must_be_pascal_case.severity = warning
dotnet_naming_rule.non_interface_types_must_be_pascal_case.symbols = non_interface_types
dotnet_naming_rule.non_interface_types_must_be_pascal_case.style = pascal_case
# Interfaces must be PascalCase and start with an 'I'
dotnet_naming_rule.interface_types_must_be_prefixed_with_i.severity = warning
dotnet_naming_rule.interface_types_must_be_prefixed_with_i.symbols = interface_types
dotnet_naming_rule.interface_types_must_be_prefixed_with_i.style = prefix_interface_interface_with_i
# Naming Symbols
# constant_fields - Define constant fields
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const
# non_private_readonly_fields - Define public, internal and protected readonly fields
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, internal, protected
dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
# static_readonly_fields - Define static and readonly fields
dotnet_naming_symbols.static_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.static_readonly_fields.required_modifiers = static, readonly
# public_internal_fields - Define public and internal fields
dotnet_naming_symbols.public_internal_fields.applicable_accessibilities = public, internal
dotnet_naming_symbols.public_internal_fields.applicable_kinds = field
# private_fields - Define private fields
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
# protected_fields - Define protected fields
dotnet_naming_symbols.protected_fields.applicable_kinds = field
dotnet_naming_symbols.protected_fields.applicable_accessibilities = protected
# public_symbols - Define any public symbol
dotnet_naming_symbols.public_symbols.applicable_accessibilities = public, internal, protected, protected_internal
dotnet_naming_symbols.public_symbols.applicable_kinds = method, property, event, delegate
# parameters - Defines any parameter
dotnet_naming_symbols.parameters.applicable_kinds = parameter
# non_interface_types - Defines class, struct, enum and delegate types
dotnet_naming_symbols.non_interface_types.applicable_kinds = class, struct, enum, delegate
# interface_types - Defines interfaces
dotnet_naming_symbols.interface_types.applicable_kinds = interface
# private_readonly_fields - Define private readonly fields
dotnet_naming_symbols.private_readonly_fields.required_modifiers = readonly
dotnet_naming_symbols.private_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.private_readonly_fields.applicable_accessibilities = private
# Naming Styles
# camel_case - Define the camelCase style
dotnet_naming_style.camel_case.capitalization = camel_case
# pascal_case - Define the Pascal_case style
dotnet_naming_style.pascal_case.capitalization = pascal_case
# first_upper - The first character must start with an upper-case character
dotnet_naming_style.first_upper.capitalization = first_word_upper
# underscore_prefix - The first character must be prefixed with an underscore
dotnet_naming_style.underscore_prefix.capitalization = camel_case
dotnet_naming_style.underscore_prefix.required_prefix = _
# prefix_interface_interface_with_i - Interfaces must be PascalCase and the first character of an interface must be an 'I'
dotnet_naming_style.prefix_interface_interface_with_i.capitalization = pascal_case
dotnet_naming_style.prefix_interface_interface_with_i.required_prefix = I
示例:
private bool _thisMember;
上面应该很好,而
private bool ThisMember;
应标记警告。
答案 0 :(得分:1)
如果您仍然没有发现问题,这是您的声明中的错字:
dotnet_naming_rule_private_members_with_underscore.symbols = private_fields
您在“ dotnet_naming_rule”之后加上下划线而不是点。
如果将上面的行更改为下面的行,则应该可以。
dotnet_naming_rule.private_members_with_underscore.symbols = private_fields