Repository navigation
Say what a value asked for as a base type or an interface is - #2483
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 14.x #2483 +/- ##
==========================================
+ Coverage 93.68% 93.70% +0.01%
==========================================
Files 279 279
Lines 7903 7905 +2
Branches 885 886 +1
==========================================
+ Hits 7404 7407 +3
Misses 310 310
+ Partials 189 188 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
danielcweber
force-pushed
the
fix/declared-type-for-base-types-contract
branch
from
October 1, 2026 02:34
e5a3b0b to
b5383f3
Compare
… it stands for The shared GraphSON tests asked for a value as the type it is, or as an object. What a g:Int32 is to an IComparable, a bare 5 to a ValueType or an array to the non-generic IEnumerable was pinned nowhere, and the two implementations disagreed about most of it. 51 tests now say what this implementation answers. As a snapshot of 5 does not say whether it is an int or a long, they record the type next to the value, through VerifyAttemptWithRuntimeType. - A typed value is the type its name stands for to everything that could hold that type: a g:Int32 is an int to an IComparable, a ValueType and an IEquatable<int>, a g:Float a float, a g:UUID a Guid, a g:Date a DateTimeOffset, a g:T a T to Gremlin.Net's EnumWrapper, a g:Tree a Tree<object> to the non-generic IEnumerable. - Where the requested type cannot hold that type, or the @value does not fit it, the bare @value is read instead: a g:UUID is a string to an IConvertible, and a g:Int32 "abc" a string to an IComparable. Nothing throws. Where the bare @value cannot be held either, there is no answer. - A bare scalar is to everything that could hold it what it is to an object: a string, a long or a double, a bool. A bare 5 is a long, so it is no IEquatable<int>. - The items of an array are read the same way. - An array, a g:List and a bulk set are an object[] to the non-generic IEnumerable, ICollection and IList. - An object, and a map whose keys are all strings, are a Dictionary<string, object> to the non-generic IDictionary, ICollection and IEnumerable. No implementation changes: all 51 are what this implementation answered before. Measured on the System.Text.Json implementation in Gremlinq.Extensions, which runs the same tests against the same snapshots: 47 of the 51 differ there today. It declines where a typed value or a bare scalar is asked for as an interface, hands out its own JsonElement for a ValueType and its own JsonMap for an object asked for as an IEnumerable, and builds a List<object> and a Dictionary<object, object> where an object[] and a Dictionary<string, object> are built here. Left out on purpose, because this implementation's answer is its own token rather than a value: a bare true or "abc" asked for as an IFormattable, any bare scalar but a string as an ICloneable or an IEnumerable, and an object as an IList or an ICloneable all come back as the JValue or JObject itself. A map keyed by ints, asked for as an IDictionary, comes back as an empty Dictionary<string, object>. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
danielcweber
force-pushed
the
fix/declared-type-for-base-types-contract
branch
from
October 1, 2026 03:21
b5383f3 to
48327a6
Compare
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.
The contract both GraphSON deserializers are tested against now says what a value is when it is asked for as a base type or an interface - an
IComparable, aValueType, anEnumWrapper, the non-genericIEnumerableorIDictionary- where it said nothing before and the two implementations disagreed. A typed value is the type its name stands for to everything that can hold that type: ag:Int32is anintto anIComparable, ag:TaTto anEnumWrapper. A bare scalar is what it is when asked for as an object. An array is anobject[]and an object aDictionary<string, object>to the non-generic collection interfaces.Changes
GraphsonSupportTestBase, afterDateTime_from_typed_Timestamp, andVerifyAttemptWithRuntimeType, which records the type of an answer next to its value - a snapshot of5does not say whether it is anintor along.g:Int32,g:Float,g:Double,g:UUID,g:Date,g:Timestampand thegx:numbers,gx:Durationandgx:Charasked for as anIComparable,IConvertible,IFormattable,ValueTypeorIEquatable<>of themselves;g:T,g:Directionandg:Mergeas anEnumWrapper;g:Treeas anIEnumerable.@valuedoes not fit it, the bare@valueis read instead - ag:UUIDis astringto anIConvertible, ag:Int32"abc"astringto anIComparable. Nothing throws.string, alongordoubleand aboolto whatever can hold one; a bare5is noIEquatable<int>. The items of anIComparable[]likewise.g:Listand a bulk set as anobject[]toIEnumerable,ICollectionandIList; an object and a map keyed by strings as aDictionary<string, object>toIDictionary,ICollectionandIEnumerable.Notes
srcchanges.trueor"abc"as anIFormattable, a bare number or bool as anICloneableorIEnumerable, and an object as anIListorICloneablecome back as theJValueorJObjectitself; a map keyed by ints as anIDictionarycomes back as an emptyDictionary<string, object>; an element map as anIDictionarycomes back rebuilt as{ id, label, properties }.🤖 Generated with Claude Code