From 3744d1c475f0b98bbf69bb1186400974070a6512 Mon Sep 17 00:00:00 2001 From: Vladimir Pecanac Date: Sun, 11 Oct 2026 12:36:27 +0200 Subject: [PATCH] StyleCop: net10.0, OpenAPI without Swashbuckle, .editorconfig sample Retarget both projects from net7.0 to net10.0. Drop Swashbuckle.AspNetCore and wire Microsoft.AspNetCore.OpenApi 10.0.12 with AddOpenApi() and MapOpenApi(), as the .NET 10 template does. Add the .editorconfig the article edits, demoting SA1101 to a suggestion. Register stylecop.json as a bare AdditionalFiles item (the analyzers read it at compile time, so CopyToOutputDirectory did nothing). Bump the test packages. StyleCop.Analyzers stays on the stable 1.1.118. --- dotnet-projects/StyleCop/.editorconfig | 3 +++ dotnet-projects/StyleCop/StyleCop/Program.cs | 8 +++----- dotnet-projects/StyleCop/StyleCop/StyleCop.csproj | 9 +++------ dotnet-projects/StyleCop/Tests/Tests.csproj | 10 +++++----- 4 files changed, 14 insertions(+), 16 deletions(-) create mode 100644 dotnet-projects/StyleCop/.editorconfig diff --git a/dotnet-projects/StyleCop/.editorconfig b/dotnet-projects/StyleCop/.editorconfig new file mode 100644 index 0000000000..790edd72d1 --- /dev/null +++ b/dotnet-projects/StyleCop/.editorconfig @@ -0,0 +1,3 @@ +[*.cs] +# SA1101: Prefix local calls with this (demoted to a suggestion, see the article) +dotnet_diagnostic.SA1101.severity = suggestion diff --git a/dotnet-projects/StyleCop/StyleCop/Program.cs b/dotnet-projects/StyleCop/StyleCop/Program.cs index e8f3c37699..8f1154f630 100644 --- a/dotnet-projects/StyleCop/StyleCop/Program.cs +++ b/dotnet-projects/StyleCop/StyleCop/Program.cs @@ -13,17 +13,15 @@ public static void Main(string[] args) // Add services to the container. builder.Services.AddControllers(); - // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle - builder.Services.AddEndpointsApiExplorer(); - builder.Services.AddSwaggerGen(); + // Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi + builder.Services.AddOpenApi(); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { - app.UseSwagger(); - app.UseSwaggerUI(); + app.MapOpenApi(); } app.UseHttpsRedirection(); diff --git a/dotnet-projects/StyleCop/StyleCop/StyleCop.csproj b/dotnet-projects/StyleCop/StyleCop/StyleCop.csproj index 2cb22fb4b9..814f2dc863 100644 --- a/dotnet-projects/StyleCop/StyleCop/StyleCop.csproj +++ b/dotnet-projects/StyleCop/StyleCop/StyleCop.csproj @@ -1,7 +1,7 @@ - net7.0 + net10.0 enable enable @@ -11,18 +11,15 @@ - - Always - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/dotnet-projects/StyleCop/Tests/Tests.csproj b/dotnet-projects/StyleCop/Tests/Tests.csproj index 20281cab39..4a83736808 100644 --- a/dotnet-projects/StyleCop/Tests/Tests.csproj +++ b/dotnet-projects/StyleCop/Tests/Tests.csproj @@ -1,7 +1,7 @@  - net7.0 + net10.0 enable enable @@ -9,13 +9,13 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all