Using code analysis in Visual Studio 2013

Visual Studio code analysis checks if your code is following programming standards. If you are a beginner developer you might have not even known coding standards exists.

Code Analysis tools in Visual Studio Premium and Visual Studio Ultimate enable developers to check their code for quality issues as they write it.

– Microsoft Documentation

By default Visual Studio only checks for warnings and build errors and does not do code analysis while building.  The reason being, code analysis takes time. The bigger the application the longer it will take. So rather than doing a code analysis on ever build you can do it once in a while. Following coding standards is not necessary, but is really encouraged.

There are multiple ways to run code analysis. Here are some.

Run on every build:

Right click your project and select Properties, then under code analysis enable the “Enable Code Analysis on Build” check box.

Codeanalysis

Run Code Analysis Once:

With you project selected, select “Run Code Analysis on {ProjectName}” from the “Analyze” dropdown in the toolbar.

CodeAnalysis2

Here are some guidelines for using the code analysis tool:

  • Read up on the different warning types.
  • Analyze code often. Depending on the code analysis results you get, waiting till the end might not always be the best idea.
  • Always have warnings enabled on your project.
  • Works towards fixing warnings also, and not just the build errors.
Bookmark and Share

Leave a Reply

Your email address will not be published. Required fields are marked *