You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MetadataFile.FindLocation points at text inside // and /* */ comments, and a " in a comment sends a scoped lookup to the wrong entry #78
FindLocation("Yard", "Meter") returns line 5 (0-based, Rod's entry); expected line 4 (Yard's). The comment's quote makes Yard's { look like string content, the enclosing object becomes the root, and the search lands in the next entry. Remove the comment line and the same call is correct.
Unscoped, location inside the comment:
{
// "Metre" is the British spelling"things": [ { "name": "Metre" } ]
}
FindLocation("Metre") points at line 1, inside the comment; expected line 2.
Why it matters
A generator reporting "Yard has a bad base unit" sends the user's click to Rod's entry or to a comment, in exactly the hand-annotated files #69 set out to support.
Suggested fix
One forward lexer over Text that tracks string, escape, line-comment and block-comment state; build TryGetEnclosingObject and the token search on it (or precompute a mask of comment spans and skip matches that start inside one).
Acceptance criteria
Tests for: a " inside a // comment between entries (scoped lookup lands on the right entry); a quoted needle mentioned in a // comment and in a /* */ comment (location is the real entry)
Area / suggested owner:SourceGeneratorToolkit/MetadataFile.cs: TryGetEnclosingObject and IndexOfToken. Add a single forward lexer, or a mask of comment spans, that tracks string, escape, line-comment and block-comment state.
Activity
matt-edmondson commentedon Nov 12, 2026
Triage
SourceGeneratorToolkit/MetadataFile.cs:TryGetEnclosingObjectandIndexOfToken. Add a single forward lexer, or a mask of comment spans, that tracks string, escape, line-comment and block-comment state.C:\temp,say "hi", and System.Text.Json-written non-ASCII names likeΩ·m²can't be located #68, which open PR Find metadata values the file writes with JSON escapes [patch] #76 is fixing. Find metadata values the file writes with JSON escapes [patch] #76 rewritesIndexOfToken, the same search this issue needs to make comment-aware, so build this on top of Find metadata values the file writes with JSON escapes [patch] #76 once it merges, or fold it into Find metadata values the file writes with JSON escapes [patch] #76, to avoid conflicts.Generated by Claude Code