C# 编辑配置VS的命名';我不能在VS2017工作

C# 编辑配置VS的命名';我不能在VS2017工作,c#,visual-studio,editorconfig,C#,Visual Studio,Editorconfig,我尝试使用.editorconfig,新的VS特性来设置我自己的代码样式。 但有一部分不起作用。我听说Roslyn的bug,处理命名风格,但我不知道问题出在哪里。 我的.editorconfig: root = true ################################# # .NET Coding Conventions # ################################# [*.cs] # Code files indent_style = t

我尝试使用.editorconfig,新的VS特性来设置我自己的代码样式。 但有一部分不起作用。我听说Roslyn的bug,处理命名风格,但我不知道问题出在哪里。 我的.editorconfig:

root = true

#################################
#   .NET Coding Conventions     #
#################################
[*.cs]
# Code files
indent_style = tab
insert_final_newline = true
charset = utf-8-bom

# this. preferences
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning

# Language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
dotnet_style_predefined_type_for_member_access = true:warning

# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:warning
dotnet_style_readonly_field = true:suggestion

# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:warning
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning

# Null checking preferences
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion

# Implicit and explicit types
###############
csharp_style_var_when_type_is_apparent = true:warning
csharp_style_var_elsewhere = false:none

# Expression-bodied members
csharp_style_expression_bodied_methods = when_on_single_line:none
csharp_style_expression_bodied_constructors = when_on_single_line:none
csharp_style_expression_bodied_operators = when_on_single_line:none
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion

# Pattern matching C# 7.0+
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
csharp_style_pattern_matching_over_as_with_null_check = true:warning

# Inlined variable declarations C# 7.0+
csharp_style_inlined_variable_declaration = true:warning

# Expression-level preferences C# 7.0+
csharp_prefer_simple_default_expression = true:warning
csharp_style_deconstructed_variable_declaration = true:warning
csharp_style_pattern_local_over_anonymous_function = true:suggestion

# Null checking preferences
csharp_style_throw_expression = true:warning
csharp_style_conditional_delegate_call = true:warning

# Code block preferences
csharp_prefer_braces =true:none

# Organize usings
dotnet_sort_system_directives_first = true

# Newline options
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true

#Indentation options
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = no_change

#Spacing options
csharp_space_after_cast = true
csharp_space_after_keywords_in_control_flow_statements = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
#csharp_space_between_parentheses
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false

#Wrapping options
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true

# Naming
# Common rule
dotnet_naming_rule.members_and_types_common_name.symbols = members_and_types_identifier
dotnet_naming_rule.members_and_types_common_name.style = pascal_case_style
dotnet_naming_rule.members_and_types_common_name.severity = error

dotnet_naming_symbols.members_and_types_identifier.applicable_kinds = class,struct,interface,enum,property,method,field,event,delegate
dotnet_naming_symbols.members_and_types_identifier.applicable_accessibilities = *
dotnet_naming_symbols.members_and_types_identifier.required_modifiers =

dotnet_naming_style.pascal_case_style.required_prefix = 
dotnet_naming_style.pascal_case_style.required_suffix =
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
dotnet_naming_style.pascal_case_style.word_separator = 

# Async methods should have "Async" suffix
dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods
dotnet_naming_rule.async_methods_end_in_async.style = end_in_async
dotnet_naming_rule.async_methods_end_in_async.severity = error

dotnet_naming_symbols.any_async_methods.applicable_kinds = method
dotnet_naming_symbols.any_async_methods.applicable_accessibilities = *
dotnet_naming_symbols.any_async_methods.required_modifiers = async

dotnet_naming_style.end_in_async.required_prefix = 
dotnet_naming_style.end_in_async.required_suffix = Async
dotnet_naming_style.end_in_async.capitalization = pascal_case
dotnet_naming_style.end_in_async.word_separator = 

csharp_style_var_for_built_in_types = true:error

# Interfaces
dotnet_naming_rule.interface_i_prefix.symbols           = interfaces_identifier
dotnet_naming_rule.interface_i_prefix.style             = i_prefix_style
dotnet_naming_rule.interface_i_prefix.severity          = error

dotnet_naming_symbols.interfaces_identifier.applicable_kinds = interface
dotnet_naming_style.i_prefix_style.capitalization            = pascal_case
dotnet_naming_style.i_prefix_style.required_prefix           = _

# Parameter
dotnet_naming_rule.parameters_in_camel.symbols  = parameters_identifier
dotnet_naming_rule.parameters_in_camel.style    = camel_case_style
dotnet_naming_rule.parameters_in_camel.severity = error

dotnet_naming_symbols.parameters_identifier.applicable_kinds  = parameter
dotnet_naming_style.camel_case_style.capitalization           = camel_case
请看“#命名”部分和下面的屏幕截图。 正如您所看到的,“#通用规则”和“用于内置类型的csharp_样式_var_”在第17行和第21行中起到了很好的作用。 但是“#Async方法应该有“Async”后缀”,“#接口”和参数不起作用(第19、13和30行)

这是因为

在.editorconfig文件中,命名约定应按从最特定到最不特定的顺序排列。遇到的第一个可以应用的规则是唯一应用的规则

参考:

因此,在
DisplayResultAync
的情况下,匹配并应用
members\u和\u types\u common\u name
规则,并跳过其余命名规则。解决方法是简单地改变顺序。在这种情况下,看起来您应该将“通用规则”放在最后