Share via


How to: Suppress Warnings by Using the Menu Item

Note

In source suppression is not supported for C/C++ and web site projects.

You can use the Error List window to suppress managed code analysis warnings. Suppressing a warning differs from disabling it. When you suppress a warning, it applies only to a particular instance of the violation. Other violations of the same warning will still be reported in the Error List window.

After you run code analysis, you might determine that one or more of the code analysis warnings that are displayed in the Error List window are not applicable to your application. For example, you might determine that the code is correct as is. Or, it might be the case that some violations are low priority and will not be fixed in the current development cycle. Regardless of the reason, it is frequently useful to indicate that the warning is non-applicable in order to let your team members know that the code was reviewed and that it was determined that the warning could be suppressed. In source suppression is useful because it enables a developer to put a suppression close to where the warning is generated.

You can choose whether the suppression will appear in the source code or in the global suppression file. Some suppressions must be placed in the global suppression file. If this is the case, the In Source option will be disabled.

To suppress a warning by using menu item

  1. On the View menu, click Error List to display the Error List window.

  2. In the Error List, select the warning or warnings to suppress. Multiple warnings can be selected at the same time.

  3. Right-click the warning, point to Suppress Message(s), and click either In Source or In Project Suppression File.

    The specific warning is suppressed, and the warning appears in the Error List window with a strikethrough.

Note

Suppressions that do not have a target appear in the global suppression file.