Code Metrics – Calculating Metrics

Windows: Alt, N, M (selected projects); Alt, N, L (solution); Alt, V, E, M, M, M, Enter (results)

Menu: Analyze | Calculate Code Metrics For Selected Projects; Analyze | Calculate Code Metrics For Solution; View | Other Windows | Code Metric Results

Command: Analyze.CalculateCodeMetricsforSelectedProjects; Analyze.CalculateCodeMetricsforSolution; Analyze.CancelCodeMetricsCalculation; View.CodeMetricsResults

SKU: Premium, Ultimate

Versions: 2008, 2010

Code: vstipTool0129


During my many Visual Studio tours to visit customers with my good friend Clint Edmonson, we discovered that a lot of people apparently didn’t know they had access to code metrics. So, that begs the question, what are code metrics and why should you care?


According to Wikipedia:

“A software metric is a measure of some property of a piece of software or its specifications. Since quantitative measurements are essential in all sciences, there is a continuous effort by computer science practitioners and theoreticians to bring similar approaches to software development. The goal is obtaining objective, reproducible and quantifiable measurements, which may have numerous valuable applications in schedule and budget planning, cost estimation, quality assurance testing, software debugging, software performance optimization, and optimal personnel task assignments.”


Specifically, for our feature, referred to as code metrics, we say this:

“Code metrics is a set of software measures that provide developers better insight into the code they are developing. By taking advantage of code metrics, developers can understand which types and/or methods should be reworked or more thoroughly tested. Development teams can identify potential risks, understand the current state of a project, and track progress during software development.”


Code metrics essentially allows us to view, at a high level, data about our code. By reviewing this data, we can make qualitative decisions about areas that could be of concern and require additional examination. We often refer to this as looking for code smells (


Calculating Code Metrics

You can calculate code metrics for one project, multiple projects, or an entire solution. The scope is often determined by the size of your solution. With larger solutions you may want to calculate metrics for one or more projects to narrow down the scope where issues might occur.



Single Project

Calculating code metrics for a single project is straightforward. Make sure the project (or any item in the project) is selected in Solution Explorer. Then go to Analyze | Calculate Code Metrics For <Project Name>:




Multiple Projects

When you want to calculate code metrics for more than one project, you can CTRL + Left Click the projects in Solution Explorer:



Go to Analyze | Calculate Code Metrics For Selected Project(s):




Entire Solution

Calculating code metrics for an entire solution is simply a matter of going to Analyze | Calculate Code Metrics for Solution. Also, the Code Metrics Results window (View | Other Windows | Code Metrics Results) has a button that will calculate the metrics for the entire solution:



Special Note

As you use code metrics, you may receive the following message:  “One or more projects were skipped. Code metrics are available only for C#, Visual Basic, and C++/CLI projects that are not Web Site projects.”  This is fairly self explanatory and should be taken into account when calculating code metrics. 

Comments (8)

  1. Hanii Puppy says:

    I don't have an "Analyze" (Analyse?) menu.

  2. zainnab says:


    This feature is only available in Premium and Ultimate versions of VS.


  3. Vlad says:

    Hi, regarding your special note, “One or more projects were skipped. Code metrics are available only for C#, Visual Basic, and C++/CLI projects that are not Web Site projects.”… I use to not get this message, now I randomly do. I looked and running metrics on the entire solution works (no projects are excluded), but I still get that error and when I click on it… it isn't linked to anything (i.e. "No source available"). Any ideas?

  4. Pal says:


    Did you get the solution of your prob? I'm also facing the same problem. Please let me know if you have the solution.

  5. zainnab says:

    Vlad / Pal,

    Are you getting all the metrics but it is just giving you an error or are metrics missing?


  6. Pal says:

    I am getting the metrics for other projects in the solution except the website project.  

  7. zainnab says:

    Hey Pal 🙂

    You can calculate metrics for web application projects but not website projects unfortunately.


  8. Rick says:

    I'm getting the same error running Metrics 10.0 against a VS 2010 Solution that contains two C# class library projects and a C# Web Application project. I tried running against just one of the class library project files ("BusinessLayer.csproj") and received the same error.

Skip to main content