Visual Studio Call Hierarchy View: call it programmatically

夙愿已清 提交于 2021-02-08 08:46:24

问题


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.


回答1:


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 roslyn (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 nrefactory 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.



来源:https://stackoverflow.com/questions/26440055/visual-studio-call-hierarchy-view-call-it-programmatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!