Getting TypeSyntax from TypeSymbol. Do I really need to re-parse the name?

Viewed 804

I want to get TypeSyntax from TypeSymbol. Based on the answer to the Get TypeSyntax from ITypeSymbol question, my solution is Syntax.ParseTypeName(typeSymbol.ToDisplayString()) which doesn't look good.

Is there a more direct solution?

1 Answers

I am not sure if this is what you are looking for but this works forks for me. I get TypeSyntax of declared method parameter using SyntaxReferences this way:

(Symbol.DeclaringSyntaxReferences.First().GetSyntax() as ParameterSyntax).Type
Related