On this page following code is suggested to find classes which derive from a given type, but this code does not work because following line
var symbol = _model.GetDeclaredSymbol(node);
returns ISymbol, rather than expected INamedTypeSymbol.
On the answers to FAQs on this page , for getting the type of a variable declaration, following piece of code is suggested. However, this also throws an exception in run-time, saying that cast to ILocalSymbol is not valid.
var type = ((ILocalSymbol)model.GetDeclaredSymbol(variableDeclarator)).Type;
I tried looking into Roslyn source code to figure out a way and tried them but so far no success.
What I would like to do is, detect all classes in a solution which derive from DbContext class of EntityFramework. Can anybody suggest me a way to find this? Thanks in advance!