[5.0] Let consumers choose the Roslyn version used by the testing framework - #1810
Merged
Merged
Conversation
Lower the Roslyn dependency of the testing packages to 3.8.0 so the effective Roslyn version is determined by the consumer's own Microsoft.CodeAnalysis.* reference instead of being forced to a fixed version. - Decouple Roslynator.Testing.Common from the Roslynator.Core package by duplicating the handful of internal helpers it used. - Add RoslynatorTestRoslynVersion so this repo's own test suite can run against a chosen Roslyn version; add a CI run at 4.7.0. - Guard version-sensitive tests so the suite builds and passes at 4.7.0. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
josefpihrt
commented
Aug 11, 2026
josefpihrt
left a comment
Collaborator
Author
There was a problem hiding this comment.
Review notes for making the testing framework’s Roslyn version consumer-selectable. Direction and changelog/breaking-change notes look strong; a few verification/CI clarifications.
Co-authored-by: Cursor <cursoragent@cursor.com>
josefpihrt
commented
Aug 14, 2026
josefpihrt
left a comment
Collaborator
Author
There was a problem hiding this comment.
Detailed pass on the testing-framework Roslyn floor change. The approach is right: compile Testing.* against 3.8, drop the Roslynator.Core leak, pin this repo with RoslynatorTestRoslynVersion, and document the consumer PackageReference. CI is green at default 4.14 and at test_roslyn_versions 4.7.0; the earlier review nits on the 4.4 DefineConstants comma and the CI comment are addressed.
A few leftover product/docs issues before merge.
Move the Testing Framework changelog entry to Breaking (including the Core reference break), centralize ROSLYN_TEST_* defines for all test projects, and clarify Default vs Latest parse LanguageVersion in the NuGet readmes. Also pin RoslynatorTestRoslynVersion to 5.0.0 after the Roslyn 5.0 merge and drop the incompatible 4.7 test matrix cell. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
The Unreleased #1787 bullet conflicted with the testing-package floor at 3.8.0. CLI still targets 5.0.0; this repo's suite still runs at 5.0.0. Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Aug 21, 2026
Open
Open
This was referenced Aug 24, 2026
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.
Problem
The Roslynator testing framework forced every test run onto a fixed Roslyn version (
4.14.0), becauseRoslynator.Testing.*declaredMicrosoft.CodeAnalysis.* >= 4.14.0. Since NuGet dependency versions are minimums, a consumer whose analyzer targets an older Roslyn (e.g. theroslyn3.8/roslyn4.7buckets Roslynator itself ships) could not test against that version — NuGet unified the graph up to4.14.0.Change
3.8.0so the effective version is determined by the consumer's ownMicrosoft.CodeAnalysis.*reference. Verified theTesting.*projects use no API newer than 3.8.build_core_and_testingcompiles and packs those projects against 3.8.Roslynator.Testing.Commonfrom theRoslynator.Corepackage (its floor would otherwise leak back through). The ~6 internal helpers used (StringBuilderCache,Hash, the diagnostic comparers,ToReportDiagnostic) are duplicated intoTesting.Commonasinternaltypes.Roslynator.Core's own published floor is unchanged.RoslynatorTestRoslynVersion(default5.0.0, matching this repo's analyzerMicrosoft.CodeAnalysis.*floor after Bump Roslyn to 5.0 #1787) so the in-repo suite pins the Roslyn version used at test runtime.Microsoft.CodeAnalysis.*PackageReference. It does not switchRoslynatorRoslynVersion/ analyzer compilation.ProjectReferenceanalyzers that requireMicrosoft.CodeAnalysis.* >= 5.0.0.3.8.0: that is the testing package compile floor for consumers, not a version this repo's analyzers can execute against.SyntaxKindTestsand tests using C# 12/13 features or newer-Roslyn formatter output) withROSLYN_TEST_*defines insrc/Tests/Directory.Build.props.DefineConstantslist:ROSLYN_4_2,ROSLYN_4_4used a comma, soROSLYN_4_4was never defined for that bucket. It is now semicolon-separated (already onmainvia Bump Roslyn to 5.0 #1787).Consumer action required
A test project that relied on the implicit
4.14.0should now add its own reference:The chosen version raises the maximum C# the parser can accept; test sources still parse at
CSharpParseOptions.Default(notLatest) unless you set parse options /LanguageVersion. The same note is in the Testing.CSharp.Xunit / MSTest NuGet readmes.A test project that used
Roslynator.Coretypes via the old transitive dependency must add an explicitRoslynator.Corepackage reference.Verification
RoslynatorTestRoslynVersion=5.0.0(default).Testing.Common/Testing.CSharpfloor at3.8.0with noRoslynator.Coredependency;Roslynator.Corestill floors at the product Roslyn version.