Call Hierarchy Navigation in Visual Studio 2010

Call Hierarchy Navigation in Visual Studio 2010

Rate This
  • Comments 31

We're currently designing a new IDE feature named Call Hierarchy. Essentially, it allows you to find places where a given method is called, which is similar to how Find All References currently works. However, unlike Find All References, the Call Hierarchy feature provides more deep understanding and more detailed information about calls.


You can invoke the Call Hierarchy toolwindow by right-clicking on a method, property or constructor name in the code editor and choosing View Call Hierarchy from the context menu:


Tool window

A toolwindow will appear docked on the bottom of the Visual Studio window:


You can expand the node for the method to see information about it: incoming calls to the method ("Calls To") and outgoing calls ("Calls From"):


Here's how it works. A method (or a property, or a constructor) is displayed as a root in the treeview. You can expand the node to get a list of "search categories" - things you want to find. Four search categories are currently supported:

  1. Calls To - "incoming" calls to this member
  2. Calls From - "outgoing" calls mentioned in this member's body
  3. Overrides - available only for abstract or virtual members
  4. Implements - finds places where an interface member is implemented

When you expand a search node (such as Calls To 'GetCallableMethods'), a solution-wide search is started in the background and the results appear under the Calls To folder. You can click on a result, and the details will appear in the Details list view on the right hand side.

The Details list view shows all the exact call sites and locations in code where GetCallableMethods is called from GenerateXsdForComplexTypes. We see that the method is being called only once, the line of code is shown, as well as file name and position in the file. Double-clicking on that call site will navigate to it in the code editor.

The advantages of Call Hierarchy compared to Find All References is that it allows you to explore and drill deep multiple levels into the call graph (find caller's caller etc.) Also, Call Hierarchy has deeper and more fine-granular understanding of the source code - while Find All References just finds the symbols, Call Hierarchy differentiates abstract and virtual methods, interface implementations, actual calls from delegate creation expressions, etc. Also it works like a scratch-pad: you can add any member as another root-level item in the call hierarchy tool window and have several members displayed there at once. Finally, the Details Pane given information about the concrete call sites, if a method is being called several times in the body of the calling method.


In the toolbar you can select the scope of the search: search in currently opened file only, current project or the entire solution.

Refresh button re-fills the treeview in case the original source code was modified.

If a root node of the treeview is selected, the "Delete Root" button will remove it from the treeview. You can add any member as a new root in the treeview by right-clicking on it in the context menu:


or adding it from the source code as described in the beginning.

Finally, the Toggle Details Pane button shows or hides the details pane.

Some design issues and implementation details

Although the feature is already implemented and if you have the Visual Studio 2010 CTP, you can already play with Call Hierarchy, we're still not quite happy with the current UI design, usability and the user experience.

For example, one issue that we're seeing is that it takes 2 mouseclicks and 2 mousemoves to invoke the Find All References search, but it takes 4 mouseclicks and 4 mousemoves to get the callers list for a given method (1 click - menu invocation, 1 click - menu item selection, 1 click - expand the treeview node for the method, 1 click - expand the "Calls To" folder). Although the search itself will be slightly faster than Find All References, the perceived complexity of invoking the feature is something we definitely want to improve. We want this feature to be at least as good and usable as Find All References, but also provide additional benefits, otherwise people will just not use the feature and continue using Find All References.

I think I'll stop for now and see what kind of feedback you guys might have about this. In the next blog post I plan to share more of our current thinking and what we'd like to change. For now, I'd be really interested to know what you think and if you have any suggestions or ideas. Now it's not too late, and we can change the feature based on your feedback.

  • This looks awesome.  I've been waiting for this for years - it's unbelievable how much time I waste on "Find All References" when multiple things call multiple things which call what I'm looking for.

    Can't wait for VS2010.

  • I have used something similar to this feature in Eclipse, but lately with so many frameworks relying on XML configs and reflection, this feature is becoming less useful. Nevertheless, I would love to see this in VS.

  • You didn't mention anything about keyboard shortcuts for Call Hierarchy. Keyboard usage is a crucial aspect of such tools. I can invoke Find All References by pressing SHIFT-F12, and move through references using F8, very convenient. The new feature must be as least as easy to use as this. Better still to keep the same key bindings, so we don't have to get used to new ones.

    Perhaps the most common use case of Call Hierarchy can be covered by these keys, with ALL other use cases covered by other keys. Reaching for the mouse is a pain, especially when working on a laptop.

  • Yess! Since my acquaintance with VS 6.0 I was wondering why MS didn't have such an obviously useful feature.

  • Very nice feature - love it!

    Regarding your concern about extra mouse clicks/moves to get the same results as in "Find All References": immediate solution that comes to mind is for the Call Hierarchy operation to highlight the "Calls To" node automatically to display all callers of the method as the default outcome.

    How about another category  - "Subscribes", if the "Calls To" is invoked on an event? This is also kind of a call, isn't it?

  • Welcome to the 48th Community Convergence. The C# team continues to work hard to get out the next version

  • This is like the analyze feature in reflector :)

  • How could I use the call tree explorer tool to find functions declared in one class that are only used in another class?

    Same question but how to find functions that are declared in one file and only called from a single other file.

    Generally, I'd like to be able to reorganize a project and its classes so that

     a) Functions only called from one class but are declared outside that class can be moved into that class and made private (if it makes sense)

     b) Functions are organized into source code files to minimize the number of cross file function calls (when it makes sense)

    I try to make most all functions static without side effects since it is much much easier when dealing with legacy code to modify a static function rather than one that is not static (i.e, because you do not have to worry about object state with a static function since it has not object state).  this makes it easier to refactor since a function without side effects can be moved from one class to another or one source code file to another without any long, detailed analysis needed.

  • Thanks everyone for your feedback! I will post another post shortly.

  • Sorry, but on

    the images dissapeared.

  • They're back! Was probably an intermittent server issue.

  • [A quick reminder, Call Hierarchy is a new IDE feature in VS 2010] In the comments to the previous post

  • Tom: thanks a lot for the feedback about keyboard navigation. We hope to add the support for F8/Shift+F8 before we ship.

    Right now we support Ctrl+Alt+K to set focus to the Call Hierarchy toolwindow, and once you're inside, arrow keys do the navigation, F12 or Return on a member will go back to the editor.

  • Hello everyone, My name is Raman Sharma and I am a PM on the VC++ IDE team. I want to talk about a new

  • Feature looks cool... It would be nice if one could perform a query like "Find all functions in solution that have no callers" or exactly one, etc. We have some legacy code and it would be nice to quickly sort out the dead methods and remove them- I suspect there are hundreds if not thousands in one area of our code base...

Page 1 of 3 (31 items) 123
Leave a Comment
  • Please add 5 and 4 and type the answer here:
  • Post