I'd like to propose changing the contract of ISerializer to useReadOnlySpan<T> instead of byte[].
Since System.Memory is not out yet (RTM's expected with .NET Core 2.1), obviously none of the current implementations (JSON, Xml, ProtoBuf) will actually take advantage of that. It would be great though to already use ReadOnlySpan<T> on the contract to avoid any breaking changes related to this.
When support comes from underlying libraries, we'd only change the implementations to avoid the span.ToArray() calls.
It seems to me that it doesn't make sense to expose ReadOnlySpan<T> and also byte[] so I suggest we go ahead and change the current ISerializer.
I've changed the contract to get an idea of the change: https://github.com/Greentube/serialization/tree/system.memory
Some tests break though, with:
typeof(System.InvalidProgramException): Common Language Runtime detected an invalid program.
I haven't investigated or filed a bug yet.
I'd like to propose changing the contract of
ISerializerto useReadOnlySpan<T>instead ofbyte[].Since
System.Memoryis not out yet (RTM's expected with .NET Core 2.1), obviously none of the current implementations (JSON, Xml, ProtoBuf) will actually take advantage of that. It would be great though to already useReadOnlySpan<T>on the contract to avoid any breaking changes related to this.When support comes from underlying libraries, we'd only change the implementations to avoid the
span.ToArray()calls.It seems to me that it doesn't make sense to expose
ReadOnlySpan<T>and alsobyte[]so I suggest we go ahead and change the currentISerializer.I've changed the contract to get an idea of the change: https://github.com/Greentube/serialization/tree/system.memory
Some tests break though, with:
I haven't investigated or filed a bug yet.