Delen via


How to: Suppress code analysis warnings for generated code

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Generated code includes code that's added to your project by managed code compilers or third-party tools. You might want to see the rule violations that code analysis discovers in generated code. However, since you can't view and maintain the code that contains the violations, you might not want to see them.

The Suppress results from generated code check box on the code analysis property page of a project enables you to select whether to show code analysis warnings from code generated by a third-party tool.

Note

This option does not suppress code analysis errors and warnings from generated code when the errors and warnings appear in forms and templates. You can both view and maintain the source code for a form or a template.

To suppress warnings for generated code in a project

  1. Right-click the project in Solution Explorer and then click Properties.

  2. Choose the Code Analysis tab.

  3. Select the Suppress results from generated code check box.

Important

You can only suppress warnings from legacy analysis. The property page with the setting has been deprecated and will be removed in a future product release. Currently, you cannot suppress code analysis warnings from analyzers.