Search code examples
.netreflectionmethodinfo

Get methods and classes referenced by method


Using .NET 4+ Is there any way to find all the methods that are called by all the code paths for a method?

Ideally I'm looking for something that would let me get the inner loop in:

For Each Method In Class
    For Each ReferencedMethod in Method
        Console.PrintLine(Method)
    Next
Next

Failing that, is there a tool that would tell me all the code paths?


Solution

  • The methods that are invoked within a method are not part of the metadata of the method and are therefore not obtainable via reflection. You'll have to parse the IL, or use something like Mono.Cecil to do what you are looking for.