cs2gs: escape keyword-named packages on the namespace-split path (ADR-0170, #3610) - #3624
Merged
Conversation
…-0170, #3610, #3501) The repository-mode package-split path resolves each split unit's package through ResolvePackageName with the namespace's C# DISPLAY spelling — ToDisplayString yields `@class` for `namespace @class` — while the symbol walk compared against the bare metadata name (`class`). The mismatch fell through to the raw `@` text, so the emitted file began `package @class`, which does not round-trip-parse (GS0005 AtToken): the Cs2Gs.Tests wall in the 2026-08-28 selfmig nightly (run 33217212584), pinned to Issue3461ReservedMetadataFixtures. Compare each dotted segment with its leading `@` stripped so the walk reaches the namespace symbol and the allocator returns the ADR-0170 G# escape ($class). Verified against the real shape: a repo-mode migrate of the cs2gs subtree at the nightly tip now emits `package $class` and the AtToken translate fingerprint disappears (only the known params-ReadOnlySpan gap remains for Cs2Gs.Tests). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nng28yiBdPVdeML7mSZphs
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
Root-causes and fixes the residual
AtTokenround-trip wall from the 2026-08-28 selfmig nightly (run 33217212584), pinned toIssue3461ReservedMetadataFixtures.cs.Root cause: the repository-mode namespace-split path feeds
ResolvePackageNamethe C# display spelling of the package (ToDisplayString()→@classfornamespace @class), but the resolver's namespace-symbol walk compared segments against the bare metadata name (class). The mismatch fell through to returning the raw text, so the split unit printedpackage @class— which gsc's parser rejects (GS0005: Unexpected token <AtToken>), failing the translator's round-trip validation. Class names were unaffected (class $deferprinted correctly); only the package line missed the ADR-0170 escape.Fix: strip a leading
@from each dotted segment before the symbol comparison, so the walk reaches the namespace symbol and the emitted-name allocator returns the G#$classescape.Verification
PackageSplit_KeywordNamespace_PrintsEscapedPackage(drives the exact pipeline shape:GetDeclaredPackagesdisplay spelling →packageFiltertranslator → assertspackage $class, no@). All 35 Issue3461 suites green.translate-9dd020ef25f2AtToken fingerprint), then re-ran with the fix: the fingerprint disappears, the emitted file readspackage $class, and Cs2Gs.Tests' only remaining translate gap is the knownparams ReadOnlySpan<int>CS2GS-GAP.🤖 Generated with Claude Code
https://claude.ai/code/session_01Nng28yiBdPVdeML7mSZphs