mardi 12 janvier 2016

Getting type from a symbol in roslyn

What is the best general purpose way to get a System.Type from Microsoft.CodeAnalysis.ISymbol for different types of symbols ? (e.g. class declarations, variable, properties, etc)

I want to be able to do various checks on the type e.g. as checking if the type implements any interface or is cast-able to any interface, just like one can check on System.Type.

The problem I am having is that most of the concrete classes used to represent the symbol are internal (see http://ift.tt/1x4SYbu) and I could not find tye type information in the ISymbol.

  • SourceNamedTypeSymbol
  • LocalSymbol

I retrieve the ISymbol using the following code

var objectSymbol = (ISymbol)model.GetDeclaredSymbol(obj.Node);





Aucun commentaire:

Enregistrer un commentaire