I try make analyser which will detect BaseType IB
from class A
inside list.Add(typeof(A));
. I have A
as IdentifierNameSyntax
but there is not method for getting base IB
. Or exist? Can you help me?
class Consolidator
{
...
public void Warner()
{
list.Add(typeof(A));
}
...
}
class A : IB
{
...
}
In a Roslyn analyzer, you need to use the SemanticModel to bind the thing inside the typeof. Call SemanticModel.GetSymbolInfo() and that'll give you an INamedTypeSymbol. From there you can inspect the base types.