diff --git a/eng/Versions.props b/eng/Versions.props
index a91bb7d87d2..5b06993e6ae 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -26,6 +26,6 @@
7.0.0-preview.6.22319.5
- 4.1.0
+ 4.2.0
diff --git a/src/EFCore.Analyzers/UninitializedDbSetDiagnosticSuppressor.cs b/src/EFCore.Analyzers/UninitializedDbSetDiagnosticSuppressor.cs
index ea9f994e19c..c5cf7accf66 100644
--- a/src/EFCore.Analyzers/UninitializedDbSetDiagnosticSuppressor.cs
+++ b/src/EFCore.Analyzers/UninitializedDbSetDiagnosticSuppressor.cs
@@ -12,7 +12,7 @@ namespace Microsoft.EntityFrameworkCore;
public sealed class UninitializedDbSetDiagnosticSuppressor : DiagnosticSuppressor
{
private static readonly SuppressionDescriptor SuppressUninitializedDbSetRule = new(
- id: "SPR1001",
+ id: "EFSPR1001",
suppressedDiagnosticId: "CS8618",
justification: AnalyzerStrings.UninitializedDbSetWarningSuppressionJustification);
@@ -70,7 +70,7 @@ public override void ReportSuppressions(SuppressionAnalysisContext context)
if (propertySymbol.Type.OriginalDefinition.Equals(dbSetTypeSymbol, SymbolEqualityComparer.Default)
&& InheritsFrom(propertySymbol.ContainingType, dbContextTypeSymbol))
{
- context.ReportSuppression(Suppression.Create(SupportedSuppressions[0], diagnostic));
+ context.ReportSuppression(Suppression.Create(SuppressUninitializedDbSetRule, diagnostic));
}
static bool InheritsFrom(ITypeSymbol typeSymbol, ITypeSymbol baseTypeSymbol)
diff --git a/test/EFCore.Analyzers.Tests/TestUtilities/DiagnosticAnalyzerTestBase.cs b/test/EFCore.Analyzers.Tests/TestUtilities/DiagnosticAnalyzerTestBase.cs
index bc4d40526c0..5f33a445660 100644
--- a/test/EFCore.Analyzers.Tests/TestUtilities/DiagnosticAnalyzerTestBase.cs
+++ b/test/EFCore.Analyzers.Tests/TestUtilities/DiagnosticAnalyzerTestBase.cs
@@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;
using Microsoft.Extensions.DependencyModel;
+using CompilationOptions = Microsoft.CodeAnalysis.CompilationOptions;
namespace Microsoft.EntityFrameworkCore.TestUtilities;
@@ -59,11 +60,13 @@ protected async Task GetDiagnosticsFullSourceAsync(string source,
var analyzer = CreateDiagnosticAnalyzer();
var compilationWithAnalyzers
= compilation
- .WithOptions(
- compilation.Options.WithSpecificDiagnosticOptions(
- compilation.Options.SpecificDiagnosticOptions
- .AddRange(analyzer.SupportedDiagnostics.ToDictionary(d => d.Id, d => ReportDiagnostic.Default))))
- .WithAnalyzers(ImmutableArray.Create(analyzer));
+ .WithAnalyzers(ImmutableArray.Create(analyzer),
+ new CompilationWithAnalyzersOptions(
+ new AnalyzerOptions(new()),
+ onAnalyzerException: null,
+ concurrentAnalysis: false,
+ logAnalyzerExecutionTime: false,
+ reportSuppressedDiagnostics: true));
var diagnostics = analyzerDiagnosticsOnly
? await compilationWithAnalyzers.GetAnalyzerDiagnosticsAsync()
diff --git a/test/EFCore.Analyzers.Tests/UninitializedDbSetDiagnosticSuppressorTest.cs b/test/EFCore.Analyzers.Tests/UninitializedDbSetDiagnosticSuppressorTest.cs
index e6f9a2b8e1b..12185c1c261 100644
--- a/test/EFCore.Analyzers.Tests/UninitializedDbSetDiagnosticSuppressorTest.cs
+++ b/test/EFCore.Analyzers.Tests/UninitializedDbSetDiagnosticSuppressorTest.cs
@@ -1,11 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.EntityFrameworkCore.TestUtilities;
-using Xunit;
namespace Microsoft.EntityFrameworkCore;
@@ -165,9 +162,7 @@ public class Blog
var diagnostic = Assert.Single(await GetDiagnosticsFullSourceAsync(source));
Assert.Equal("CS8618", diagnostic.Id);
-
- // Suppression does work, but not in tests because of #27895
- Assert.False(diagnostic.IsSuppressed);
+ Assert.True(diagnostic.IsSuppressed);
}
[ConditionalFact]
@@ -195,9 +190,7 @@ public class Blog
diagnostic =>
{
Assert.Equal("CS8618", diagnostic.Id);
-
- // Suppression does work, but not in tests because of #27895
- Assert.False(diagnostic.IsSuppressed);
+ Assert.True(diagnostic.IsSuppressed);
});
}