Skip to content

Commit

Permalink
Add reproducer for #6772 (S4507 FP: Error raised on .NET 7 although t…
Browse files Browse the repository at this point in the history
…he debug feature is deactivated)
  • Loading branch information
martin-strecker-sonarsource committed Feb 22, 2023
1 parent be60a31 commit 94f72fa
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ internal static class AspNetCoreMetadataReference
internal static MetadataReference MicrosoftAspNetCoreMvcCore { get; } = Create(typeof(Microsoft.AspNetCore.Mvc.ControllerBase));
internal static MetadataReference MicrosoftAspNetCoreMvcViewFeatures { get; } = Create(typeof(Microsoft.AspNetCore.Mvc.Controller));
internal static MetadataReference MicrosoftAspNetCoreRazorPages { get; } = Create(typeof(Microsoft.AspNetCore.Mvc.RazorPages.PageModel));
internal static MetadataReference MicrosoftAspNetCoreRouting { get; } = Create(typeof(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder));
internal static MetadataReference MicrosoftAspNetCoreWebHost { get; } = Create(typeof(Microsoft.AspNetCore.WebHost));
internal static MetadataReference MicrosoftExtensionsHostingAbstractions { get; } = Create(typeof(Microsoft.Extensions.Hosting.IHost));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ public class DeliveringDebugFeaturesInProductionTest
.AddReferences(AdditionalReferencesForAspNetCore3AndLater)
.Verify();

[TestMethod]
public void DeliveringDebugFeaturesInProduction_Net7_CS() =>
builderCS.AddPaths("DeliveringDebugFeaturesInProduction.Net7.cs")
.WithTopLevelStatements()
.AddReferences(new[]
{
AspNetCoreMetadataReference.MicrosoftAspNetCoreWebHost,
AspNetCoreMetadataReference.MicrosoftAspNetCoreRouting,
AspNetCoreMetadataReference.MicrosoftAspNetCoreDiagnostics,
AspNetCoreMetadataReference.MicrosoftAspNetCoreHttpAbstractions,
AspNetCoreMetadataReference.MicrosoftAspNetCoreHostingAbstractions,
AspNetCoreMetadataReference.MicrosoftExtensionsHostingAbstractions,
})
.Verify();

private static IEnumerable<MetadataReference> AdditionalReferencesForAspNetCore3AndLater =>
new[]
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Hosting;

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage(); // Noncompliant FP https://github.com/SonarSource/sonar-dotnet/issues/6772
}

app.Run();

0 comments on commit 94f72fa

Please sign in to comment.