Skip to content

feat(analyzer): build the analyzer against four Roslyn API versions - #505

Merged
samtrion merged 2 commits into
mainfrom
feat/analyzer-multi-roslyn-versions
Aug 4, 2026
Merged

feat(analyzer): build the analyzer against four Roslyn API versions#505
samtrion merged 2 commits into
mainfrom
feat/analyzer-multi-roslyn-versions

Conversation

@samtrion

@samtrion samtrion commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Similar to dailydevops/analyzer#30.

Splits NetEvolve.Defaults.Analyzer.csproj into a packaging-only shell and four Roslyn-version-specific sibling projects, each targeting a different Microsoft.CodeAnalysis.CSharp version:

  • NetEvolve.Defaults.Analyzer.Roslyn4_4.csproj — 4.4.0 (oldest supported; build-verified only)
  • NetEvolve.Defaults.Analyzer.Roslyn4_7.csproj — 4.7.0
  • NetEvolve.Defaults.Analyzer.Roslyn4_14.csproj — 4.14.0
  • NetEvolve.Defaults.Analyzer.Roslyn5_6.csproj — 5.6.0 (latest, matches the centrally pinned version)

All four share their compile settings (target framework, language settings, InternalsVisibleTo, analyzer release tracking, resource codegen) via a new NetEvolve.Defaults.Analyzer.Build.props, and each pulls in its own Microsoft.CodeAnalysis.CSharp version via CPM's VersionOverride.

Each variant's output is packed into a version-qualified analyzers/dotnet/roslynX.Y/cs folder in the NuGet package, matching the versioned-analyzer layout the .NET SDK understands from 8.0.400 onward — consumers on older SDKs won't receive an analyzer from this package, same trade-off as the reference PR.

Two collection-expression usages targeting ImmutableArray<T> were rewritten as ImmutableArray.Create(...), since older Microsoft.CodeAnalysis.CSharp releases pull in a System.Collections.Immutable without [CollectionBuilder] support.

The unit test project now multi-targets net8.0/net9.0/net10.0, each mapped to a different Roslyn variant (4.7.0 / 4.14.0 / 5.6.0), so the analyzer is actually exercised against three of the four Roslyn versions instead of just compiling against the latest. The 4.4.0 variant remains build-verified only.

Verified: dotnet build on the packaging project produces all four DLLs in their versioned analyzers/dotnet/roslynX.Y/cs paths, the full solution builds cleanly, and all 165 analyzer unit tests (55 × 3 target frameworks) pass.

Splits NetEvolve.Defaults.Analyzer.csproj into a packaging-only shell and
four Roslyn-version-specific sibling projects (4.4.0, 4.7.0, 4.14.0, 5.6.0),
sharing their compile settings via NetEvolve.Defaults.Analyzer.Build.props.
Each variant is packed into a version-qualified analyzers/dotnet/roslynX.Y/cs
folder, matching the versioned analyzer layout supported by the .NET SDK
(8.0.400+).

The unit test project now compiles against the Roslyn5_6 variant, since the
packaging shell no longer contains any compilable source.
@samtrion
samtrion requested a review from a team as a code owner August 4, 2026 20:00
@samtrion
samtrion requested review from Hnogared and removed request for a team August 4, 2026 20:00
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f6f5545) to head (0e88301).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #505   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           16        16           
  Branches         1         1           
=========================================
  Hits            16        16           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…ants

Multi-targets the unit test project across net8.0/net9.0/net10.0 and maps
each target framework to a different Roslyn variant project (4.7.0, 4.14.0,
5.6.0 respectively), so the analyzer is actually exercised against multiple
Roslyn API versions instead of only the latest one. The 4.4.0 variant stays
build-verified only, same as its baseline fallback role in the Build.props.
@samtrion
samtrion merged commit af25156 into main Aug 4, 2026
12 checks passed
@samtrion
samtrion deleted the feat/analyzer-multi-roslyn-versions branch August 4, 2026 20:15
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