Visual Studio Extension for displaying Call Hierarchy RRS feed

  • Question

  • Hiya, 


    I'm trying to create an extension that graphically displays the calls to and from methods in a c# class. In some ways I want to create a graphical display of the call hierarchy results for all the methods on a page. I'm wondering what the best way of doing this will be. I can easily parse the CodeFunctions on a document using the EnvDTE, but beyond that I'm direction-less. Is it possible to exploit VS's inbuilt call hierarchy code? I've seen some reference to the ICallHierarchy service, but I can't find any examples of how to grab that service? Obviously I'm trying to avoid writing my own c# parser to lift method calls out of the CodeFunction. 


    Hope someone can help.





    Sunday, June 20, 2010 3:11 PM

All replies

  • Hi,


    I know the anwser about this:

    >but I can't find any examples of how to grab that service

    its easy,but only display the result in "CallHierarchy" tool window.

    1.Open the [Package Manager Console]

    2.Run the command below

    Install-Package VSSDK.Language.CallHierarchy.12 -version 12.0.4

    then you will be able to  add [using] of the namespace and get the service like this:

    ICallHierarchy svs = Package.GetGlobalService(typeof(SCallHierarchy)) as ICallHierarchy;

    using the instance of the ICallHierarchy service, 

    only could call [ShowToolWindow()]  and  [AddRootItem()]


    that was not what you want right?

    Did you figured out this problem?

    If so, could you share me the solution please.

    Thursday, June 29, 2017 6:03 AM
  • use the ICallHierarchy service could show the call hierarchy tool window,

    besides , there is another way to show call hierarchy.

    DTE2 dte = (DTE2)Package.GetGlobalService(typeof(DTE));
    var doc = dte.ActiveDocument;
    if (doc == null)
    doc.Activate();    // ★this is important
    // then you could
    // or

    Tuesday, July 4, 2017 5:21 AM