Repository navigation
fix: a value declared as its factory interface is written as its literal in JSON (#581) - #598
Merged
CaffeinatedCoder merged 2 commits intoNov 30, 2026
Conversation
This reverts commit ae9473c, merge of PR #571, the port of #487 to release/10.x (reverting the mainline, -m 1). With the port, a final Select of ToRangeSet() ran in the database where it ran in memory on 10.4.0: a set holding int.MaxValue failed with 22003, and at the ends of a date type the result counted one range more. 10.5.0 is a stable minor and takes no changed answer, so the translation, the guard's bridge, its tests, seeds, claims, changelog lines, docs and the migration section go. The feature ships in 11.0.0 only. The one conflict was the bridge's alias line, which #573 made invariant; it goes with the bridge. The NodaTime EF changelog loses the "No change in this package." line the revert would have restored above #573's Fixed entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ral in JSON (#581) A property declared as IRangeFactory<TRange, T> or IValueSetFactory<TSet, T> was written as {} by System.Text.Json, with no error: the value was lost on write. The other interfaces of the package carry InterfaceDeclaredJsonConverter, which writes through the runtime type and refuses a read. These two did not, and JsonDefaultContractTests left them out on purpose, as interfaces whose static abstract members rule them out as a declared type. They rule them out as a type argument only (CS8920); a property, a field or a record parameter of such a type compiles. Both interfaces carry the attribute, and the converter handles them and names the right concrete type when it refuses a read. The convention test checks every interface of the core namespace that a range or a value set implements, handing the declared type over as a Type, which is how a property reaches the serializer. Port of #579 to release/10.x. Differences from main: 10.x has no IRangeSet, IRangeSetOperations, IRangeSetFactory or IRangeSetProducer, so the two attributes on the operations and range set factory interfaces, the converter's range set arm and the range set check of the convention test are left out, and a range variant has three of the package's interfaces, not four. The seed is factory-interface-without-json-converter (IRangeFactory), as operations-interface-without-json-converter patches a file this line does not have. The row is under ### Changed answers in [10.5.0], linking #581, with a new "Changed answers in 10.5.0" section in docs/migration.md comparing 10.4.0 and 10.5.0; claim M23 points at it. With either attribute removed, JsonDefaultContractTests fails naming the interface. Found-By: CA Defect-Class: JSON (cherry picked from commit 689a609) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 30, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #581
The port of #579 (PR #587, commit 689a609 on
main), cherry-picked with-xand adapted to this line. Merge after #597: this branch is built on it, because #597 removes the### Changed answerssection the revert of #487 leaves behind and this PR adds one back holding only this row. Until #597 merges, the diff here shows its commit too.Problem
On 10.x a property declared as
IRangeFactory<TRange, T>orIValueSetFactory<TSet, T>was written as{}by System.Text.Json, with no error, and nothing could read{}back. Neither interface carriedInterfaceDeclaredJsonConverter, whichIRange<T>, the shape interfaces andIValueSet<T>do, andJsonDefaultContractTestsskipped interfaces with static abstract members as "not declarable". They are not declarable as a type argument (CS8920); a property of such a type compiles.Change
As on
main: both interfaces carry[JsonConverter(typeof(InterfaceDeclaredJsonConverter))], the converter accepts them and names the right concrete type when it refuses a read, andJsonDefaultContractTestschecks every interface of the core namespace a range or value set implements.Differences from
main, where the cherry-pick conflicted or did not apply:IRangeSet,IRangeSetOperations,IRangeSetFactoryorIRangeSetProducer: their two attribute hunks, the converter's range set message arm, the convention test's range set check and the docs' mention of them are left out. A range variant has three of the package's interfaces (IRange<T>, its shape,IRangeFactory), not four.operations-interface-without-json-converterpatches a file this line lacks; this line hasfactory-interface-without-json-converter, stripping the attribute fromIRangeFactory.### Changed answersin[10.5.0](root and core), linking 10.x: a range or value set declared as its factory interface is written as {} in JSON (port of #579) #581 and the migration section, with the line 10.4.0 opens with.mainhas it under### Breakingof 11.0.0.docs/migration.md. A new## Changed answers in 10.5.0at the end, holding "Check JSON for a property declared as a factory interface", comparing 10.4.0 with 10.5.0 and without the bullet on the range set interfaces. Claim M23 points at it, worded for the factory interfaces only. The 10.5.0 carry PR owesmainthis section header.docs/serialization.md. "Before 10.5" wheremainsays "Before 11.0".Tests
JsonDefaultContractTestsfails with the attribute removed fromIRangeFactory(the seed: "DateRange.EmptyRange empty: declared as IRangeFactory2, the wire form differs") and, separately, fromIValueSetFactory("DateSet {}: declared as IValueSetFactory2, …"); passes with both.🤖 Generated with Claude Code