I've added a bunch of nodes to a compilation unit, and now I would like to look up the syntax node corresponding to a given symbol:
var compilation = Compilation.Create("HelloWorld")
.AddSyntaxTrees(SyntaxTree.ParseCompilationUnit("<some namespace>"));
ISymbol symbol = // some arbitrary symbol, e.g. a method whose syntax node I had
compilation.GlobalNamespace.GetNamespaceMembers().First();
SyntaxToken token = ???; // how do I get the token for that symbol?
How do I get the token for that symbol?
My goal is to be able to get the method body for each method from it MethodSymbol
.
Use ISymbol.DeclaringSyntaxReferences
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With