Skip to content

Comments

chore: consolidate 9 Roslyn-versioned project duplicates#4943

Merged
thomhurst merged 1 commit intomainfrom
chore/roslyn-consolidate
Feb 19, 2026
Merged

chore: consolidate 9 Roslyn-versioned project duplicates#4943
thomhurst merged 1 commit intomainfrom
chore/roslyn-consolidate

Conversation

@thomhurst
Copy link
Owner

Summary

  • Merges three near-identical Directory.Build.props PropertyGroup blocks into one that dynamically derives AssemblyName, RootNamespace, and RoslynVersion from the project name using MSBuild regex functions
  • Consolidates Analyzer.props, AspNetCore.Analyzer.props, and SourceGenerator.props into a single unified Roslyn.props that uses the derived _BaseProjectName property to link source files from the correct base project
  • Removes explicit RoslynVersion from all 9 .csproj files (now derived from project name suffix, e.g. Roslyn44 -> 4.4, Roslyn414 -> 4.14)
  • Removes duplicated Folder items from SourceGenerator .csproj files (moved to shared props)

Result: Each Roslyn-versioned .csproj is now a minimal 3-line stub that only imports Roslyn.props. Adding a new Roslyn version target requires only creating a new directory with a stub .csproj -- no other files need updating.

Net change: 14 files changed, 39 insertions, 111 deletions (-72 lines). Three .props files deleted.

Closes #4883

Test plan

  • All 9 Roslyn-versioned projects build successfully
  • Downstream projects (TUnit.Core, TUnit.AspNetCore, TUnit.SourceGenerator.IncrementalTests) build successfully
  • Full solution build passes with 0 errors
  • Verified RoslynVersion, AssemblyName, and RootNamespace resolve correctly for all projects via dotnet msbuild -getProperty

@claude
Copy link
Contributor

claude bot commented Feb 19, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

This is a well-executed MSBuild refactor. A few things worth calling out positively:

RoslynVersion derivation is correct. The two-step regex (Roslyn(\d+)$^(\d)$1.) correctly produces 4.4, 4.7, and 4.14 from the respective project name suffixes. The .NET Regex.Replace with ^ anchoring means "414" → "4.14" without risk of double-inserting a dot.

Condition specificity is solid. Using .Contains('.Roslyn') (with the dot) rather than .Contains('Roslyn') prevents any hypothetical false matches on projects that might have "Roslyn" as part of another word. The existing 9 variant projects are the only ones in the solution with .Roslyn in their names.

Behavior parity is maintained. The conditional ItemGroup structure in Roslyn.props correctly replicates the previous per-file behavior:

  • EndsWith('.Analyzers')EmbeddedResource for both TUnit.Analyzers and TUnit.AspNetCore.Analyzers
  • Contains('AspNetCore.Analyzers')AdditionalFiles for release tracking only for AspNetCore ✓
  • Contains('SourceGenerator')Folder IDE link only for SourceGenerator ✓

The result is each Roslyn-versioned .csproj becoming a 3-line stub, and adding a new Roslyn version target will now require only creating a new directory with that stub — a clear DRY improvement with no behavioral regressions.

…props

Reduce duplication across the 9 Roslyn-versioned analyzer/generator projects
by centralizing shared configuration:

- Merge three near-identical Directory.Build.props PropertyGroup blocks into
  one that dynamically derives AssemblyName, RootNamespace, and RoslynVersion
  from the project name using MSBuild regex functions
- Consolidate Analyzer.props, AspNetCore.Analyzer.props, and
  SourceGenerator.props into a single Roslyn.props that uses the derived
  _BaseProjectName property to link source files from the correct base project
- Remove explicit RoslynVersion from all 9 .csproj files (now derived)
- Remove Folder items from SourceGenerator .csproj files (moved to Roslyn.props)

The 9 .csproj files are now minimal 3-line stubs that only import Roslyn.props.
Adding a new Roslyn version target requires only creating a new directory with
a stub .csproj -- no other files need updating.
This was referenced Feb 23, 2026
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.

chore: consolidate 9 Roslyn-versioned project duplicates

1 participant