Background and motivation
In .NET 8.0, System.Text.Json source generator generates code to JSON serialize ReadOnlyMemory<byte> values the same way as byte[].
To avoid extra allocations, it would be nice to be able to JSON serialize ReadOnlySequence<byte> the same way.
Currently, the generator tries to write code to serialize ReadOnlySequence<byte>, which is not possible.
API Proposal
// System.Text.Json source generator code
// ...
API Usage
public class Dto
{
public ReadOnlySequence<byte> Data { get; set; }
}
[JsonSerializable(typeof(Dto))]
public partial class Class1JsonSerializationContext : JsonSerializerContext
{
}
Alternative Designs
No response
Risks
No response