Skip to content

Fix #264: lock in C# interpolated/verbatim string reference extraction - #434

Merged
Widthdom merged 3 commits into
mainfrom
fix/issue-264-string-interpolation
Apr 18, 2026
Merged

Fix #264: lock in C# interpolated/verbatim string reference extraction#434
Widthdom merged 3 commits into
mainfrom
fix/issue-264-string-interpolation

Conversation

@Widthdom

Copy link
Copy Markdown
Owner

Summary

  • Issue C#: interpolated strings $"... {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.
  • After inspection, the current StructuralLineMasker (C# branch) and PrepareLine already handle all four forms correctly. Running the repro through the current binary shows the reported defects no longer reproduce.
  • This PR locks in the behavior with a dedicated regression fixture covering single-line and multi-line forms in both $@ and @$ orderings, and documents the fix in the changelog so accidental future reversions surface immediately.

Changes

  • tests/CodeIndex.Tests/ReferenceExtractorTests.cs — new Extract_CsharpInterpolatedAndVerbatimStrings_Issue264_Repro_CapturesHoleCallsAndSuppressesPhantoms fixture:
    • $"..." 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 rows
    • Container names resolve to the enclosing method
  • CHANGELOG.md — Unreleased entry under #### Fixed (English and Japanese).

Test plan

  • dotnet build succeeds.
  • dotnet test --filter "FullyQualifiedName~ReferenceExtractorTests.Extract_CsharpInterpolatedAndVerbatimStrings_Issue264_Repro" passes.
  • Full dotnet test suite passes (1874 passed, 2 skipped).
  • Branch rebased cleanly onto latest origin/main.

Out of scope (filed separately)

Closes #264

Widthdom and others added 3 commits April 18, 2026 17:09
…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.
@Widthdom
Widthdom merged commit 4b47079 into main Apr 18, 2026
5 checks passed
@Widthdom
Widthdom deleted the fix/issue-264-string-interpolation branch April 18, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant