Uh oh!
There was an error while loading. Please reload this page.
Support resumable serialization in NullableConverter<T> - #65524
Conversation
ghost
commented
Feb 17, 2022
Tagging subscribers to this area: @dotnet/area-system-text-json Issue DetailsMakes NullableConverter support resumable serialization, adapting an approach followed by the existing FSharpOptionConverter. Fix #65522.
|
| protected static JsonConverter<TElement> GetElementConverter(ref WriteStack state) | ||
| { | ||
| JsonConverter<TElement> converter = (JsonConverter<TElement>)state.Current.DeclaredJsonPropertyInfo!.ConverterBase; | ||
| JsonConverter<TElement> converter = (JsonConverter<TElement>)state.Current.JsonPropertyInfo!.ConverterBase; |
There was a problem hiding this comment.
This renames a property I should have renamed in #65224 and matches the naming convention by the equivalent property in ReadStackFrame.
| #endif | ||
| state.Push(); | ||
| Debug.Assert(TypeToConvert.IsAssignableFrom(state.Current.JsonTypeInfo.Type)); | ||
| Debug.Assert(TypeToConvert == state.Current.JsonTypeInfo.Type); |
There was a problem hiding this comment.
Strengthens an assertion that should have been changed via #65224.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| { | ||
| internal sealed class NullableConverter<T> : JsonConverter<T?> where T : struct | ||
| { | ||
| internal override ConverterStrategy ConverterStrategy { get; } |
There was a problem hiding this comment.
I assume the ConverterStrategy is determined by the value held by Nullable? I.e. it can be Value, Object, Collection.
| } | ||
| [Theory] | ||
| [MemberData(nameof(GetAsyncEnumerableSources))] |
There was a problem hiding this comment.
Should there be a non-IAsyncEnumerable test added that can verify a larger, nullable POCO (as a value type)?
There was a problem hiding this comment.
Nullable POCOs still work, however they don't flow the state. This becomes more evident in the case of IAE which simply fails serialization.
Makes NullableConverter support resumable serialization, adapting an approach followed by the existing FSharpOptionConverter.
Fix#65522.