DonNet Code Review using VIsual Studio Code Analysis

Visual Studio Code Analysis is an integrated tool in Visual Studio which can be used for code reviewing the managed code assemblies. It can analyze managed code and gives reports on various improvements needed for the code such as possible design, localization, performance, and security improvements.

Code Analysis is a version of FxCop integrated to visual studio. See more details about FxCop standalone application in this article DonNet Code Review using FxCop.

The advantage of using Code Analysis in Visual Studio over FxCop standalone application is that code analysis settings are inbuilt in the project properties and can be set and checked in to any source code version control software. So that everyone in the development can use the same settings.

The code analysis option is available in Premium and Ultimate editions of Visual Studio 2010 & 2012 and also in Visual Studio 2005 & 2008 Team System.

Steps to enable code analysis option:

  1. In the Visual Studio solution, select a project and right click.
  2. In the right click menu select properties.
  3. In the properties window go to Code Analysis tab.
  4. In the code analysis tab enable the rules which need to be analyzed.
  5. Select the treat warning as errors corresponding to the selected rules so that the code analysis findings can be segregated from the regular warnings.
  6. Save the project.
  7. Do the above steps in all the projects in the solution
  8. Right click the project and select Run Code Analysis. This will build the project and lists the code review issues as errors.
  9. This won’t affect the normal build process. The code analysis will be done only when we run code analysis.
  10. But in case if we need to do the code review on every compilation and throw the review issues as errors, then select the Enable Code Analysis on Build option in the project properties code analysis tab. This option will provide a tight integration and automation of code review, by throwing error in any selected code analysis rule violation.


Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.