Sunday, November 30, 2008

VS.NET 2010 - Call Hierarchy

Every day I use the splendid VS.NET add-in called ReSharper in the development routine. This tool greatly reduces the amount of efforts that are needed to find the syntax errors in the code, refactor the code, search various entities of the code, etc. etc. I don't realize how I can code without using ReSharper.
One of the pretty useful features of R# is "Find usages..." functionality. Right click on the method, property, constructor, type, etc., then select "Find Usages" or "Find Usages Advanced..." and R# shows you the points of code where the selected entity is used. You can find the derived classes of some base type or the implementations of some interface, etc. etc. This is really great feature and it has a lot of options...Now I realize that this feature and R# doesn't provide another brilliant option...
So, sometimes I need to analyze
the convoluted and very complex code to figure out how it works to find the possible flaws or realize the possible solution for the newly required features. Say I am interested in some method("A" method), I want to figure out it's place in the the flow of code execution. If I don't want to debug the code I usually use Find Usages feature if R#. I find the usages of the method A. Let's say method A is called by methods B and C. This fact isn't very informative. Then I need to find the usages of the methods B and C, etc. etc. Then I need to realize the entire picture of the place of method A in the flow of the code execution based on the list of usages of the related methods and believe me, this is not pretty straightforward in the complex code(or I am just retard:))
Anyway, VS.NET 2010 introduced the new feature called Call Hierarchy and this is exactly what I needed for more productive and quick code analysis in the complex projects! Right-click on the method, property, constructor or indexer then select "View call hierarchy" and Visual Studio shows you the entire picture of the selected entity place in the flow of the code execution. It shows the calls to "method A" that I referred to in the previous paragraph and calls from "method A". For every calling or called method VS shows it's invokers and invoked methods. You can navigate to calling or called methods and change the scope of call hierarchy analysis! Here is the screen shot of the call hierarchy of the piece of the code of one of my projects:


I am impressed by this new feature and undoubtedly I will use it every day once the standalone version of VS.NET 2010(outside of virtual machine) is released :)

No comments:

Post a Comment