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
Metadata parse-failure diagnostic has no location, so malformed JSON can't be clicked through to the bad line #28
MetadataFile.Deserialize<T> (SourceGeneratorToolkit/MetadataFile.cs, the local ParseFailed function) reports the parse failure with context.Report(parseFailed, FileName, ex.Message). DiagnosticCatalog.Report always reports at Location.None (DiagnosticCatalog.cs:103).
For a JsonException, the exception already carries LineNumber and BytePositionInLine. MetadataFile also already has the text and a LocationAt(index, length) helper, which it uses to make its other diagnostics navigable. The toolkit's most common diagnostic is the one that isn't navigable, even though the README advertises navigable diagnostics.
Failure scenario
A things.json containing {"things": [1,,2]} on line 3 produces a MetadataParseFailed diagnostic with no file or line in the IDE error list. The only pointer is the "LineNumber: 2 | BytePositionInLine: …" text buried in the message, and double-clicking goes nowhere.
Suggested fix / acceptance criteria
In the JsonException branch, when ex.LineNumber has a value and the text is available, compute an offset from ex.LineNumber and ex.BytePositionInLine and report with ReportAt at that location.
BytePositionInLine counts UTF-8 bytes, so convert it to a character offset on non-ASCII lines.
Clamp the offset to the line length.
Keep Location.None for the NotSupportedException, InvalidOperationException and null-document cases, and for a JsonException without a line number.
Test: malformed JSON on line 3 produces a diagnostic whose Location.GetLineSpan() has the metadata file's path and StartLinePosition.Line == 2.
Suggested next step: implement it as described. Take care with the conversion from UTF-8 bytes to characters and with clamping, and add the line-3 test.
Activity
matt-edmondson commentedon Sep 28, 2026
Triage
ParseFailed/JsonExceptionbranch ofMetadataFile.Deserialize<T>, using the existingLocationAthelper.Suggested next step: implement it as described. Take care with the conversion from UTF-8 bytes to characters and with clamping, and add the line-3 test.
Generated by Claude Code