Build one test project per Roslyn version - #1301
Merged
Merged
Conversation
The analyzer and the code fixers already had one project per Roslyn version. The tests did not, so a single test project was built against whatever /p:RoslynVersion was passed to it. - Add tests/Meziantou.Analyzer.Test/Meziantou.Analyzer.Test.roslyn<version>.csproj and move the shared content to the Directory.Build.props of the folder, the same way the src folders are organized. Each test project references the analyzer and the code fixers of its own Roslyn version. - Remove the development projects (Meziantou.Analyzer.csproj, Meziantou.Analyzer.CodeFixers.csproj and Meziantou.Analyzer.Test.csproj), as every project is now tied to a Roslyn version. DocumentationGenerator uses the default version. - Derive RoslynVersion from the name of the project file in the Directory.Build.props of the repository root, so the version specific projects are empty, and derive the version of the Microsoft.CodeAnalysis packages from it instead of listing it for each version. A project named after an unsupported version now fails with an explicit error. - Give each test project its own trx file, as they all produce an assembly named Meziantou.Analyzer.Test and would otherwise overwrite each other. - Build the CI matrix from the test projects found in the repository instead of hardcoding it, and validate that every Roslyn version has an analyzer, a code fixer and a test project, and that the default version is the latest supported one.
This was referenced Aug 19, 2026
Bump Meziantou.Analyzer from 3.0.139 to 3.0.167
Analogy-LogViewer/Analogy.LogViewer.NLog.Targets#551
Closed
Closed
Bump Meziantou.Analyzer from 3.0.139 to 3.0.167
Analogy-LogViewer/Analogy.AspNetCore.LogProvider#537
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
This was referenced Sep 20, 2026
Closed
Open
Bump Meziantou.Analyzer from 3.0.139 to 3.0.266
Analogy-LogViewer/Analogy.LogViewer.NLog.Targets#579
Closed
Closed
Bump Meziantou.Analyzer from 3.0.139 to 3.0.266
Analogy-LogViewer/Analogy.AspNetCore.LogProvider#560
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
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.
The analyzer and the code fixers already had one project per Roslyn version, but the tests did not: a single test project was built against whatever
/p:RoslynVersionwas passed to it. This applies the same pattern to the tests, and removes the duplication that made it necessary.Tests follow the
srcpatternOne
Meziantou.Analyzer.Test.roslyn<version>.csprojper version, with the shared content moved to theDirectory.Build.propsof the folder. Each test project references the analyzer and the code fixers of its own Roslyn version.The development projects are gone
Meziantou.Analyzer.csproj,Meziantou.Analyzer.CodeFixers.csprojandMeziantou.Analyzer.Test.csprojare removed, as every project is now tied to a Roslyn version.DocumentationGeneratoris not specific to a version, so it referencesMeziantou.Analyzer.$(RoslynVersion).csprojand follows the default. ItsVersion="4.11.0"onMicrosoft.CodeAnalysis.CSharp.Workspaceswas already dead (theUpdateinDirectory.Build.targetsoverrode it to 5.9.0), so it was dropped./p:RoslynVersionis no longer a way to build another version — build or test the project of that version instead. The version specific projects keepTreatAsLocalProperty="RoslynVersion"so a stray/p:RoslynVersioncannot silently retarget them.Less to maintain per version
RoslynVersionis derived from the name of the project file in theDirectory.Build.propsof the repository root, so the 15 version specific projects are now empty. The version of theMicrosoft.CodeAnalysis.*packages is derived from it too, replacing the 15 hardcoded entries inDirectory.Build.targets; what stays version specific there isDefineConstantsand the warnings to disable.Removing the
Otherwisebranch created a silent failure path: a project named after an unsupported version would have compiled with noROSLYN_*constant at all, quietly dropping#ifblocks while still succeeding. EachWhennow setsRoslynVersionSupportedand aBeforeBuildtarget errors otherwise.CI
The
build_and_testmatrix is discovered from the test projects present in the repository instead of being hardcoded, and alist_test_projectsjob validates that every Roslyn version has an analyzer, a code fixer and a test project, and that the default version is the latest supported one. The version comparison casts to[version], soroslyn5.10sorts afterroslyn5.9.Also removed
runs-onandconfigurationfrom the matrix, as each had a single value.Note for reviewers
All the test projects produce an assembly named
Meziantou.Analyzer.Test(required by theInternalsVisibleToinAssemblyInfo.cs), so on a solution wide run they all wrote the same trx file and five reports were silently overwritten. Each project now sets its own report name. CI was never affected, as it runs one project per job.build/update-version.ps1referenced the deletedMeziantou.Analyzer.csproj, but it was already dead before this change: it targets aPackageVersionproperty and asrc/Meziantou.Analyzer.Vsix/folder that no longer exist, and the CI computes the version itself. Left untouched, but it looks like a candidate for deletion.Verification
dotnet run --project src/DocumentationGeneratorexits 0 with byte identical markdown.lib/.