SingleTypeParameter

SingleTypeParameter

Summary

Use T as a type parameter name if the type parameter is single.

Default severity

Warning

Description

Names of Classes, Structs, and Interfaces [1] is quoted as follows:

Names of Generic Type Parameters

  • ✓ Consider using T as the type parameter name for types with one single-letter type parameter.

Code fix

The code fix provides an option replacing the type parameter name with T.

Example

Diagnostic

public sealed class Code<Type>
{
    public Code(Type instance)
    {
        Instance = instance;
    }

    public Type Instance { get; }
}

Code fix

public sealed class Code<T>
{
    public Code(T instance)
    {
        Instance = instance;
    }

    public T Instance { get; }
}

References

[1] Microsoft, .NET Framework Design Guidelines