piter
piter

Reputation: 3

How to get the type constraint list from INamedTypeSymbol

I have a type that comes as INamedTypeSymbol, his definition like this:

    public interface IFoo<TFoo> where TFoo: class
    {
        TFoo Foo{ get; set; }
    }

How can I get the constraint list? (here is: where TFoo: class)

Upvotes: 0

Views: 202

Answers (1)

Jason Malinowski
Jason Malinowski

Reputation: 19021

INamedTypeSymbol has a TypeParameters which will get you to TFoo, that type parameter symbol has various properties (ConstraintTypes, HasReferenceTypeConstraint, etc.) to see what constraints exist.

Upvotes: 1

Related Questions