Showing the Hierarchy of Method Calls

Visual Studio 2015 offers a window named Call Hierarchy. As its name implies, Call Hierarchy enables you to see the hierarchy of calls to one or more methods. To understand how it works, consider the following code:

Module Module1
  Sub Main()
    DoSomething()
  End Sub
  Sub DoSomething()
    DoSomethingElse()
  End Sub
  Sub DoSomethingElse()
    DoNothing()
  End Sub
  Sub DoNothing()
    '
   End Sub
End Module

This code defines some method, without performing any particular tasks, but it demonstrates a nested hierarchy of method calls. If you right-click the name of one of the methods and then select View Call Hierarchy from the context menu, you can see the method call hierarchy, as shown in Figure 2.40.

Image

FIGURE 2.40 Analyzing method calls with Call Hierarchy.

As you can see in Figure 2.40, the tool shows the first-level hierarchy, but you can also expand method names to see 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 the Call Hierarchy window, the code editor automatically focuses on the method definition.


Call Hierarchy Differences in Visual Studio 2015

If you have had experience with Visual Studio versions 2010 up to 2013, you might notice that in the new release, the tool window does not show calls from methods. The reason is that the Call Hierarchy window is another tool rebuilt on the .NET Compiler Platform, and the migration has not been totally completed yet. Because of this, in Visual Studio 2015, you only have calls to methods, but not from methods. It is reasonable to expect that this will be fixed in future versions.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.126.211