public unsafe int Serialize(ref byte[] bytes, int offset, T value, IFormatterResolver formatterResolver) { var headerSize = MessagePackBinaryEx.WriteBytesHeaderWithEnsureCount(ref bytes, offset, size); Unsafe.WriteUnaligned(ref Unsafe.Add(ref bytes[0], offset + headerSize), value); return(headerSize + size); }
public unsafe int Serialize(ref byte[] bytes, int offset, T value, IFormatterResolver formatterResolver) { var headerSize = MessagePackBinaryEx.WriteBytesHeaderWithEnsureCount(ref bytes, offset, size); fixed(void *p = &bytes[offset + headerSize]) { UnsafeUtility.CopyStructureToPtr(ref value, p); } return(headerSize + size); }