Published: Code Metrics Viewer 2012

I published updates of all my Visual Studio Gallery contributions. Actually, there´s no new functionality in there, just minor changes, a few bug-fixes and updated references to third-party libraries. I changed the names of the tools a bit; “Code Metrics Viewer” has been renamed to “Code Metrics Viewer 2010” and the pre-release of “Code Metrics Viewer 2” is now named “Roslyn Metrics“, which makes more sense since I created the Code Metrics Viewer 2012 extension that integrates the Code Metrics Power Tool 11.0 into Visual Studio 2012.

As I wrote in my last post, the Code Metrics Power Tool 11.0 does not have a setup… but don´t worry (-: After you´ve installed the Code Metrics Viewer 2012 extension, just open the Options dialog, navigate to Code Metrics, than Tools – and click the “Download and Install…”-button. This will download the Power Tool from: http://bit.ly/11b4mqX and extract it to the local FxCop-directory. If you´re interested in how the setup routine works, you can take a look at the code that I published on github…

Code Metrics Viewer 2012 Options Dialog

Code Metrics Power Tool 11.0

Some weeks ago, Microsoft released the Code Metrics Power Tool 11.0 that works together with the latest FxCop binaries of Visual Studio 2012. What a surprise… I did not exptect that they would come up with a new version of the tool, due to the fact that the code metrics analysis feature is now also available in Visual Studio Professional (of course I know it´s intended to be used in an automated build environment). Even though I implemented my own metrics calculator based on the Roslyn September 2012 CTP, I will integrate the Power Tool into the Code Metrics Viewer 2… thinking about to move the experimental Roslyn stuff into a separate package. Will see…

For god´s sake! I would like to know why the Power Tool does not have a user-friendly setup? It is compressed into a self-extracting cabinet file. In my opinion this would be okay, if the package would also contain all dependencies which are required to run the application. This would allow to install it to a directory free of choice. But no, the Metrics.exe binary is tightly coupled to Visual Studio binaries and must be copied to the FxCop directory within the Visual Studio installation folder (at least this is mentioned by the installation instructions on the download page). So, before I do the integration, I need to think about a setup util…

I wrote some sample code that can be used to build a simple setup application: http://bit.ly/10kQMQj

Update, 2013/09/20: The Code Metrics Viewer 2012 extension is now available at: http://bit.ly/19kOHUI.

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.

How to get results for code behind XAML-files

In June, a user reported a problem where he does not see any results for code behind XAML files. I dove into the problem and figured out that code behind XAML files was handled by the power tool like generated code, which I had disabled by default using the /igc switch. The latest version of the tool allows to take control over the switch; if you want to calculate code metrics for generated code you have to make sure, that the /igc option is disabled.

How to get it working?

Before you can use Code Metrics Viewer within Visual Studio 2010, you also need to download and install Code Metrics Power Tool 10.0. The Code Metrics Power Tool 10.0 is a console application which is available at Microsoft. The download can be found at: http://bit.ly/lVH1Aa

The extension comes up with it´s own options page, where you can specifiy the installation path of the Code Metrics Power Tool. Please have a look at the Readme-file provided together with the Code Metrics Power Tool 10.0 to find out the installation folder (might be: <Program Files>\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop). The specified path shall not contain a filename (the extension will add the name of the executable). Consider that there is a difference in the <Program Files> path between 32- and 64-bit versions of Windows.