visual-studio-2017 - 如何在 Visual Studio 中为泛型类型参数设置规则?

标签 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   = *

最佳答案

# 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 .

关于visual-studio-2017 - 如何在 Visual Studio 中为泛型类型参数设置规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53866200/

相关文章:

editorconfig - 可以忽略/排除来自.editorconfig的文件/文件夹吗?

c# - ReSharper 似乎不尊重 .editorconfig

f# - 加载不在当前目录中的 F# 模块

xaml - 如何使用 Xamarin.Forms xaml 编辑器预览 ListView

c# - asp.net 从查询中获取数据

c# - 如何强制 visual studio 使用小写类型生成属性(例如,字符串而不是字符串)

visual-studio-code - Omnisharp/VS Code 中不考虑 .editorconfig 的设置

visual-studio-2017 - 如何卸载Visual Studio 2017更新15.3

c++ - 多个错误,在 VS2017 中的头文件中,opengl 项目 C++