This documentation is archived and is not being maintained.

Code Analysis for Managed Code Overview

Code analysis for managed code tool analyzes managed assemblies and reports information about the assemblies, such as violations of the programming and design rules set forth in the Microsoft .NET Framework Design Guidelines.

The analysis tool represents the checks it performs during an analysis as warnings. Warning messages identify any relevant programming and design issues and, when possible, supply information about how to fix the problem.

To make it convenient for developers to use the analysis tool, developers can select Enable Code Analysis on the project's Property Pages.

Additional options for including or excluding rules and treating rules as warnings or errors can also be accessed from property pages. When the tool is enabled, during the build process, it reports warnings in the Error List.

It is often useful to indicate that a warning is non-applicable; this informs the developer, and others who might review the code later, that a warning was investigated and then either suppressed or ignored.

In Source Suppression of warnings is implemented through custom attributes. To suppress a warning, add the attribute SuppressMessage to the source code as shown in the following example:

[SuppressMessage("AdventureWorks.Rules", "AW14441")]

Public class MyClass


    // code


For more information, see Suppress Warnings Using SuppressMessage Attribute.

As an organization, you might want to require that all check-ins satisfy certain policies. In particular, you want to make sure that you follow these policies:

  • There were no build errors in code being checked in.

  • Code analysis was run as part of the most recent build.

You can accomplish this by specifying check-in policies. For more information, see How to: Add Check-In Policies.

You can use the integrated features of the build system to run the analysis tool as part of the build process. For more information, see Team Foundation Build Overview.