Reputation: 3689
I'm working on the Code Fix provider for .Net.
I'd like to check method internals, e.g. method statements from IMethodSymbol.
As an example, I have following code on input:
public void DoSomething(string input)
{
if(input == null)
throw new InvalidOperationException("!!!!");
}
On the code-fix side I have IMethodSymbol interface, and there are not ability to get method statements, internal nodes, etc. (I'd like to see 'if', condition into the 'if', exception raising, etc).
How can I get it?
Upvotes: 4
Views: 971
Reputation: 887195
Use the DeclaringSyntaxReferences
property to get the syntax tree defining the method.
Partial methods will have two nodes.
Methods defined in metadata (referenced assemblies) won't have any.
Upvotes: 9