Bound generated file hint names to prevent path overflow#219
Open
PhenX wants to merge 1 commit into
Open
Conversation
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
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.
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
GeneratedHintNameutility 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 nameProjectionExpressionGenerator: Modified to use the new hint name builder instead of directly using the generated class name as the file nameImplementation Details
string.GetHashCode()and netstandard2.0 incompatibility withSystem.HashCode)https://claude.ai/code/session_01Aj9cWDbhAR9AxSmXGZA43Y