Suppress code analysis warnings for generated code

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 checkbox 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 checkbox.

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.