Skip to content
Prev Previous commit
Next Next commit
Do not consult metadata LRU cache in JsonResumableConverter bridging …
…logic.
  • Loading branch information
eiriktsarpalis committed Jul 29, 2022
commit ba67f821e93f6d31876fdad59e2c01e8b0b6e5bf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ internal abstract class JsonResumableConverter<T> : JsonConverter<T>
// Bridge from resumable to value converters.

ReadStack state = default;
state.Initialize(typeToConvert, options, supportContinuation: false);
JsonTypeInfo jsonTypeInfo = options.GetTypeInfoInternal(typeToConvert);
state.Initialize(jsonTypeInfo);

TryRead(ref reader, typeToConvert, options, ref state, out T? value);
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,13 @@ private static async IAsyncEnumerable<TValue> CreateAsyncEnumerableDeserializer<
Debug.Assert(queueTypeInfo.IsConfigured);
JsonSerializerOptions options = queueTypeInfo.Options;
var bufferState = new ReadBufferState(options.DefaultBufferSize);
ReadStack readStack = default;
readStack.Initialize(queueTypeInfo, supportContinuation: true);
ReadStack readStack = new ReadStack
{
SupportContinuation = true
};

readStack.Initialize(queueTypeInfo);

var jsonReaderState = new JsonReaderState(options.GetReaderOptions());

try
Expand Down Expand Up @@ -470,8 +475,11 @@ private static async IAsyncEnumerable<TValue> CreateAsyncEnumerableDeserializer<
Debug.Assert(jsonTypeInfo.IsConfigured);
JsonSerializerOptions options = jsonTypeInfo.Options;
var bufferState = new ReadBufferState(options.DefaultBufferSize);
ReadStack readStack = default;
readStack.Initialize(jsonTypeInfo, supportContinuation: true);
ReadStack readStack = new ReadStack
{
SupportContinuation = true
};
readStack.Initialize(jsonTypeInfo);
var jsonReaderState = new JsonReaderState(options.GetReaderOptions());

try
Expand Down Expand Up @@ -500,8 +508,11 @@ private static async IAsyncEnumerable<TValue> CreateAsyncEnumerableDeserializer<
Debug.Assert(jsonTypeInfo.IsConfigured);
JsonSerializerOptions options = jsonTypeInfo.Options;
var bufferState = new ReadBufferState(options.DefaultBufferSize);
ReadStack readStack = default;
readStack.Initialize(jsonTypeInfo, supportContinuation: true);
ReadStack readStack = new ReadStack
{
SupportContinuation = true
};
readStack.Initialize(jsonTypeInfo);
var jsonReaderState = new JsonReaderState(options.GetReaderOptions());

try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,7 @@ private void EnsurePushCapacity()
}
}

public void Initialize(Type type, JsonSerializerOptions options, bool supportContinuation)
{
JsonTypeInfo jsonTypeInfo = options.GetTypeInfoForRootType(type);
Initialize(jsonTypeInfo, supportContinuation);
}

internal void Initialize(JsonTypeInfo jsonTypeInfo, bool supportContinuation = false)
internal void Initialize(JsonTypeInfo jsonTypeInfo)
{
JsonSerializerOptions options = jsonTypeInfo.Options;
if (options.ReferenceHandlingStrategy == ReferenceHandlingStrategy.Preserve)
Expand All @@ -108,7 +102,6 @@ internal void Initialize(JsonTypeInfo jsonTypeInfo, bool supportContinuation = f
PreserveReferences = true;
}

SupportContinuation = supportContinuation;
Current.JsonTypeInfo = jsonTypeInfo;
Current.JsonPropertyInfo = jsonTypeInfo.PropertyInfoForTypeInfo;
Current.NumberHandling = Current.JsonPropertyInfo.EffectiveNumberHandling;
Expand Down