feat(analyzer): build the analyzer against four Roslyn API versions - #505
Merged
Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Similar to dailydevops/analyzer#30.
Splits
NetEvolve.Defaults.Analyzer.csprojinto a packaging-only shell and four Roslyn-version-specific sibling projects, each targeting a differentMicrosoft.CodeAnalysis.CSharpversion:NetEvolve.Defaults.Analyzer.Roslyn4_4.csproj— 4.4.0 (oldest supported; build-verified only)NetEvolve.Defaults.Analyzer.Roslyn4_7.csproj— 4.7.0NetEvolve.Defaults.Analyzer.Roslyn4_14.csproj— 4.14.0NetEvolve.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 ownMicrosoft.CodeAnalysis.CSharpversion via CPM'sVersionOverride.Each variant's output is packed into a version-qualified
analyzers/dotnet/roslynX.Y/csfolder 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 asImmutableArray.Create(...), since olderMicrosoft.CodeAnalysis.CSharpreleases pull in aSystem.Collections.Immutablewithout[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 buildon the packaging project produces all four DLLs in their versionedanalyzers/dotnet/roslynX.Y/cspaths, the full solution builds cleanly, and all 165 analyzer unit tests (55 × 3 target frameworks) pass.