Share via


How to: Configure Code Analysis for a Managed Code Project

In Visual Studio Premium and Visual Studio Ultimate, you can choose from a list of Code Analysis rule sets to apply to a managed code project. The default rule set is the Microsoft Minimum Recommended Rules. You can apply another rule set to a project or to all projects in a solution.

Note

For information about how to configure a rule set for ASP.NET Web applications, see How to: Configure Code Analysis for an ASP.NET Web Application.

To configure a rule set for a .NET Framework project

  1. In Solution Explorer, click the project.

  2. On the Analyze menu, click Configure Code Analysis for ProjectName.

  3. In the Configuration and Platform lists, click the build configuration and target platform.

  4. To run code analysis every time the project is built using the selected configuration, select the Enable Code Analysis on Build (defines CODE_ANALYSIS constant) check box. You can also run code analysis manually by opening the Analyze menu and clicking Run Code Analysis on ProjectName.

  5. By default, code analysis does not report warnings from code that is automatically generated by external tools. To view warnings from generated code, clear the Suppress results from generated code check box.

    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.

  6. In the Run this rule set list, do one of the following:

    • Click the rule set that you want to use.

    • Click <Browse...> to specify an existing custom rule set that is not in the list.

    • Define a custom rule set.

      For more information, see Creating Custom Code Analysis Rule Sets.

See Also

Tasks

Walkthrough: Configuring and Using a Custom Rule Set