static void BufferLifetime(ReadOnlyBuffer <byte> buffer) { var array = buffer.ToArray(); using (var pinned = buffer.Retain(pin: true)) { unsafe { var p = (byte *)pinned.PinnedPointer; Assert.True(null != p); for (int i = 0; i < buffer.Length; i++) { Assert.Equal(array[i], p[i]); } } } }