Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public abstract ValueTask<TReadBufferState> ReadAsync(

public abstract void Advance(long bytesConsumed);

public abstract Utf8JsonReader GetReader(JsonReaderState jsonReaderState);
// This would normally be implemented as returning a Utf8JsonReader, but this pattern hits a limitation
// in mono aot that is not trivial to fix. For now use the alternative pattern of returning via an out
// argument. Tracking issue: https://github.com/dotnet/runtime/issues/118697
public abstract void GetReader(JsonReaderState jsonReaderState, out Utf8JsonReader reader);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ internal bool ContinueDeserialize<TReadBufferState, TStream>(
out T? value)
where TReadBufferState : struct, IReadBufferState<TReadBufferState, TStream>
{
Utf8JsonReader reader = bufferState.GetReader(jsonReaderState);
bufferState.GetReader(jsonReaderState, out Utf8JsonReader reader);

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ public async ValueTask<PipeReadBufferState> ReadAsync(PipeReader utf8Json, Cance

public void Read(PipeReader utf8Json) => throw new NotImplementedException();

public Utf8JsonReader GetReader(JsonReaderState jsonReaderState)
public void GetReader(JsonReaderState jsonReaderState, out Utf8JsonReader reader)
{
if (_sequence.IsSingleSegment)
{
return new Utf8JsonReader(
reader = new Utf8JsonReader(
#if NET
_sequence.FirstSpan,
#else
Expand All @@ -89,7 +89,7 @@ public Utf8JsonReader GetReader(JsonReaderState jsonReaderState)
}
else
{
return new Utf8JsonReader(_sequence, IsFinalBlock, jsonReaderState);
reader = new Utf8JsonReader(_sequence, IsFinalBlock, jsonReaderState);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ public void Advance(long bytesConsumed)
_offset = 0;
}

public Utf8JsonReader GetReader(JsonReaderState jsonReaderState)
public void GetReader(JsonReaderState jsonReaderState, out Utf8JsonReader reader)
{
return new Utf8JsonReader(
reader = new Utf8JsonReader(
_buffer.AsSpan(_offset, _count),
IsFinalBlock,
jsonReaderState);
Expand Down
Loading