Call Hierarchy : A handy feature in Visual Studio 2010

Suppose we have a solution that contains different dependent projects. We can face 2 most common situation here:

Situation 1: We have a method that we need to change by modifying the definition of that method or just we want to check that which other methods are calling this method.

Situation 2: We have a method that contains so many lines of codes and we need to check that inside this method which all other methods are calling as method is too large and we don’t want to go line by line for this.

Before VS 2010, for situation 1, we need to search the method name in whole solution then we can find the call of this solution in search window but the drawback of this approach is that if you have overloaded methods then in search result all methods will display and you need to take extra care for that.

Now in VS 2010, Microsoft provided a beautiful menu and context command to help these situations. Below are the steps to use these helpful commands:

  1. First you need to open your solution.
  2. Now open the file, where the method is located and needs to be checked.
  3. Go to View > Call Hierarchy
  4. Call Hierarchy window will open on bottom side, in this window choose My Solution from drop down. (You can also choose Current Project, Current Document depending upon your needs.)
  5. Now right click the method name in file opened and click on “View Call Hierarchy” from context menu.
  6. Your Call Hierarchy window will populate with details like Calls To “Method Name” and Calls From “Method Name” you can just expand these nodes and check all the incoming and outgoing call from this particular method.

Enjoy this new feature 🙂