Skip to content

Bound generated file hint names to prevent path overflow#219

Open
PhenX wants to merge 1 commit into
masterfrom
claude/issue-214-plan-tvxr3z
Open

Bound generated file hint names to prevent path overflow#219
PhenX wants to merge 1 commit into
masterfrom
claude/issue-214-plan-tvxr3z

Conversation

@PhenX

@PhenX PhenX commented Jul 20, 2026

Copy link
Copy Markdown
Member

Summary

This change addresses a critical issue where generated source files for projectable methods with long or deeply generic parameters could exceed filesystem path limits (e.g., Windows' MAX_PATH of ~260 characters), causing Visual Studio to crash when browsing generated files under Dependencies > Analyzers.

Key Changes

  • New GeneratedHintName utility class: Implements intelligent hint name generation that keeps short names unchanged for readability and backward compatibility, while shortening long names to a readable prefix (up to 40 characters) plus a deterministic FNV-1a hash of the full name
  • Updated ProjectionExpressionGenerator: Modified to use the new hint name builder instead of directly using the generated class name as the file name
  • Added comprehensive tests: Two new test cases verify that:
    • Long parameter methods produce bounded hint names (≤69 characters) while remaining recognizable
    • Overloaded methods with different long parameter types get unique hint names via deterministic hashing

Implementation Details

  • The hint name is a pure IDE/filesystem artifact and never read at runtime, so it can be shortened freely without affecting the runtime contract
  • The generated class name remains unchanged (it's used by reflection fallback and embedded in the registry), only the file hint name is shortened
  • The FNV-1a hash is hand-rolled to ensure deterministic, cross-platform consistency (avoiding randomized string.GetHashCode() and netstandard2.0 incompatibility with System.HashCode)
  • Names ≤64 characters are emitted unchanged, preserving byte-identical output for the common case

https://claude.ai/code/session_01Aj9cWDbhAR9AxSmXGZA43Y

Generated per-member files were named "{generatedClassName}.g.cs", where the
class name embeds every parameter's fully-qualified type name. Methods with
many or deeply generic parameters produced file names hundreds of characters
long, overflowing path limits (e.g. Windows MAX_PATH) and crashing Visual
Studio when browsing files under Dependencies > Analyzers.

Decouple the file (hint) name from the generated class name. The hint name is
never read at runtime, so it can be shortened freely; the class name is a
runtime contract (resolved via Assembly.GetType in the reflection fallback and
embedded in the registry) and is left byte-for-byte unchanged. Short names are
emitted exactly as before; over-long names become
"{namespace_member}_{hash}.g.cs" using a deterministic FNV-1a 64-bit hash of
the full name to preserve per-overload uniqueness.

Fixes #214

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Aj9cWDbhAR9AxSmXGZA43Y
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.

2 participants