mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 23:25:43 +00:00
fix: fix marshal of decimal for netstandard 2.1
This commit is contained in:
parent
caa0070458
commit
30b7a465a7
@ -1,4 +1,4 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace X10D.IO;
|
namespace X10D.IO;
|
||||||
@ -97,15 +97,22 @@ public static class DecimalExtensions
|
|||||||
#else
|
#else
|
||||||
Span<byte> buffer = stackalloc byte[16];
|
Span<byte> buffer = stackalloc byte[16];
|
||||||
MemoryMarshal.Write(buffer, ref value);
|
MemoryMarshal.Write(buffer, ref value);
|
||||||
|
WriteBits(destination, buffer);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteBits(Span<int> destination, Span<byte> buffer)
|
||||||
|
{
|
||||||
var flags = MemoryMarshal.Read<int>(buffer[..4]);
|
var flags = MemoryMarshal.Read<int>(buffer[..4]);
|
||||||
var hi = MemoryMarshal.Read<int>(buffer[4..8]);
|
var hi = MemoryMarshal.Read<int>(buffer[4..8]);
|
||||||
var lo = MemoryMarshal.Read<long>(buffer[8..]);
|
var lo = MemoryMarshal.Read<long>(buffer[8..]);
|
||||||
|
|
||||||
destination[0] = flags;
|
var low = (uint)lo;
|
||||||
destination[1] = hi;
|
var mid = (uint)(lo >> 32);
|
||||||
destination[2] = (int)(lo & 0xFFFFFFFF);
|
|
||||||
destination[3] = (int)(lo >> 32);
|
destination[0] = (int)low;
|
||||||
#endif
|
destination[1] = (int)mid;
|
||||||
|
destination[2] = hi;
|
||||||
|
destination[3] = flags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user