The Best of Visual Studio 2010: Using the Call Hierarchy (C# Only)
Keyboard: CTRL + ALT + K (anywhere); CTRL + K,T (cursor must be on a member name)
Menu: View -> Call Hierarchy
Command: View.CallHierarchy; EditorContextMenus.CodeWindow.ViewCallHierarchy
Versions: 2010
Published: 1/19/2010
Code: vstipTool0005
For the C# folks this is one heck of a great feature: The Call Hierarchy. It allows you to visualize all calls to and from a selected method, property, or constructor. To see how it works just right-click on any method, property, or constructor in the Editor and select View Call Hierarchy:
You should get a window similar to this one (amount of information will vary):
Notice there are "Calls To" and "Calls From" areas related to your selection. You can expand them out:
When you click on a node in the tree, the Call Sites window updates so you can visit the call if you want to:
You can continue expanding the hierarchy to see more "Calls To" and "Calls From" information:
The best part is you can right-click on a symbol and get all kinds of options:
Here are some options you may come across:
Context Menu Item |
Description |
Add As New Root |
Adds the selected node to the tree view pane as a new root node. |
Remove Root |
Removes the selected root node from the tree view pane. This option is available only from a root node. You can also use the Remove Root toolbar button to remove the selected root node. |
Go To Definition |
Runs the Go To Definition command on the selected node. This navigates to the original definition for a method call or variable definition. You can also press F12 to run the Go To Definition command on the selected node. |
Find All References |
Runs the Find All References command on the selected node. This finds all the lines of code in your project that reference a class or member. You can also use SHIFT+F12 to run the Find All References command on the selected node. |
Copy |
Copies the contents of the selected node (but not its subnodes). |
Refresh |
Collapses the selected node so that re-expanding it displays current information. |
Comments
- Anonymous
June 15, 2011
Is possible to run Call Hierarchy from csharp code?