Proposed API
namespaceSystem.Net.Sockets{publicclassSendPacketsElement{// Existing APIs:publicSendPacketsElement(byte[]buffer);publicSendPacketsElement(byte[]buffer,intoffset,intcount);publicSendPacketsElement(byte[]buffer,intoffset,intcount,boolendOfPacket);publicbyte[]?Buffer{get;}publicintOffset{get;}publicintCount{get;}// Proposed APIs:publicSendPacketsElement(ReadOnlyMemory<byte>buffer);publicSendPacketsElement(ReadOnlyMemory<byte>buffer,boolendOfPacket);publicReadOnlyMemory<byte>?MemoryBuffer{get;}}}This is modeled on how we added Memory support to SocketAsyncEventArgs.
If you use a new Memory constructor overload, then:
- MemoryBuffer will return the ReadOnlyMemory that you passed to the constructor
- Buffer will return null
- Offset will return 0
- Count will return MemoryBuffer.Length
If you use an old byte[] constructor overload, then:
- MemoryBuffer will return a ReadOnlyMemory constructed from the byte[], offset, and count you passed to the constructor.
- Buffer, Offset, and Count will return the values you passed to the constructor (as today)
Proposed API
This is modeled on how we added Memory support to SocketAsyncEventArgs.
If you use a new Memory constructor overload, then:
If you use an old byte[] constructor overload, then: