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 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
Select a project in Solution Explorer.
On the Project menu, click <project name> Properties.
Click Code Analysis.
Select Enable Code Analysis on Build (defines CODE_ANALYSIS constant).
Expand a rule node.
Enable the specific warning by selecting the warning check box.
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
Select a project in Solution Explorer.
On the Project menu, click <project name> Properties.
Click Code Analysis.
Expand a rule node.
Disable the specific warning by clearing the warning check box.