Rekkonnect / GenericsAnalyzer

A Roslyn analyzer for C# for generic types and functions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Base type parameter usage is misinterpreted

Rekkonnect opened this issue · comments

commented

The feature revolving around presence of InheritBaseTypeUsageConstraintsAttribute in a type parameter does not properly evaluate the usage of the marked type parameter in the inherited types' type arguments.

In fact, what this would do is inherit the type constraints system from type parameters in the base type whose names matched the marked one's. This means that in the following example:

class A
<
    T,
    U,
    V,
    W
>

class B
<
    [InheritBaseTypeUsageConstraints]
    U,
    [InheritBaseTypeUsageConstraints]
    V,
    [InheritBaseTypeUsageConstraints]
    T
>
    : A<U, V, T, V>
  • B.U would inherit from A.U
  • B.V would inherit from A.V
  • B.T would inherit from A.T

when instead the following should happen:

  • B.U should inherit from A.T
  • B.V should inherit from A.U and A.W
  • B.T should inherit from A.V

This bug is being fixed in #33; the test case for GA0001 has been updated to properly reflect this fix