From 7a0cc459af3c97f48a98f4e56ee27ef3eb55bc80 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Thu, 6 Jul 2023 20:57:45 +0000 Subject: [PATCH] Ignore suppressed diagnostics in code fix verifier --- .../Verifiers/CSharpCodeFixVerifier`2.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpCodeFixVerifier`2.cs b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpCodeFixVerifier`2.cs index 33c9d178c699d..ac59612df8b36 100644 --- a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpCodeFixVerifier`2.cs +++ b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpCodeFixVerifier`2.cs @@ -2,6 +2,8 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; using System.Threading; using System.Threading.Tasks; using ILLink.Shared; @@ -36,6 +38,15 @@ public Test () return solution; }); } + + protected override ImmutableArray<(Project project, Diagnostic diagnostic)> SortDistinctDiagnostics (IEnumerable<(Project project, Diagnostic diagnostic)> diagnostics) + { + // Only include non-suppressed diagnostics in the result. Our tests suppress diagnostics + // with 'UnconditionalSuppressMessageAttribute', and expect them not to be reported. + return base.SortDistinctDiagnostics (diagnostics) + .Where (diagnostic => !diagnostic.diagnostic.IsSuppressed) + .ToImmutableArray (); + } } ///