Home > Articles > Programming > Visual Studio

  • Print
  • + Share This
This chapter is from the book

Showing the Hierarchy of Method Calls

Visual Studio 2012 brings to Visual Basic a tool window named Call Hierarchy, which was already introduced for Visual C# in Visual Studio 2010. As its name implies, Call Hierarchy enables the showing of the hierarchy of calls to and from one or more methods. To understand how it works, let’s consider the following code:

Module Module1

  Sub Main()
  End Sub

  Sub DoSomething()
  End Sub

  Sub DoSomethingElse()
  End Sub

  Sub DoNothing()
   End Sub

End Module

The code defines some method, without performing any particular tasks, but it demonstrates a nested hierarchy of method calls. If you right-click one of the method’s names and then select View Call Hierarchy from the pop-up menu, you will be able to see the method call hierarchy as demonstrated in Figure 2.38.

Figure 2.38

Figure 2.38. Analyzing method calls with Call Hierarchy.

As you can see from Figure 2.38, the tool shows the first level hierarchy, but you can also expand method names to show the full hierarchy, including nested method calls. On the right side of the window is the line number in the code file where the selected method is defined. Also, if you double-click a method name in Call Hierarchy, the code editor will automatically focus on the method definition.

  • + Share This
  • 🔖 Save To Your Account