Skip to content

StyleCop Analyzers in .NET: net10.0, OpenAPI without Swashbuckle, .editorconfig sample - #2289

Merged
vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/92160-dotnet-stylecop-analyzers-implementation
Oct 13, 2026
Merged

vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/92160-dotnet-stylecop-analyzers-implementation

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Sample update for the article "StyleCop Analyzers in .NET: Setup and Alternatives" (https://code-maze.com/dotnet-stylecop-analyzers-implementation/).

Changes, all inside dotnet-projects/StyleCop:

  • Both projects move from net7.0 to net10.0.
  • Swashbuckle.AspNetCore removed. Microsoft.AspNetCore.OpenApi goes from 7.0.2 to 10.0.12, and Program.cs calls AddOpenApi() and MapOpenApi() (development only), the wiring the .NET 10 controller template generates. Program.cs keeps its explicit Program class, Main method and block-scoped namespace.
  • New .editorconfig at the folder root with the change the article makes: dotnet_diagnostic.SA1101.severity = suggestion. The repository's root .gitignore ignores .editorconfig, so the file is force-added, as in dotnet-cli/DotnetFormat and two other folders.
  • stylecop.json is registered as a bare . The CopyToOutputDirectory child is gone: the analyzers read the file at compile time, and the build reports the same diagnostics with and without it.
  • StyleCop.Analyzers stays on 1.1.118, the latest stable release.
  • Test project: package bumps only; the single test keeps its name.

Package versions, re-queried on NuGet on 2026-10-11 (latest listed stable):

  • Microsoft.AspNetCore.OpenApi 10.0.12
  • StyleCop.Analyzers 1.1.118 (stable; the newest prerelease is 1.2.0-beta.556)
  • Microsoft.NET.Test.Sdk 18.10.1
  • xunit 2.9.3
  • xunit.runner.visualstudio 4.0.1
  • coverlet.collector 10.1.0

Local results on SDK 10.0.302 / runtime 10.0.10: dotnet build -c Release succeeds with 0 errors and the three StyleCop warnings the sample keeps on purpose (SA1206, SA1309, SA0001); dotnet test 1 passed, 0 failed; dotnet list package --vulnerable --include-transitive reports no vulnerable packages in either project.

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.
@vladimir-pecanac-main
vladimir-pecanac-main merged commit 78f25e8 into CodeMazeBlog:main Oct 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant