How to: Enable and Disable Specific Managed Code Analysis Warnings

The managed code analysis tool allows you to select specific warnings from within the integrated development environment (IDE). This ease of use allows you to enforce only warnings that best meet your project needs. You can either choose a group of warnings or individual ones in a particular group.

Important noteImportant Note:

Avoid shipping release builds with code analysis enabled because enabling code analysis defines the CODE_ANALYSIS constant. This causes the SuppressMessage attributes to be emitted in the binaries and impacts performance.

To enable a specific managed code analysis warning

  1. Select a project in Solution Explorer.

  2. On the Project menu, click <project name> Properties.

  3. Click Code Analysis.

  4. Select Enable Code Analysis on Build (defines CODE_ANALYSIS constant).

  5. Expand a rule node.

  6. Enable the specific warning by selecting the warning check box.

  7. To treat the warning as an error, select the adjacent box in the Treat Warning as Error column.

To disable a specific managed code analysis warning

  1. Select a project in Solution Explorer.

  2. On the Project menu, click <project name> Properties.

  3. Click Code Analysis.

  4. Expand a rule node.

  5. Disable the specific warning by clearing the warning check box.

See Also

Concepts

Guidelines for Using Code Analysis Tools