Unsafe.AsPointer and blittable value types passed by ref
Summary A developer proposed using Unsafe.AsPointer<T> to obtain a pointer to a ref readonly parameter of a blittable value type (where T : unmanaged) to copy data to a native buffer. They assumed this is safe because the value is blittable and lives on the stack, meaning the GC won’t relocate it. This assumption is … Read more