Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unskip NRT suppression tests #28308

Merged
1 commit merged into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
<MicrosoftExtensionsLoggingVersion>7.0.0-preview.6.22319.5</MicrosoftExtensionsLoggingVersion>
</PropertyGroup>
<PropertyGroup Label="Other dependencies">
<MicrosoftCodeAnalysisVersion>4.1.0</MicrosoftCodeAnalysisVersion>
<MicrosoftCodeAnalysisVersion>4.2.0</MicrosoftCodeAnalysisVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -59,11 +60,13 @@ protected async Task<Diagnostic[]> 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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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);
});
}

Expand Down