Skip to content

Commit b0661ba

Browse files
authored
Merge pull request #2477 from gewarren/suppress-warnings
Suppress diagnostics from error list
2 parents b9000b6 + 3cda06b commit b0661ba

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
2.25 KB
Loading

docs/code-quality/use-roslyn-analyzers.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ There are multiple ways to suppress rule violations:
109109

110110
![Suppress diagnostic from quick actions menu](media/suppress-diagnostic-from-editor.png)
111111

112-
- To suppress a diagnostic from the **Error List**, right-click on the error, warning, or message, and select **Suppress** > **In Source** or **Suppress** > **In Suppression File**.
112+
- To suppress a diagnostic from the **Error List**, see [Suppress violations from the Error List](#suppress-violations-from-the-error-list).
113+
114+
### Suppress violations from the Error List
115+
116+
You can suppress one or many diagnostics from the **Error List** by selecting the ones you want to suppress, and then right-clicking and selecting **Suppress** > **In Source** or **Suppress** > **In Suppression File**.
113117

114118
- If you select **In Source**, the **Preview Changes** dialog opens and shows a preview of the C# [#pragma warning](/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-pragma-warning) or Visual Basic [#Disable warning](/dotnet/visual-basic/language-reference/directives/directives) directive that's added to the source code.
115119

@@ -121,6 +125,10 @@ There are multiple ways to suppress rule violations:
121125

122126
In the **Preview Changes** dialog, select **Apply**.
123127

128+
The **Error List** displays diagnostics, or rule violations, from both live code analysis and build. Since the build diagnostics can be stale, for example, if you've edited the code to fix the violation but haven't rebuilt, you cannot suppress these diagnostics from the **Error List**. However, diagnostics from live analysis, or IntelliSense, are always up-to-date with current sources, and can be suppressed from the **Error List**. If the suppression option is disabled in the right-click, or context, menu, it's likely because you have one or more build diagnostics in your selection. To exclude the build diagnostics from your selection, switch the **Error List** source filter from **Build + IntelliSense** to **Intellisense Only**. Then, select the diagnostics you want to suppress and proceed as described previously.
129+
130+
![Error List source filter in Visual Studio](media/error-list-filter.png)
131+
124132
> [!NOTE]
125133
> In a .NET Core project, if you add a reference to a project that has NuGet analyzers, those analyzers are automatically added to the dependent project too. To disable this behavior, for example if the dependent project is a unit test project, mark the NuGet package as private in the *.csproj* or *.vbproj* file of the referenced project:
126134
>

0 commit comments

Comments
 (0)