public static unsafe void ReadNoAlloc(this Stream stream, byte* bytes, int offset, int count)
{
var buffer = Buffer;
int readCount = 0;
int write = offset;
int writeEnd = offset + count;
while (write != writeEnd)
{
readCount = Math.Min(count, buffer.Length);
stream.Read(buffer, 0, readCount);
count -= readCount;
for (int i = 0; i < readCount; ++i)
{
Debug.Assert(write < writeEnd);
bytes[write++] = buffer[i];
}
}
}