Is it possible to compare metric results?

Yes, it is! The latest version of the extension has basic comparison functionality. I thought this could be very helpful, if one would use the extension during code review and/or refactoring. When I used the tool during re-factoring, I had the problem that it was hard to see, if values were getting better or worser. So, I thought it would be nice to load a previously calculated report and compare the data against the latest results, to be able to show some kind of “trend” within the grid. This is one of the features I wanted to wait with until end of this summer, because there is still some work to do… in other words, by now it´s not perfect :-) In some situation the comparison might not work…

I calculated metrics for a very simple console application… Here you can see the Main()-method of the static Program-class, which has a maintainability index of 57. Of course, this is still okay, but it could be better…

So, I made some refactorings to the Program-class… I created two new methods named ExtractPublicKey() and WriteKeyFile, recompiled the assembly and calculated the metrics again…

Now I can use the compare feature, to see if I made some “good” progress :-) As you can see in the screenshot, there is a new button named “Compare…” in the toolbar. If you press that button, a file dialog will show up, where you can select the candidate report for comparison. If you want to work with the compare feature I recommend to enable the auto-save functionality in the options dialog – so, a new report will be stored in the solution folder, each time you calculate code metrics.

In my example I have choosen the report, which was calculated before I did the refactorings – and I see, that the maintainability index increased by 7.

By the way… if you like the tool, I would be glad if you would rate the tool with five-stars in the Visual Studio Gallery :-)

Calculated results can be kept for further analysis

In accordance to the test tools for Visual Studio Professional, the extension stores a compound report containing all calculated results of the solution in a folder named “MetricResults” below the solution directory. The output path can be changed in the “Reports” options page. The output path can either be a relative or an absolute path, but Visual Studio macro´s are not supported. The “Auto-Save”-feature is enabled by default. So, each time a report is calculated it will be stored in the configured output directory. The number of automatically saved reports can be limited, so the extension will only keep the latest results – the default value is 25. If you set the limit to zero, all reports will be kept; nothing will be deleted.

The /directory-option is now supported

If you have missed support for the /directory-option of the Power Tool, then the latest version (v1.3.7) might make you happy. Code Metrics Viewer allows you now to specifiy a directoy location, which can be used by the Power Tool to search for assembly dependencies.

The option can be enabled per project; all you need to do is to add a custom property to the project file; you should already be familiar with the basics of MSBuild, because I will not explain it here… Open the project file in the editor (or notepad) and add the following property-group to the contents of your project file(s) and customize the path.


<PropertyGroup>
 <CodeMetricsDependencyDirectory
   Condition="'$(CodeMetricsDependencyDirectory)' == ''"> Your path goes here </CodeMetricsDependencyDirectory>
</PropertyGroup>

That´s it. Code Metrics Viewer will look for that property, when you analyze the solution.