Matěj Zábský
Matěj Zábský

Reputation: 17272

How do I find an INamedTypeSymbol for an instance of ITypeParameterSymbol?

I want to iterate over parameters of a particular INamedTypeSymbol and recurse into them in the case those type parameters are generic themselves. However I can't do that, because the type parameters are returned as ITypeParameterSymbol and the generic parameters are only available on INamedTypeSymbol.

How do I find an INamedTypeSymbol for an instance of ITypeParameterSymbol?

Upvotes: 3

Views: 516

Answers (1)

SLaks
SLaks

Reputation: 887509

You want TypeArguments, not TypeParameters.

TypeParameters returns the declared type parameters of the member declaration (the open/unconstructed generic type). These are never named types.

TypeArguments returns the types that have been substituted (if the type is a closed/constructed type).

Upvotes: 6

Related Questions