Getting System.Type from TypeSymbol in roslyn analyzer

Viewed 185

I want to create a diagnostic analyzer to check if a class can be instantiated. I have my class declaration and I'm trying to use Activator.CreateInstance(parameter) but this needs System.Type as its parameter. Is it possible to achieve this in Roslyn?

ClassDeclarationSyntax classSyntax = context.Node as ClassDeclarationSyntax; INamedTypeSymbol type = context.SemanticModel.GetDeclaredSymbol(classSyntax) as INamedTypeSymbol; Activator.CreateInstance(?);

0 Answers
Related