Skip to content

fix: truncate long source generator hint names for Windows#4757

Merged
thomhurst merged 1 commit intomainfrom
fix/source-gen-path-too-long-windows
Feb 13, 2026
Merged

fix: truncate long source generator hint names for Windows#4757
thomhurst merged 1 commit intomainfrom
fix/source-gen-path-too-long-windows

Conversation

@thomhurst
Copy link
Owner

Summary

  • Fixes PathTooLongException on Windows CI (modularpipeline (windows-latest)) that has been failing on every run since the GenericMethodTests.AggregateBy_HasExpectedOutput test was added
  • Generic methods with complex type parameters generate hint names exceeding 260 characters, hitting the legacy MAX_PATH limit in Roslyn's AddSource on net472
  • Truncates names exceeding 200 characters and appends a deterministic 8-char FNV-1a hash suffix (e.g. _06BD488B) to maintain uniqueness

Test plan

  • Source generator snapshot tests pass on all target frameworks (net8.0, net9.0, net10.0, net472)
  • Windows CI (modularpipeline (windows-latest)) passes without PathTooLongException

🤖 Generated with Claude Code

…ception on Windows

Generic methods with many complex type parameters (e.g. GenericMethodTests.AggregateBy_HasExpectedOutput)
generate hint names exceeding 260 characters, which triggers PathTooLongException on Windows with net472
due to the legacy MAX_PATH limit in Roslyn's AddSource. This truncates names exceeding 200 characters
and appends a deterministic FNV-1a hash suffix to maintain uniqueness.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude
Copy link
Contributor

claude bot commented Feb 13, 2026

Code review

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

Review Summary

This PR properly fixes the Windows PathTooLongException by truncating source generator hint names that exceed 200 characters. The implementation:

  • ✅ Uses correct FNV-1a hash algorithm with proper constants (deterministic across platforms)
  • ✅ Handles truncation arithmetic correctly: 186 chars (base) + 9 chars (hash suffix) + 5 chars (".g.cs") = 200 chars total
  • ✅ Commits snapshot test updates as .verified.txt per CLAUDE.md requirements
  • ✅ Maintains uniqueness via hash suffix with negligible collision risk
  • ✅ Performance-conscious with conditional truncation and fast hashing

The approach is well-suited to the problem and follows TUnit development guidelines.

@thomhurst thomhurst merged commit 7ec9212 into main Feb 13, 2026
12 of 13 checks passed
@thomhurst thomhurst deleted the fix/source-gen-path-too-long-windows branch February 13, 2026 19:43
thomhurst added a commit that referenced this pull request Feb 13, 2026
… net472

The previous limit of 200 chars (from #4757) still caused PathTooLongException
on Windows CI because .NET Framework 4.7.2's Path.GetFullPathInternal prepends
the CWD (~69 chars) to the hint name, exceeding the hardcoded 260-char MAX_PATH
limit. Reducing to 150 leaves ~110 chars of headroom for the working directory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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