Repository navigation
Description
Summary
In a verbatim interpolated string ($@"…" / @$"…"), an escaped quote "" that sits
immediately after an interpolation hole's closing } and immediately before the string
terminator is rejected by the bundled tree-sitter-c-sharp 0.23.5 grammar. In short: the
literal ends with }""".
It is valid C#, dotnet build is happy, and every neighbouring spelling parses. The file it
appears in is partially extracted, so the members after the offending line are missing from
graph.json.
The reported line is the recovery point, not the cause. In my case the construct is on lines
72 and 83 and the warning said first error at line 76, which sent me looking at an
[InlineData("Config")] attribute for a while.
Reproduction — grammar level
graphify 0.9.46, tree-sitter-c-sharp 0.23.5. No extraction run needed:
from tree_sitter import Language, Parser
import tree_sitter_c_sharp as tscs
p = Parser(Language(tscs.language()))
W = 'class C { void M(string e) { var s = %s; } }\n'
def check(lit):
print("ERROR" if p.parse((W % lit).encode()).root_node.has_error else "ok ", lit)
check(r'$@"a""{e}"""') # ERROR <-- valid C#, the real-world shape
check(r'$@"a{e}"""') # ERROR
check(r'$@"{e}"""') # ERROR
check(r'@$"a""{e}"""') # ERROR (other prefix order, same failure)
check(r'$@"a{e}""b"') # ok escape after the hole, but not at the end
check(r'$@"a{e}b"""') # ok escape at the end, but text between hole and escape
check(r'$@"{e}=""x"""') # ok hole and a trailing escape, hole not adjacent to it
check(r'$@"a""{e}""b"') # ok escape, hole, escape - not at the end
check(r'$@"a""x"""') # ok escape at the end, no hole at all
check(r'$@"a{e}"') # ok hole, no escape
check(r'@"a{e}"""') # ok no `$`, so `{e}` is literal text
check(r'$"a\"{e}\""') # ok regular interpolated string
check(r'$$"""a={{e}}"""')# ok raw interpolated stringEach passing line differs from a failing one in exactly one property, so the trigger is
neither "verbatim interpolated string" nor "escape at the end" nor "escape plus hole" on its
own — it is specifically the } "" " adjacency.
What it costs
Small but silent-ish, and it hides in a construct that is idiomatic wherever a test asserts on
a quoted attribute:
Assert.Contains($@"Content=""{expected}""", xaml); // XAML / XML / HTML attribute needleOn a 258-file C#/WPF repo it is 1 file — but that one file is the project's UI-language guard,
and the agent instructions for this repo tell the assistant to query the graph before reading
source. A guard that is only partially in the graph is worse than one that is absent, because
nothing signals the gap at query time.
The #2551 warning did its job here: without that line I would have had no reason to suspect
the parser at all. Same class as #2551 (Kotlin one-line type bodies) and #2520 (.luau),
different language and trigger.
Workaround
A regular interpolated string with backslash escapes is byte-identical in output and parses:
Assert.Contains($@"Content=""{expected}""", xaml); // trips the grammar
Assert.Contains($"Content=\"{expected}\"", xaml); // same string, parsesEnvironment
| graphify | 0.9.46 |
| tree-sitter | 0.26.0 |
| tree-sitter-c-sharp | 0.23.5 |
| OS | Windows 10 22H2 |
| Python | 3.12 |
Activity
rohit-jsfreaky commentedon Sep 16, 2026
Ran your grammar table verbatim on tree-sitter-c-sharp 0.23.5 — all four failing spellings error, all nine neighbours parse. The
}"""adjacency is exactly it.The extraction cost shows up as you describe. A class with six methods and the literal in the third:
0.23.5 is the newest release on PyPI and the pin already allows
<0.25, so there is no grammar bump to take.Opening a PR that neutralizes only the trailing
""escape, through thesource_overrideseamextract_js/extract_vue/extract_cppalready use. It is byte-length preserving, so nosource_locationshifts — on the file above exactly 2 bytes change and every member still reports the line it is really on. It also steps aside entirely when a file already parses, and falls back to the original if the rewrite does not clear the errors.To be clear about scope: this does not fix the grammar, which is where the bug really is. It stops graphify silently dropping symbols while the grammar is what it is. If you would rather wait for an upstream fix, that is a reasonable call.
perf(csharp): resume past the \$/@ prefix run so malformed files stay…
fix(csharp): extract past a verbatim interpolated string ending in an…
perf(csharp): resume past the \$/@ prefix run so malformed files stay…
fix(csharp): extract past a verbatim interpolated string ending in an…
perf(csharp): resume past the \$/@ prefix run so malformed files stay…
safishamsi commentedon Oct 12, 2026
Fixed in v0.9.88 (
graphifyy 0.9.88on PyPI) via #3612.fix(pascal): recover units the grammar cannot parse end to end