Add GetStream(ReadOnlyMemory<byte>) or replace GetStream(Memory<byte>)
80O opened this issue · 1 comments
80O commented
As far as I have understood the documentation, the buffer given using GetStream(Memory<byte>)
will be copied into the stream. If thats the case, ReadOnlyMemory<byte>
should be sufficient.
I think this would also help the API to make it more clear that the buffer given to initialize the stream won't be used any further.
I'm stuck with an API that gives me an ReadOnlyMemory<byte>
buffer which I want to use to initialize the stream.
grbell-ms commented
That's a good point. We will fix that in a later release.
In the meantime, you can use MemoryMarshal.AsMemory as a workaround:
ReadOnlyMemory<byte> mem;
RecyclableMemoryStreamManager manager;
// ...
var stream = manager.GetStream(MemoryMarshal.AsMemory(mem));