private unsafe void CheckAlignment <T>(int alignment) where T : unmanaged { ValueBuffer <T> t = new ValueBuffer <T>(); try { t.EnsureCapacity(42); void *p = Unsafe.AsPointer(ref t.Span[0]); ulong address = (ulong)p; int sizeOfT = Unsafe.SizeOf <T>(); int offset = (int)(address % (ulong)alignment); offset.Should().Be(0); } finally { t.Dispose(); } }