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:
- First you need to open your solution.
- Now open the file, where the method is located and needs to be checked.
- Go to View > Call Hierarchy
- 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.)
- Now right click the method name in file opened and click on “View Call Hierarchy” from context menu.
- 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 🙂