1

In a VSpackage, is there a way to programmatically call, on a method, the "call hierarchy view" from code and access (even from code) to its results?

For completeness: VSpackage target is Visual Studio 2013.

Update
The final aim is to find how many times a given method (given its namespace and class) is used/called inside the opened solution.

Lando
  • 103
  • 1
  • 9

1 Answers1

2

I'm going to say no. The reason is the "call hierarchy view" isn't going to expose it's data set directly. Instead you'd be better served going after the data set directly. You can use (the new C# compiler) to get this information. See: How to use C# to find usages of a class or method?

Alternatively, you could also use to the same end. There is a tutorial on Code Project that shows how to use it: http://www.codeproject.com/Articles/408663/Using-NRefactory-for-analyzing-Csharp-code

Or if you just want to see how many times code is accessed in the IDE, you can upgrade to Visual Studio 2013 Ultimate and use Code Lens: http://blogs.msdn.com/b/zainnab/archive/2013/07/09/visual-studio-2013-preview-codelens-aka-code-information-indicators.aspx.

Community
  • 1
  • 1
Philip Pittle
  • 11,821
  • 8
  • 59
  • 123
  • Latest suggestion is not applicable since my VSPackage needs this info for further code analysis. Never heard about nrefactory (it seems good). Roslyn is good. I'm using it in another project as Nuget library. The problem with it, for what I could understand, is that you actually need to use Visual Studio 2014 (which is still CTP) in order to work with workspaces. – Lando Oct 18 '14 at 17:35