0

In Visual Studio you can display the Call hierarchy of a single function. What I'm looking for is the same functionality but accessible from inside C# code.

Is it possible to use some API's through a self written Visual Studio Plugin? Or can I access some libraries directly to make the code analysis?

It would be enough for me to get the CFG of the program through some static code analysis.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Tarion
  • 16,283
  • 13
  • 71
  • 107
  • Have a look [here](http://www.csharp-examples.net/reflection-callstack/). – Aliostad Apr 04 '12 at 09:38
  • That's probably the best method available, but it doesn't account for inlined methods, so it's not perfect... +1 anyway, because I can't think of a better alternative! – Maximilian Mayerl Apr 04 '12 at 09:42
  • And it's a runtime analysis, I'm looking for a static analysis. – Tarion Apr 04 '12 at 09:58
  • @Tarion how can you do that? Let's imagine you use dependency injection (which most people use now) how can you know which implementation has been configured for the interface hence which method calls are to be run? – Aliostad Apr 04 '12 at 10:01
  • In the end I have a library and want to know where functions on that library are called. As you can see, it works with the Vs integrated "calls hierarchy". I don't need to support all the special cases when someone put my method call into an delegate. – Tarion Apr 04 '12 at 10:50

1 Answers1

0

Found FxCop fits my needs to get the call stack.

It's shipped with VS Professional and Ultimate and part of the windows SDK.

I'm still looking for a full controllflow graph implementation but thats another questions.

Tarion
  • 16,283
  • 13
  • 71
  • 107