Accessing IMethodDeclaration objects via ReSharper SDK

130 Views Asked by At

I have in hand an INamespaceBody, IClassDeclaration, and IMethod. I want to get the IMethodDeclaration corresponding to the IMethod and the IClassBody corresponding to the IClassDeclaration. But I am totally at a loss...how can I achieve this?

1

There are 1 best solutions below

0
On

You can call the GetDeclarations() method on the given IMethod to get IMethodDeclaration

IMethod method = MyGetMethod(); // Your code to get the IMethod.
// This returns a list of IDeclaration
var declaration = main.GetDeclarations();
IMethodDeclaration methodDeclaration = declaration[0];

As for getting IClassBody from an IClassDeclaration, just call the Body property.