如何在Visual Studio中为通用类型参数设置规则?

时间:2018-12-20 09:54:51

标签: visual-studio-2017 editorconfig

下图显示了我不断在Visual Studio 2017中收到的警告:

enter image description here

我从某个网站上获得了此权限,并且尝试了各种方法。有谁知道我该如何摆脱?

这是我的.editorconfig中与命名有关的部分:

###############################
# Naming Conventions          #
###############################

# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization               = pascal_case

dotnet_naming_style.camel_case_style.capitalization                = camel_case

dotnet_naming_style.I_prefix_style.required_prefix                 = I
dotnet_naming_style.I_prefix_style.capitalization                  = pascal_case

# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity  = warning
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols   = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style     = pascal_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

# Use PascalCase for public fields
dotnet_naming_rule.pascal_case_for_public_fields.severity          = warning
dotnet_naming_rule.pascal_case_for_public_fields.symbols           = public_fields
dotnet_naming_rule.pascal_case_for_public_fields.style             = pascal_case_style
dotnet_naming_symbols.public_fields.applicable_kinds               = field
dotnet_naming_symbols.public_fields.applicable_accessibilities     = public

# Interfaces must be PascalCase and have an I prefix
dotnet_naming_rule.interfaces_start_with_I.severity                = warning
dotnet_naming_rule.interfaces_start_with_I.symbols                 = any_interface
dotnet_naming_rule.interfaces_start_with_I.style                   = I_prefix_style
dotnet_naming_symbols.any_interface.applicable_accessibilities     = *
dotnet_naming_symbols.any_interface.applicable_kinds               = interface

# Classes, structs, methods, enums, events, properties, namespaces, delegates must be PascalCase
dotnet_naming_rule.general_naming.severity                         = warning
dotnet_naming_rule.general_naming.symbols                          = general
dotnet_naming_rule.general_naming.style                            = pascal_case_style
dotnet_naming_symbols.general.applicable_kinds                     = class,struct,enum,property,method,event,namespace,delegate
dotnet_naming_symbols.general.applicable_accessibilities           = *

# Everything else is camelCase
dotnet_naming_rule.everything_else_naming.severity                 = warning
dotnet_naming_rule.everything_else_naming.symbols                  = everything_else
dotnet_naming_rule.everything_else_naming.style                    = camel_case_style
dotnet_naming_symbols.everything_else.applicable_kinds             = *
dotnet_naming_symbols.everything_else.applicable_accessibilities   = *

1 个答案:

答案 0 :(得分:1)

# prefix_type_parameters_with_t_style - Generic Type Parameters must be PascalCase and the first character must be a 'T'
dotnet_naming_style.prefix_type_parameters_with_t_style.capitalization = pascal_case
dotnet_naming_style.prefix_type_parameters_with_t_style.required_prefix = T

您可以获得一套不错的规则from here