Fix #264: lock in C# interpolated/verbatim string reference extraction - #434
Merged
Conversation
…extraction (#264) StructuralLineMasker already handles C# single-line $"...", multi-line $@"..." / @$"...", and non-interpolated @"..." correctly — interpolation-hole call sites are captured and multi-line verbatim bodies do not leak phantom edges — but no end-to-end test pinned that behavior on the exact fixture from issue #264, leaving the invariant exposed to silent regressions in future masker refactors. Add Extract_CsharpInterpolatedAndVerbatimStrings_Issue264_Repro_CapturesHoleCallsAndSuppressesPhantoms which feeds the issue's repro verbatim (single-line $"...", multi-line $@"..." with an interpolation hole, nested Helper.Format(Helper.GetName()), plain non-interpolated call site, and a multi-line @"..." body carrying PhantomCall() / PhantomTable() / MoreFake()) through ReferenceExtractor.Extract and pins four invariants: Helper.GetName is captured exactly four times, Helper.GetAge and Helper.Format are each captured at least once, every captured call's ContainerName resolves to Work, and no reference row surfaces for the phantom identifiers embedded in the verbatim body. Closes #264
Round 1 codex review flagged that the new fixture only exercised the $@"..." ordering. StructuralLineMasker has dedicated branches for both legal spellings, so add a sibling @$"..." case to close the coverage gap claimed by the changelog entry.
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
$"... {Foo()} ..."hide embedded call sites from the reference index; verbatim strings@"..."confuse the extractor on line continuations #264 originally reported that C#$"..."interpolated and@"..."verbatim strings (including$@"..."and@$"...") confused the reference extractor: embedded call sites hidden and phantom references leaking out of verbatim bodies.StructuralLineMasker(C# branch) andPrepareLinealready handle all four forms correctly. Running the repro through the current binary shows the reported defects no longer reproduce.$@and@$orderings, and documents the fix in the changelog so accidental future reversions surface immediately.Changes
tests/CodeIndex.Tests/ReferenceExtractorTests.cs— newExtract_CsharpInterpolatedAndVerbatimStrings_Issue264_Repro_CapturesHoleCallsAndSuppressesPhantomsfixture:$"..."single-line interpolation hole calls captured once per call site$@"...{...}..."multi-line verbatim-interpolated string hole calls captured, literal body suppressed@$"...{...}..."alternate legal ordering also covered (addresses round-1 codex review gap)@"..."multi-line verbatim body contents do not produce phantom reference rowsCHANGELOG.md— Unreleased entry under#### Fixed(English and Japanese).Test plan
dotnet buildsucceeds.dotnet test --filter "FullyQualifiedName~ReferenceExtractorTests.Extract_CsharpInterpolatedAndVerbatimStrings_Issue264_Repro"passes.dotnet testsuite passes (1874 passed, 2 skipped).origin/main.Out of scope (filed separately)
${"foo\\\nbar"}) breaks hole scanner state #433 — JS/TS template-hole scanner does not carry line-continuation string state across lines (StructuralLineMasker.cs:1504/:1875). Surfaced by adversarial review during this PR but unrelated to C#: interpolated strings$"... {Foo()} ..."hide embedded call sites from the reference index; verbatim strings@"..."confuse the extractor on line continuations #264's C# scope.Closes #264