visual-studio-2017editorconfig

How to set rules for generic type parameters in VisualStudio?


The picture below shows the warning I keep getting in Visual Studio 2017:

enter image description here

I got this off some website and I have tried all sorts of things. Does anyone know how I can get rid of this?

Here is my the part of my .editorconfig related to naming:

###############################
# 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   = *

Solution

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

    You can get nice set of rules from here.