Commit c6ce7fc
fix(csharp): pre-merge review — JsonSource length-1 invariant + null-source fallback
Two cross-port drifts surfaced by the pre-merge review of FR5a, both
worth fixing now while only two ports (TS + C#) have to stay in sync.
1. Parser.cs ParseState.CurrentSource() returned a JsonSource with an
empty Files array when the parser was invoked without a source id
(e.g. parsing from a string buffer in tests). That violates the FR5a
length-1 invariant and produces an envelope shape no other port
emits. TS reference (parser-core.ts:104-114) falls back to the
default CodeSource in the same case. C# now matches.
2. ErrorSource.cs JsonSource.Files was typed IReadOnlyList<string> with
a Javadoc invariant ("FR5a invariant: exactly one file") that the
type didn't enforce. Combined with #1 the type system allowed the
bad shape through. Added a constructor-init validator that throws
ArgumentException when Files.Count != 1, pointing callers at
MergedSource for multi-file provenance (FR5c).
Verification: C# all 4 projects 561/561 still green (Conformance 302
including the 26 new FR5a tests + Render 88 + Codegen 164 + Cli 7).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 8f41f31 commit c6ce7fc
2 files changed
Lines changed: 17 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
138 | | - | |
| 141 | + | |
139 | 142 | | |
140 | 143 | | |
141 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
31 | 42 | | |
32 | 43 | | |
33 | 44 | | |
| |||
0 commit comments