From 2f78ddc53c7d10bd40c2901f28cb0c1372c80b2f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Jul 2026 19:09:52 +0000 Subject: [PATCH 1/4] feat: add BinaryPrimitives polyfills --- .../NetCore21/BinaryPrimitivesTests.cs | 308 +++++++++ PolyShim/Net50/BinaryPrimitives.cs | 22 + PolyShim/NetCore21/BinaryPrimitives.cs | 639 ++++++++++++++++++ Signatures.md | 10 +- 4 files changed, 976 insertions(+), 3 deletions(-) create mode 100644 PolyShim.Tests/NetCore21/BinaryPrimitivesTests.cs create mode 100644 PolyShim/Net50/BinaryPrimitives.cs create mode 100644 PolyShim/NetCore21/BinaryPrimitives.cs diff --git a/PolyShim.Tests/NetCore21/BinaryPrimitivesTests.cs b/PolyShim.Tests/NetCore21/BinaryPrimitivesTests.cs new file mode 100644 index 0000000..c7fc181 --- /dev/null +++ b/PolyShim.Tests/NetCore21/BinaryPrimitivesTests.cs @@ -0,0 +1,308 @@ +using System; +using System.Buffers.Binary; +using FluentAssertions; +using Xunit; + +namespace PolyShim.Tests.NetCore21; + +public class BinaryPrimitivesTests +{ + [Fact] + public void ReverseEndianness_Int16_Test() + { + BinaryPrimitives.ReverseEndianness((short)0x1234).Should().Be(0x3412); + BinaryPrimitives.ReverseEndianness((short)0x0000).Should().Be(0x0000); + BinaryPrimitives.ReverseEndianness(unchecked((short)0xFF00)).Should().Be(0x00FF); + } + + [Fact] + public void ReverseEndianness_UInt16_Test() + { + BinaryPrimitives.ReverseEndianness((ushort)0x1234).Should().Be(0x3412); + BinaryPrimitives.ReverseEndianness((ushort)0xFF00).Should().Be(0x00FF); + } + + [Fact] + public void ReverseEndianness_Int32_Test() + { + BinaryPrimitives.ReverseEndianness(0x12345678).Should().Be(0x78563412); + BinaryPrimitives.ReverseEndianness(0x00000000).Should().Be(0x00000000); + BinaryPrimitives.ReverseEndianness(unchecked((int)0xFF000000)).Should().Be(0x000000FF); + } + + [Fact] + public void ReverseEndianness_UInt32_Test() + { + BinaryPrimitives.ReverseEndianness(0x12345678U).Should().Be(0x78563412U); + BinaryPrimitives.ReverseEndianness(0xFF000000U).Should().Be(0x000000FFU); + } + + [Fact] + public void ReverseEndianness_Int64_Test() + { + BinaryPrimitives.ReverseEndianness(0x0102030405060708L).Should().Be(0x0807060504030201L); + BinaryPrimitives.ReverseEndianness(0L).Should().Be(0L); + } + + [Fact] + public void ReverseEndianness_UInt64_Test() + { + BinaryPrimitives.ReverseEndianness(0x0102030405060708UL).Should().Be(0x0807060504030201UL); + BinaryPrimitives.ReverseEndianness(0UL).Should().Be(0UL); + } + + [Fact] + public void ReadInt16BigEndian_Test() + { + byte[] bytes = [0x12, 0x34, 0xFF]; + BinaryPrimitives.ReadInt16BigEndian(bytes).Should().Be(0x1234); + } + + [Fact] + public void ReadInt16LittleEndian_Test() + { + byte[] bytes = [0x34, 0x12, 0xFF]; + BinaryPrimitives.ReadInt16LittleEndian(bytes).Should().Be(0x1234); + } + + [Fact] + public void ReadUInt16BigEndian_Test() + { + byte[] bytes = [0xFF, 0x00]; + BinaryPrimitives.ReadUInt16BigEndian(bytes).Should().Be(0xFF00); + } + + [Fact] + public void ReadUInt16LittleEndian_Test() + { + byte[] bytes = [0x00, 0xFF]; + BinaryPrimitives.ReadUInt16LittleEndian(bytes).Should().Be(0xFF00); + } + + [Fact] + public void ReadInt32BigEndian_Test() + { + byte[] bytes = [0x12, 0x34, 0x56, 0x78]; + BinaryPrimitives.ReadInt32BigEndian(bytes).Should().Be(0x12345678); + } + + [Fact] + public void ReadInt32LittleEndian_Test() + { + byte[] bytes = [0x78, 0x56, 0x34, 0x12]; + BinaryPrimitives.ReadInt32LittleEndian(bytes).Should().Be(0x12345678); + } + + [Fact] + public void ReadUInt32BigEndian_Test() + { + byte[] bytes = [0xFF, 0x00, 0xFF, 0x00]; + BinaryPrimitives.ReadUInt32BigEndian(bytes).Should().Be(0xFF00FF00U); + } + + [Fact] + public void ReadUInt32LittleEndian_Test() + { + byte[] bytes = [0x00, 0xFF, 0x00, 0xFF]; + BinaryPrimitives.ReadUInt32LittleEndian(bytes).Should().Be(0xFF00FF00U); + } + + [Fact] + public void ReadInt64BigEndian_Test() + { + byte[] bytes = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]; + BinaryPrimitives.ReadInt64BigEndian(bytes).Should().Be(0x0102030405060708L); + } + + [Fact] + public void ReadInt64LittleEndian_Test() + { + byte[] bytes = [0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01]; + BinaryPrimitives.ReadInt64LittleEndian(bytes).Should().Be(0x0102030405060708L); + } + + [Fact] + public void ReadUInt64BigEndian_Test() + { + byte[] bytes = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]; + BinaryPrimitives.ReadUInt64BigEndian(bytes).Should().Be(0x0102030405060708UL); + } + + [Fact] + public void ReadUInt64LittleEndian_Test() + { + byte[] bytes = [0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01]; + BinaryPrimitives.ReadUInt64LittleEndian(bytes).Should().Be(0x0102030405060708UL); + } + + [Fact] + public void ReadSingleBigEndian_Test() + { + // 1.0f in IEEE 754: 0x3F800000 + byte[] bytes = [0x3F, 0x80, 0x00, 0x00]; + BinaryPrimitives.ReadSingleBigEndian(bytes).Should().Be(1.0f); + } + + [Fact] + public void ReadSingleLittleEndian_Test() + { + // 1.0f in IEEE 754: 0x3F800000 (little-endian bytes) + byte[] bytes = [0x00, 0x00, 0x80, 0x3F]; + BinaryPrimitives.ReadSingleLittleEndian(bytes).Should().Be(1.0f); + } + + [Fact] + public void ReadDoubleBigEndian_Test() + { + // 1.0 in IEEE 754: 0x3FF0000000000000 + byte[] bytes = [0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + BinaryPrimitives.ReadDoubleBigEndian(bytes).Should().Be(1.0); + } + + [Fact] + public void ReadDoubleLittleEndian_Test() + { + // 1.0 in IEEE 754: 0x3FF0000000000000 (little-endian bytes) + byte[] bytes = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F]; + BinaryPrimitives.ReadDoubleLittleEndian(bytes).Should().Be(1.0); + } + + [Fact] + public void TryReadInt32BigEndian_TooShort_Test() + { + byte[] bytes = [0x01, 0x02]; + BinaryPrimitives.TryReadInt32BigEndian(bytes, out _).Should().BeFalse(); + } + + [Fact] + public void TryReadInt32BigEndian_Success_Test() + { + byte[] bytes = [0x12, 0x34, 0x56, 0x78]; + BinaryPrimitives.TryReadInt32BigEndian(bytes, out var value).Should().BeTrue(); + value.Should().Be(0x12345678); + } + + [Fact] + public void TryReadInt64LittleEndian_TooShort_Test() + { + byte[] bytes = [0x01, 0x02, 0x03, 0x04]; + BinaryPrimitives.TryReadInt64LittleEndian(bytes, out _).Should().BeFalse(); + } + + [Fact] + public void WriteInt16BigEndian_Test() + { + var buf = new byte[2]; + BinaryPrimitives.WriteInt16BigEndian(buf, 0x1234); + buf.Should().Equal(0x12, 0x34); + } + + [Fact] + public void WriteInt16LittleEndian_Test() + { + var buf = new byte[2]; + BinaryPrimitives.WriteInt16LittleEndian(buf, 0x1234); + buf.Should().Equal(0x34, 0x12); + } + + [Fact] + public void WriteInt32BigEndian_Test() + { + var buf = new byte[4]; + BinaryPrimitives.WriteInt32BigEndian(buf, 0x12345678); + buf.Should().Equal(0x12, 0x34, 0x56, 0x78); + } + + [Fact] + public void WriteInt32LittleEndian_Test() + { + var buf = new byte[4]; + BinaryPrimitives.WriteInt32LittleEndian(buf, 0x12345678); + buf.Should().Equal(0x78, 0x56, 0x34, 0x12); + } + + [Fact] + public void WriteInt64BigEndian_Test() + { + var buf = new byte[8]; + BinaryPrimitives.WriteInt64BigEndian(buf, 0x0102030405060708L); + buf.Should().Equal(0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08); + } + + [Fact] + public void WriteInt64LittleEndian_Test() + { + var buf = new byte[8]; + BinaryPrimitives.WriteInt64LittleEndian(buf, 0x0102030405060708L); + buf.Should().Equal(0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01); + } + + [Fact] + public void WriteSingleBigEndian_Test() + { + var buf = new byte[4]; + BinaryPrimitives.WriteSingleBigEndian(buf, 1.0f); + // 1.0f IEEE 754: 0x3F800000 + buf.Should().Equal(0x3F, 0x80, 0x00, 0x00); + } + + [Fact] + public void WriteSingleLittleEndian_Test() + { + var buf = new byte[4]; + BinaryPrimitives.WriteSingleLittleEndian(buf, 1.0f); + // 1.0f IEEE 754 little-endian + buf.Should().Equal(0x00, 0x00, 0x80, 0x3F); + } + + [Fact] + public void WriteDoubleBigEndian_Test() + { + var buf = new byte[8]; + BinaryPrimitives.WriteDoubleBigEndian(buf, 1.0); + // 1.0 IEEE 754: 0x3FF0000000000000 + buf.Should().Equal(0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); + } + + [Fact] + public void WriteDoubleLittleEndian_Test() + { + var buf = new byte[8]; + BinaryPrimitives.WriteDoubleLittleEndian(buf, 1.0); + // 1.0 IEEE 754 little-endian + buf.Should().Equal(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F); + } + + [Fact] + public void TryWriteInt32BigEndian_TooShort_Test() + { + var buf = new byte[2]; + BinaryPrimitives.TryWriteInt32BigEndian(buf, 0x12345678).Should().BeFalse(); + } + + [Fact] + public void TryWriteInt32BigEndian_Success_Test() + { + var buf = new byte[4]; + BinaryPrimitives.TryWriteInt32BigEndian(buf, 0x12345678).Should().BeTrue(); + buf.Should().Equal(0x12, 0x34, 0x56, 0x78); + } + + [Fact] + public void ReadWrite_RoundTrip_Int32BigEndian_Test() + { + var value = -123456789; + var buf = new byte[4]; + BinaryPrimitives.WriteInt32BigEndian(buf, value); + BinaryPrimitives.ReadInt32BigEndian(buf).Should().Be(value); + } + + [Fact] + public void ReadWrite_RoundTrip_DoubleBigEndian_Test() + { + var value = Math.PI; + var buf = new byte[8]; + BinaryPrimitives.WriteDoubleBigEndian(buf, value); + BinaryPrimitives.ReadDoubleBigEndian(buf).Should().Be(value); + } +} diff --git a/PolyShim/Net50/BinaryPrimitives.cs b/PolyShim/Net50/BinaryPrimitives.cs new file mode 100644 index 0000000..54974b4 --- /dev/null +++ b/PolyShim/Net50/BinaryPrimitives.cs @@ -0,0 +1,22 @@ +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +#pragma warning disable CS0436 + +using System.Buffers.Binary; +using System.Diagnostics.CodeAnalysis; + +#if !POLYSHIM_INCLUDE_COVERAGE +[ExcludeFromCodeCoverage] +#endif +internal static class MemberPolyfills_Net50_BinaryPrimitives +{ + extension(BinaryPrimitives) + { + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-byte) + public static byte ReverseEndianness(byte value) => value; + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-sbyte) + public static sbyte ReverseEndianness(sbyte value) => value; + } +} +#endif diff --git a/PolyShim/NetCore21/BinaryPrimitives.cs b/PolyShim/NetCore21/BinaryPrimitives.cs new file mode 100644 index 0000000..ba1acfe --- /dev/null +++ b/PolyShim/NetCore21/BinaryPrimitives.cs @@ -0,0 +1,639 @@ +#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) || NETFRAMEWORK +#nullable enable +#pragma warning disable CS0436 + +using System.Diagnostics.CodeAnalysis; + +namespace System.Buffers.Binary; + +// https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives +#if !POLYSHIM_INCLUDE_COVERAGE +[ExcludeFromCodeCoverage] +#endif +internal static class BinaryPrimitives +{ + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-int16) + public static short ReverseEndianness(short value) => + (short)(((value & 0x00FF) << 8) | ((value >> 8) & 0x00FF)); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-uint16) + public static ushort ReverseEndianness(ushort value) => + (ushort)(((value & 0x00FFU) << 8) | ((value >> 8) & 0x00FFU)); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-int32) + public static int ReverseEndianness(int value) => (int)ReverseEndianness((uint)value); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-uint32) + public static uint ReverseEndianness(uint value) => + ((value & 0x000000FFU) << 24) + | ((value & 0x0000FF00U) << 8) + | ((value & 0x00FF0000U) >> 8) + | ((value & 0xFF000000U) >> 24); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-int64) + public static long ReverseEndianness(long value) => (long)ReverseEndianness((ulong)value); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-uint64) + public static ulong ReverseEndianness(ulong value) => + ((ulong)ReverseEndianness((uint)(value & 0xFFFFFFFFUL)) << 32) + | (ulong)ReverseEndianness((uint)(value >> 32)); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint16bigendian + public static short ReadInt16BigEndian(ReadOnlySpan source) => + (short)((source[0] << 8) | source[1]); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint16littleendian + public static short ReadInt16LittleEndian(ReadOnlySpan source) => + (short)(source[0] | (source[1] << 8)); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint16bigendian + public static ushort ReadUInt16BigEndian(ReadOnlySpan source) => + (ushort)((source[0] << 8) | source[1]); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint16littleendian + public static ushort ReadUInt16LittleEndian(ReadOnlySpan source) => + (ushort)(source[0] | (source[1] << 8)); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint32bigendian + public static int ReadInt32BigEndian(ReadOnlySpan source) => + (source[0] << 24) | (source[1] << 16) | (source[2] << 8) | source[3]; + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint32littleendian + public static int ReadInt32LittleEndian(ReadOnlySpan source) => + source[0] | (source[1] << 8) | (source[2] << 16) | (source[3] << 24); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint32bigendian + public static uint ReadUInt32BigEndian(ReadOnlySpan source) => + ((uint)source[0] << 24) + | ((uint)source[1] << 16) + | ((uint)source[2] << 8) + | (uint)source[3]; + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint32littleendian + public static uint ReadUInt32LittleEndian(ReadOnlySpan source) => + (uint)source[0] + | ((uint)source[1] << 8) + | ((uint)source[2] << 16) + | ((uint)source[3] << 24); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint64bigendian + public static long ReadInt64BigEndian(ReadOnlySpan source) => + ((long)source[0] << 56) + | ((long)source[1] << 48) + | ((long)source[2] << 40) + | ((long)source[3] << 32) + | ((long)source[4] << 24) + | ((long)source[5] << 16) + | ((long)source[6] << 8) + | (long)source[7]; + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint64littleendian + public static long ReadInt64LittleEndian(ReadOnlySpan source) => + (long)source[0] + | ((long)source[1] << 8) + | ((long)source[2] << 16) + | ((long)source[3] << 24) + | ((long)source[4] << 32) + | ((long)source[5] << 40) + | ((long)source[6] << 48) + | ((long)source[7] << 56); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint64bigendian + public static ulong ReadUInt64BigEndian(ReadOnlySpan source) => + ((ulong)source[0] << 56) + | ((ulong)source[1] << 48) + | ((ulong)source[2] << 40) + | ((ulong)source[3] << 32) + | ((ulong)source[4] << 24) + | ((ulong)source[5] << 16) + | ((ulong)source[6] << 8) + | (ulong)source[7]; + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint64littleendian + public static ulong ReadUInt64LittleEndian(ReadOnlySpan source) => + (ulong)source[0] + | ((ulong)source[1] << 8) + | ((ulong)source[2] << 16) + | ((ulong)source[3] << 24) + | ((ulong)source[4] << 32) + | ((ulong)source[5] << 40) + | ((ulong)source[6] << 48) + | ((ulong)source[7] << 56); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readsinglebigendian + public static float ReadSingleBigEndian(ReadOnlySpan source) => + BitConverter.ToSingle(BitConverter.GetBytes(ReadInt32BigEndian(source)), 0); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readsinglelittleendian + public static float ReadSingleLittleEndian(ReadOnlySpan source) => + BitConverter.ToSingle(BitConverter.GetBytes(ReadInt32LittleEndian(source)), 0); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readdoublebigendian + public static double ReadDoubleBigEndian(ReadOnlySpan source) => + BitConverter.Int64BitsToDouble(ReadInt64BigEndian(source)); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readdoublelittleendian + public static double ReadDoubleLittleEndian(ReadOnlySpan source) => + BitConverter.Int64BitsToDouble(ReadInt64LittleEndian(source)); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint16bigendian + public static bool TryReadInt16BigEndian(ReadOnlySpan source, out short value) + { + if (source.Length < sizeof(short)) + { + value = default; + return false; + } + + value = ReadInt16BigEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint16littleendian + public static bool TryReadInt16LittleEndian(ReadOnlySpan source, out short value) + { + if (source.Length < sizeof(short)) + { + value = default; + return false; + } + + value = ReadInt16LittleEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint16bigendian + public static bool TryReadUInt16BigEndian(ReadOnlySpan source, out ushort value) + { + if (source.Length < sizeof(ushort)) + { + value = default; + return false; + } + + value = ReadUInt16BigEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint16littleendian + public static bool TryReadUInt16LittleEndian(ReadOnlySpan source, out ushort value) + { + if (source.Length < sizeof(ushort)) + { + value = default; + return false; + } + + value = ReadUInt16LittleEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint32bigendian + public static bool TryReadInt32BigEndian(ReadOnlySpan source, out int value) + { + if (source.Length < sizeof(int)) + { + value = default; + return false; + } + + value = ReadInt32BigEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint32littleendian + public static bool TryReadInt32LittleEndian(ReadOnlySpan source, out int value) + { + if (source.Length < sizeof(int)) + { + value = default; + return false; + } + + value = ReadInt32LittleEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint32bigendian + public static bool TryReadUInt32BigEndian(ReadOnlySpan source, out uint value) + { + if (source.Length < sizeof(uint)) + { + value = default; + return false; + } + + value = ReadUInt32BigEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint32littleendian + public static bool TryReadUInt32LittleEndian(ReadOnlySpan source, out uint value) + { + if (source.Length < sizeof(uint)) + { + value = default; + return false; + } + + value = ReadUInt32LittleEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint64bigendian + public static bool TryReadInt64BigEndian(ReadOnlySpan source, out long value) + { + if (source.Length < sizeof(long)) + { + value = default; + return false; + } + + value = ReadInt64BigEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint64littleendian + public static bool TryReadInt64LittleEndian(ReadOnlySpan source, out long value) + { + if (source.Length < sizeof(long)) + { + value = default; + return false; + } + + value = ReadInt64LittleEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint64bigendian + public static bool TryReadUInt64BigEndian(ReadOnlySpan source, out ulong value) + { + if (source.Length < sizeof(ulong)) + { + value = default; + return false; + } + + value = ReadUInt64BigEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint64littleendian + public static bool TryReadUInt64LittleEndian(ReadOnlySpan source, out ulong value) + { + if (source.Length < sizeof(ulong)) + { + value = default; + return false; + } + + value = ReadUInt64LittleEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadsinglebigendian + public static bool TryReadSingleBigEndian(ReadOnlySpan source, out float value) + { + if (source.Length < sizeof(float)) + { + value = default; + return false; + } + + value = ReadSingleBigEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadsinglelittleendian + public static bool TryReadSingleLittleEndian(ReadOnlySpan source, out float value) + { + if (source.Length < sizeof(float)) + { + value = default; + return false; + } + + value = ReadSingleLittleEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaddoublebigendian + public static bool TryReadDoubleBigEndian(ReadOnlySpan source, out double value) + { + if (source.Length < sizeof(double)) + { + value = default; + return false; + } + + value = ReadDoubleBigEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaddoublelittleendian + public static bool TryReadDoubleLittleEndian(ReadOnlySpan source, out double value) + { + if (source.Length < sizeof(double)) + { + value = default; + return false; + } + + value = ReadDoubleLittleEndian(source); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint16bigendian + public static void WriteInt16BigEndian(Span destination, short value) + { + destination[0] = (byte)(value >> 8); + destination[1] = (byte)value; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint16littleendian + public static void WriteInt16LittleEndian(Span destination, short value) + { + destination[0] = (byte)value; + destination[1] = (byte)(value >> 8); + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint16bigendian + public static void WriteUInt16BigEndian(Span destination, ushort value) + { + destination[0] = (byte)(value >> 8); + destination[1] = (byte)value; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint16littleendian + public static void WriteUInt16LittleEndian(Span destination, ushort value) + { + destination[0] = (byte)value; + destination[1] = (byte)(value >> 8); + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint32bigendian + public static void WriteInt32BigEndian(Span destination, int value) + { + destination[0] = (byte)(value >> 24); + destination[1] = (byte)(value >> 16); + destination[2] = (byte)(value >> 8); + destination[3] = (byte)value; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint32littleendian + public static void WriteInt32LittleEndian(Span destination, int value) + { + destination[0] = (byte)value; + destination[1] = (byte)(value >> 8); + destination[2] = (byte)(value >> 16); + destination[3] = (byte)(value >> 24); + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint32bigendian + public static void WriteUInt32BigEndian(Span destination, uint value) + { + destination[0] = (byte)(value >> 24); + destination[1] = (byte)(value >> 16); + destination[2] = (byte)(value >> 8); + destination[3] = (byte)value; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint32littleendian + public static void WriteUInt32LittleEndian(Span destination, uint value) + { + destination[0] = (byte)value; + destination[1] = (byte)(value >> 8); + destination[2] = (byte)(value >> 16); + destination[3] = (byte)(value >> 24); + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint64bigendian + public static void WriteInt64BigEndian(Span destination, long value) + { + destination[0] = (byte)(value >> 56); + destination[1] = (byte)(value >> 48); + destination[2] = (byte)(value >> 40); + destination[3] = (byte)(value >> 32); + destination[4] = (byte)(value >> 24); + destination[5] = (byte)(value >> 16); + destination[6] = (byte)(value >> 8); + destination[7] = (byte)value; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint64littleendian + public static void WriteInt64LittleEndian(Span destination, long value) + { + destination[0] = (byte)value; + destination[1] = (byte)(value >> 8); + destination[2] = (byte)(value >> 16); + destination[3] = (byte)(value >> 24); + destination[4] = (byte)(value >> 32); + destination[5] = (byte)(value >> 40); + destination[6] = (byte)(value >> 48); + destination[7] = (byte)(value >> 56); + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint64bigendian + public static void WriteUInt64BigEndian(Span destination, ulong value) + { + destination[0] = (byte)(value >> 56); + destination[1] = (byte)(value >> 48); + destination[2] = (byte)(value >> 40); + destination[3] = (byte)(value >> 32); + destination[4] = (byte)(value >> 24); + destination[5] = (byte)(value >> 16); + destination[6] = (byte)(value >> 8); + destination[7] = (byte)value; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint64littleendian + public static void WriteUInt64LittleEndian(Span destination, ulong value) + { + destination[0] = (byte)value; + destination[1] = (byte)(value >> 8); + destination[2] = (byte)(value >> 16); + destination[3] = (byte)(value >> 24); + destination[4] = (byte)(value >> 32); + destination[5] = (byte)(value >> 40); + destination[6] = (byte)(value >> 48); + destination[7] = (byte)(value >> 56); + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writesinglebigendian + public static void WriteSingleBigEndian(Span destination, float value) => + WriteInt32BigEndian(destination, BitConverter.ToInt32(BitConverter.GetBytes(value), 0)); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writesinglelittleendian + public static void WriteSingleLittleEndian(Span destination, float value) => + WriteInt32LittleEndian(destination, BitConverter.ToInt32(BitConverter.GetBytes(value), 0)); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writedoublebigendian + public static void WriteDoubleBigEndian(Span destination, double value) => + WriteInt64BigEndian(destination, BitConverter.DoubleToInt64Bits(value)); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writedoublelittleendian + public static void WriteDoubleLittleEndian(Span destination, double value) => + WriteInt64LittleEndian(destination, BitConverter.DoubleToInt64Bits(value)); + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint16bigendian + public static bool TryWriteInt16BigEndian(Span destination, short value) + { + if (destination.Length < sizeof(short)) + return false; + + WriteInt16BigEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint16littleendian + public static bool TryWriteInt16LittleEndian(Span destination, short value) + { + if (destination.Length < sizeof(short)) + return false; + + WriteInt16LittleEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint16bigendian + public static bool TryWriteUInt16BigEndian(Span destination, ushort value) + { + if (destination.Length < sizeof(ushort)) + return false; + + WriteUInt16BigEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint16littleendian + public static bool TryWriteUInt16LittleEndian(Span destination, ushort value) + { + if (destination.Length < sizeof(ushort)) + return false; + + WriteUInt16LittleEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint32bigendian + public static bool TryWriteInt32BigEndian(Span destination, int value) + { + if (destination.Length < sizeof(int)) + return false; + + WriteInt32BigEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint32littleendian + public static bool TryWriteInt32LittleEndian(Span destination, int value) + { + if (destination.Length < sizeof(int)) + return false; + + WriteInt32LittleEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint32bigendian + public static bool TryWriteUInt32BigEndian(Span destination, uint value) + { + if (destination.Length < sizeof(uint)) + return false; + + WriteUInt32BigEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint32littleendian + public static bool TryWriteUInt32LittleEndian(Span destination, uint value) + { + if (destination.Length < sizeof(uint)) + return false; + + WriteUInt32LittleEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint64bigendian + public static bool TryWriteInt64BigEndian(Span destination, long value) + { + if (destination.Length < sizeof(long)) + return false; + + WriteInt64BigEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint64littleendian + public static bool TryWriteInt64LittleEndian(Span destination, long value) + { + if (destination.Length < sizeof(long)) + return false; + + WriteInt64LittleEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint64bigendian + public static bool TryWriteUInt64BigEndian(Span destination, ulong value) + { + if (destination.Length < sizeof(ulong)) + return false; + + WriteUInt64BigEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint64littleendian + public static bool TryWriteUInt64LittleEndian(Span destination, ulong value) + { + if (destination.Length < sizeof(ulong)) + return false; + + WriteUInt64LittleEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywritesinglebigendian + public static bool TryWriteSingleBigEndian(Span destination, float value) + { + if (destination.Length < sizeof(float)) + return false; + + WriteSingleBigEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywritesinglelittleendian + public static bool TryWriteSingleLittleEndian(Span destination, float value) + { + if (destination.Length < sizeof(float)) + return false; + + WriteSingleLittleEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywritedoublebigendian + public static bool TryWriteDoubleBigEndian(Span destination, double value) + { + if (destination.Length < sizeof(double)) + return false; + + WriteDoubleBigEndian(destination, value); + return true; + } + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywritedoublelittleendian + public static bool TryWriteDoubleLittleEndian(Span destination, double value) + { + if (destination.Length < sizeof(double)) + return false; + + WriteDoubleLittleEndian(destination, value); + return true; + } +} +#endif diff --git a/Signatures.md b/Signatures.md index 49bc126..18fbe43 100644 --- a/Signatures.md +++ b/Signatures.md @@ -1,8 +1,8 @@ # Signatures -- **Total:** 541 -- **Types:** 113 -- **Members:** 428 +- **Total:** 544 +- **Types:** 114 +- **Members:** 430 ___ @@ -45,6 +45,10 @@ ___ - [**[struct]**](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.asyncvaluetaskmethodbuilder) .NET Core 2.1 - `AsyncValueTaskMethodBuilder` - [**[struct]**](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.asyncvaluetaskmethodbuilder-1) .NET Core 2.1 +- `BinaryPrimitives` + - [**[class]**](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives) .NET Core 2.1 + - [`static byte ReverseEndianness(byte)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-byte)) .NET 5.0 + - [`static sbyte ReverseEndianness(sbyte)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-sbyte)) .NET 5.0 - `byte` - [`static bool TryParse(ReadOnlySpan, IFormatProvider?, out byte)`](https://learn.microsoft.com/dotnet/api/system.byte.tryparse#system-byte-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-byte@)) .NET 7.0 - [`static bool TryParse(string?, IFormatProvider?, out byte)`](https://learn.microsoft.com/dotnet/api/system.byte.tryparse#system-byte-tryparse(system-string-system-iformatprovider-system-byte@)) .NET 7.0 From f7e414a254d9e9befa27a2cf6efeb8ea6f3c85b1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Jul 2026 19:12:25 +0000 Subject: [PATCH 2/4] perf: use unsafe bit-cast for float read/write when available --- PolyShim/NetCore21/BinaryPrimitives.cs | 58 ++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/PolyShim/NetCore21/BinaryPrimitives.cs b/PolyShim/NetCore21/BinaryPrimitives.cs index ba1acfe..4038373 100644 --- a/PolyShim/NetCore21/BinaryPrimitives.cs +++ b/PolyShim/NetCore21/BinaryPrimitives.cs @@ -121,12 +121,32 @@ public static ulong ReadUInt64LittleEndian(ReadOnlySpan source) => | ((ulong)source[7] << 56); // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readsinglebigendian - public static float ReadSingleBigEndian(ReadOnlySpan source) => - BitConverter.ToSingle(BitConverter.GetBytes(ReadInt32BigEndian(source)), 0); + public static float ReadSingleBigEndian(ReadOnlySpan source) + { + var bits = ReadInt32BigEndian(source); +#if ALLOW_UNSAFE_BLOCKS + unsafe + { + return *(float*)&bits; + } +#else + return BitConverter.ToSingle(BitConverter.GetBytes(bits), 0); +#endif + } // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readsinglelittleendian - public static float ReadSingleLittleEndian(ReadOnlySpan source) => - BitConverter.ToSingle(BitConverter.GetBytes(ReadInt32LittleEndian(source)), 0); + public static float ReadSingleLittleEndian(ReadOnlySpan source) + { + var bits = ReadInt32LittleEndian(source); +#if ALLOW_UNSAFE_BLOCKS + unsafe + { + return *(float*)&bits; + } +#else + return BitConverter.ToSingle(BitConverter.GetBytes(bits), 0); +#endif + } // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readdoublebigendian public static double ReadDoubleBigEndian(ReadOnlySpan source) => @@ -461,12 +481,34 @@ public static void WriteUInt64LittleEndian(Span destination, ulong value) } // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writesinglebigendian - public static void WriteSingleBigEndian(Span destination, float value) => - WriteInt32BigEndian(destination, BitConverter.ToInt32(BitConverter.GetBytes(value), 0)); + public static void WriteSingleBigEndian(Span destination, float value) + { +#if ALLOW_UNSAFE_BLOCKS + int bits; + unsafe + { + bits = *(int*)&value; + } +#else + var bits = BitConverter.ToInt32(BitConverter.GetBytes(value), 0); +#endif + WriteInt32BigEndian(destination, bits); + } // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writesinglelittleendian - public static void WriteSingleLittleEndian(Span destination, float value) => - WriteInt32LittleEndian(destination, BitConverter.ToInt32(BitConverter.GetBytes(value), 0)); + public static void WriteSingleLittleEndian(Span destination, float value) + { +#if ALLOW_UNSAFE_BLOCKS + int bits; + unsafe + { + bits = *(int*)&value; + } +#else + var bits = BitConverter.ToInt32(BitConverter.GetBytes(value), 0); +#endif + WriteInt32LittleEndian(destination, bits); + } // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writedoublebigendian public static void WriteDoubleBigEndian(Span destination, double value) => From cafa500d839c63c937488d58481bd197e7a4e644 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Jul 2026 19:33:20 +0000 Subject: [PATCH 3/4] fix: correct BinaryPrimitives API versions and update signature generator - Move byte/sbyte ReverseEndianness from Net50 to NetCore21 (introduced in .NET Core 2.1, not .NET 5.0) - Update signature generator to include methods from static class polyfills - All 72 BinaryPrimitives methods now correctly listed in Signatures.md as .NET Core 2.1 - Signatures count updated: Total 616 (+72), Members 502 (+72) --- GenerateSignatures.csx | 42 ++++++++++++++ PolyShim/Net50/BinaryPrimitives.cs | 22 ------- PolyShim/NetCore21/BinaryPrimitives.cs | 6 ++ Signatures.md | 80 ++++++++++++++++++++++++-- 4 files changed, 124 insertions(+), 26 deletions(-) delete mode 100644 PolyShim/Net50/BinaryPrimitives.cs diff --git a/GenerateSignatures.csx b/GenerateSignatures.csx index a93473c..a54619b 100755 --- a/GenerateSignatures.csx +++ b/GenerateSignatures.csx @@ -180,6 +180,48 @@ public partial class GenerateSignaturesCommand : ICommand } signatures.Add(new Signature(typeName, "", typeKind, framework, url, false)); + + // For static classes, also extract public static methods and properties + if ( + memberDecl is ClassDeclarationSyntax classDecl + && classDecl.Modifiers.Any(m => m.IsKind(SyntaxKind.StaticKeyword)) + ) + { + foreach (var classMember in classDecl.Members) + { + string? sig = null; + string? memberUrl = null; + bool isStatic = false; + + if ( + classMember is MethodDeclarationSyntax method + && method.Modifiers.Any(m => m.IsKind(SyntaxKind.PublicKeyword)) + ) + { + sig = FormatMethodSignature(method); + memberUrl = ExtractDocUrl(classMember); + isStatic = method.Modifiers.Any(m => + m.IsKind(SyntaxKind.StaticKeyword) + ); + } + else if ( + classMember is PropertyDeclarationSyntax prop + && prop.Modifiers.Any(m => m.IsKind(SyntaxKind.PublicKeyword)) + ) + { + sig = FormatPropertySignature(prop); + memberUrl = ExtractDocUrl(classMember); + isStatic = prop.Modifiers.Any(m => m.IsKind(SyntaxKind.StaticKeyword)); + } + + if (sig is null) + continue; + + signatures.Add( + new Signature(typeName!, sig, "Extension", framework, memberUrl, isStatic) + ); + } + } } } diff --git a/PolyShim/Net50/BinaryPrimitives.cs b/PolyShim/Net50/BinaryPrimitives.cs deleted file mode 100644 index 54974b4..0000000 --- a/PolyShim/Net50/BinaryPrimitives.cs +++ /dev/null @@ -1,22 +0,0 @@ -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) -#nullable enable -#pragma warning disable CS0436 - -using System.Buffers.Binary; -using System.Diagnostics.CodeAnalysis; - -#if !POLYSHIM_INCLUDE_COVERAGE -[ExcludeFromCodeCoverage] -#endif -internal static class MemberPolyfills_Net50_BinaryPrimitives -{ - extension(BinaryPrimitives) - { - // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-byte) - public static byte ReverseEndianness(byte value) => value; - - // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-sbyte) - public static sbyte ReverseEndianness(sbyte value) => value; - } -} -#endif diff --git a/PolyShim/NetCore21/BinaryPrimitives.cs b/PolyShim/NetCore21/BinaryPrimitives.cs index 4038373..c240c45 100644 --- a/PolyShim/NetCore21/BinaryPrimitives.cs +++ b/PolyShim/NetCore21/BinaryPrimitives.cs @@ -38,6 +38,12 @@ public static ulong ReverseEndianness(ulong value) => ((ulong)ReverseEndianness((uint)(value & 0xFFFFFFFFUL)) << 32) | (ulong)ReverseEndianness((uint)(value >> 32)); + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-byte) + public static byte ReverseEndianness(byte value) => value; + + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-sbyte) + public static sbyte ReverseEndianness(sbyte value) => value; + // https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint16bigendian public static short ReadInt16BigEndian(ReadOnlySpan source) => (short)((source[0] << 8) | source[1]); diff --git a/Signatures.md b/Signatures.md index 18fbe43..e323469 100644 --- a/Signatures.md +++ b/Signatures.md @@ -1,8 +1,8 @@ # Signatures -- **Total:** 544 +- **Total:** 616 - **Types:** 114 -- **Members:** 430 +- **Members:** 502 ___ @@ -47,8 +47,78 @@ ___ - [**[struct]**](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.asyncvaluetaskmethodbuilder-1) .NET Core 2.1 - `BinaryPrimitives` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives) .NET Core 2.1 - - [`static byte ReverseEndianness(byte)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-byte)) .NET 5.0 - - [`static sbyte ReverseEndianness(sbyte)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-sbyte)) .NET 5.0 + - [`static bool TryReadDoubleBigEndian(ReadOnlySpan, out double)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaddoublebigendian) .NET Core 2.1 + - [`static bool TryReadDoubleLittleEndian(ReadOnlySpan, out double)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaddoublelittleendian) .NET Core 2.1 + - [`static bool TryReadInt16BigEndian(ReadOnlySpan, out short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint16bigendian) .NET Core 2.1 + - [`static bool TryReadInt16LittleEndian(ReadOnlySpan, out short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint16littleendian) .NET Core 2.1 + - [`static bool TryReadInt32BigEndian(ReadOnlySpan, out int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint32bigendian) .NET Core 2.1 + - [`static bool TryReadInt32LittleEndian(ReadOnlySpan, out int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint32littleendian) .NET Core 2.1 + - [`static bool TryReadInt64BigEndian(ReadOnlySpan, out long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint64bigendian) .NET Core 2.1 + - [`static bool TryReadInt64LittleEndian(ReadOnlySpan, out long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint64littleendian) .NET Core 2.1 + - [`static bool TryReadSingleBigEndian(ReadOnlySpan, out float)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadsinglebigendian) .NET Core 2.1 + - [`static bool TryReadSingleLittleEndian(ReadOnlySpan, out float)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadsinglelittleendian) .NET Core 2.1 + - [`static bool TryReadUInt16BigEndian(ReadOnlySpan, out ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint16bigendian) .NET Core 2.1 + - [`static bool TryReadUInt16LittleEndian(ReadOnlySpan, out ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint16littleendian) .NET Core 2.1 + - [`static bool TryReadUInt32BigEndian(ReadOnlySpan, out uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint32bigendian) .NET Core 2.1 + - [`static bool TryReadUInt32LittleEndian(ReadOnlySpan, out uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint32littleendian) .NET Core 2.1 + - [`static bool TryReadUInt64BigEndian(ReadOnlySpan, out ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint64bigendian) .NET Core 2.1 + - [`static bool TryReadUInt64LittleEndian(ReadOnlySpan, out ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint64littleendian) .NET Core 2.1 + - [`static bool TryWriteDoubleBigEndian(Span, double)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywritedoublebigendian) .NET Core 2.1 + - [`static bool TryWriteDoubleLittleEndian(Span, double)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywritedoublelittleendian) .NET Core 2.1 + - [`static bool TryWriteInt16BigEndian(Span, short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint16bigendian) .NET Core 2.1 + - [`static bool TryWriteInt16LittleEndian(Span, short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint16littleendian) .NET Core 2.1 + - [`static bool TryWriteInt32BigEndian(Span, int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint32bigendian) .NET Core 2.1 + - [`static bool TryWriteInt32LittleEndian(Span, int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint32littleendian) .NET Core 2.1 + - [`static bool TryWriteInt64BigEndian(Span, long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint64bigendian) .NET Core 2.1 + - [`static bool TryWriteInt64LittleEndian(Span, long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint64littleendian) .NET Core 2.1 + - [`static bool TryWriteSingleBigEndian(Span, float)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywritesinglebigendian) .NET Core 2.1 + - [`static bool TryWriteSingleLittleEndian(Span, float)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywritesinglelittleendian) .NET Core 2.1 + - [`static bool TryWriteUInt16BigEndian(Span, ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint16bigendian) .NET Core 2.1 + - [`static bool TryWriteUInt16LittleEndian(Span, ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint16littleendian) .NET Core 2.1 + - [`static bool TryWriteUInt32BigEndian(Span, uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint32bigendian) .NET Core 2.1 + - [`static bool TryWriteUInt32LittleEndian(Span, uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint32littleendian) .NET Core 2.1 + - [`static bool TryWriteUInt64BigEndian(Span, ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint64bigendian) .NET Core 2.1 + - [`static bool TryWriteUInt64LittleEndian(Span, ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint64littleendian) .NET Core 2.1 + - [`static byte ReverseEndianness(byte)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-byte)) .NET Core 2.1 + - [`static double ReadDoubleBigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readdoublebigendian) .NET Core 2.1 + - [`static double ReadDoubleLittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readdoublelittleendian) .NET Core 2.1 + - [`static float ReadSingleBigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readsinglebigendian) .NET Core 2.1 + - [`static float ReadSingleLittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readsinglelittleendian) .NET Core 2.1 + - [`static int ReadInt32BigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint32bigendian) .NET Core 2.1 + - [`static int ReadInt32LittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint32littleendian) .NET Core 2.1 + - [`static int ReverseEndianness(int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-int32)) .NET Core 2.1 + - [`static long ReadInt64BigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint64bigendian) .NET Core 2.1 + - [`static long ReadInt64LittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint64littleendian) .NET Core 2.1 + - [`static long ReverseEndianness(long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-int64)) .NET Core 2.1 + - [`static sbyte ReverseEndianness(sbyte)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-sbyte)) .NET Core 2.1 + - [`static short ReadInt16BigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint16bigendian) .NET Core 2.1 + - [`static short ReadInt16LittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint16littleendian) .NET Core 2.1 + - [`static short ReverseEndianness(short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-int16)) .NET Core 2.1 + - [`static uint ReadUInt32BigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint32bigendian) .NET Core 2.1 + - [`static uint ReadUInt32LittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint32littleendian) .NET Core 2.1 + - [`static uint ReverseEndianness(uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-uint32)) .NET Core 2.1 + - [`static ulong ReadUInt64BigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint64bigendian) .NET Core 2.1 + - [`static ulong ReadUInt64LittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint64littleendian) .NET Core 2.1 + - [`static ulong ReverseEndianness(ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-uint64)) .NET Core 2.1 + - [`static ushort ReadUInt16BigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint16bigendian) .NET Core 2.1 + - [`static ushort ReadUInt16LittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint16littleendian) .NET Core 2.1 + - [`static ushort ReverseEndianness(ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-uint16)) .NET Core 2.1 + - [`static void WriteDoubleBigEndian(Span, double)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writedoublebigendian) .NET Core 2.1 + - [`static void WriteDoubleLittleEndian(Span, double)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writedoublelittleendian) .NET Core 2.1 + - [`static void WriteInt16BigEndian(Span, short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint16bigendian) .NET Core 2.1 + - [`static void WriteInt16LittleEndian(Span, short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint16littleendian) .NET Core 2.1 + - [`static void WriteInt32BigEndian(Span, int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint32bigendian) .NET Core 2.1 + - [`static void WriteInt32LittleEndian(Span, int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint32littleendian) .NET Core 2.1 + - [`static void WriteInt64BigEndian(Span, long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint64bigendian) .NET Core 2.1 + - [`static void WriteInt64LittleEndian(Span, long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint64littleendian) .NET Core 2.1 + - [`static void WriteSingleBigEndian(Span, float)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writesinglebigendian) .NET Core 2.1 + - [`static void WriteSingleLittleEndian(Span, float)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writesinglelittleendian) .NET Core 2.1 + - [`static void WriteUInt16BigEndian(Span, ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint16bigendian) .NET Core 2.1 + - [`static void WriteUInt16LittleEndian(Span, ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint16littleendian) .NET Core 2.1 + - [`static void WriteUInt32BigEndian(Span, uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint32bigendian) .NET Core 2.1 + - [`static void WriteUInt32LittleEndian(Span, uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint32littleendian) .NET Core 2.1 + - [`static void WriteUInt64BigEndian(Span, ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint64bigendian) .NET Core 2.1 + - [`static void WriteUInt64LittleEndian(Span, ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint64littleendian) .NET Core 2.1 - `byte` - [`static bool TryParse(ReadOnlySpan, IFormatProvider?, out byte)`](https://learn.microsoft.com/dotnet/api/system.byte.tryparse#system-byte-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-byte@)) .NET 7.0 - [`static bool TryParse(string?, IFormatProvider?, out byte)`](https://learn.microsoft.com/dotnet/api/system.byte.tryparse#system-byte-tryparse(system-string-system-iformatprovider-system-byte@)) .NET 7.0 @@ -465,8 +535,10 @@ ___ - [**[class]**](https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.requiresunreferencedcodeattribute) .NET 5.0 - `RuntimeHelpers` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.runtimehelpers) .NET Core 3.0 + - [`static T[] GetSubArray(T[], Range)`](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.runtimehelpers.getsubarray) .NET Core 3.0 - `RuntimeInformation` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.runtime.interopservices.runtimeinformation) .NET Core 1.0 + - `static bool IsOSPlatform(OSPlatform)` .NET Core 1.0 - `sbyte` - [`static bool TryParse(ReadOnlySpan, IFormatProvider?, out sbyte)`](https://learn.microsoft.com/dotnet/api/system.sbyte.tryparse#system-sbyte-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-sbyte@)) .NET 7.0 - [`static bool TryParse(string?, IFormatProvider?, out sbyte)`](https://learn.microsoft.com/dotnet/api/system.sbyte.tryparse#system-sbyte-tryparse(system-string-system-iformatprovider-system-sbyte@)) .NET 7.0 From f26c3a31d0818b37644dcc2eb3886963df1599c9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Jul 2026 20:18:17 +0000 Subject: [PATCH 4/4] Regenerate Signatures.md after merging latest prime --- Signatures.md | 80 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/Signatures.md b/Signatures.md index 6b6b176..daa413b 100644 --- a/Signatures.md +++ b/Signatures.md @@ -1,8 +1,8 @@ # Signatures -- **Total:** 545 -- **Types:** 113 -- **Members:** 432 +- **Total:** 620 +- **Types:** 114 +- **Members:** 506 ___ @@ -45,6 +45,80 @@ ___ - [**[struct]**](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.asyncvaluetaskmethodbuilder) .NET Core 2.1 - `AsyncValueTaskMethodBuilder` - [**[struct]**](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.asyncvaluetaskmethodbuilder-1) .NET Core 2.1 +- `BinaryPrimitives` + - [**[class]**](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives) .NET Core 2.1 + - [`static bool TryReadDoubleBigEndian(ReadOnlySpan, out double)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaddoublebigendian) .NET Core 2.1 + - [`static bool TryReadDoubleLittleEndian(ReadOnlySpan, out double)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaddoublelittleendian) .NET Core 2.1 + - [`static bool TryReadInt16BigEndian(ReadOnlySpan, out short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint16bigendian) .NET Core 2.1 + - [`static bool TryReadInt16LittleEndian(ReadOnlySpan, out short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint16littleendian) .NET Core 2.1 + - [`static bool TryReadInt32BigEndian(ReadOnlySpan, out int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint32bigendian) .NET Core 2.1 + - [`static bool TryReadInt32LittleEndian(ReadOnlySpan, out int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint32littleendian) .NET Core 2.1 + - [`static bool TryReadInt64BigEndian(ReadOnlySpan, out long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint64bigendian) .NET Core 2.1 + - [`static bool TryReadInt64LittleEndian(ReadOnlySpan, out long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadint64littleendian) .NET Core 2.1 + - [`static bool TryReadSingleBigEndian(ReadOnlySpan, out float)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadsinglebigendian) .NET Core 2.1 + - [`static bool TryReadSingleLittleEndian(ReadOnlySpan, out float)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreadsinglelittleendian) .NET Core 2.1 + - [`static bool TryReadUInt16BigEndian(ReadOnlySpan, out ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint16bigendian) .NET Core 2.1 + - [`static bool TryReadUInt16LittleEndian(ReadOnlySpan, out ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint16littleendian) .NET Core 2.1 + - [`static bool TryReadUInt32BigEndian(ReadOnlySpan, out uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint32bigendian) .NET Core 2.1 + - [`static bool TryReadUInt32LittleEndian(ReadOnlySpan, out uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint32littleendian) .NET Core 2.1 + - [`static bool TryReadUInt64BigEndian(ReadOnlySpan, out ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint64bigendian) .NET Core 2.1 + - [`static bool TryReadUInt64LittleEndian(ReadOnlySpan, out ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.tryreaduint64littleendian) .NET Core 2.1 + - [`static bool TryWriteDoubleBigEndian(Span, double)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywritedoublebigendian) .NET Core 2.1 + - [`static bool TryWriteDoubleLittleEndian(Span, double)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywritedoublelittleendian) .NET Core 2.1 + - [`static bool TryWriteInt16BigEndian(Span, short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint16bigendian) .NET Core 2.1 + - [`static bool TryWriteInt16LittleEndian(Span, short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint16littleendian) .NET Core 2.1 + - [`static bool TryWriteInt32BigEndian(Span, int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint32bigendian) .NET Core 2.1 + - [`static bool TryWriteInt32LittleEndian(Span, int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint32littleendian) .NET Core 2.1 + - [`static bool TryWriteInt64BigEndian(Span, long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint64bigendian) .NET Core 2.1 + - [`static bool TryWriteInt64LittleEndian(Span, long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint64littleendian) .NET Core 2.1 + - [`static bool TryWriteSingleBigEndian(Span, float)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywritesinglebigendian) .NET Core 2.1 + - [`static bool TryWriteSingleLittleEndian(Span, float)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywritesinglelittleendian) .NET Core 2.1 + - [`static bool TryWriteUInt16BigEndian(Span, ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint16bigendian) .NET Core 2.1 + - [`static bool TryWriteUInt16LittleEndian(Span, ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint16littleendian) .NET Core 2.1 + - [`static bool TryWriteUInt32BigEndian(Span, uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint32bigendian) .NET Core 2.1 + - [`static bool TryWriteUInt32LittleEndian(Span, uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint32littleendian) .NET Core 2.1 + - [`static bool TryWriteUInt64BigEndian(Span, ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint64bigendian) .NET Core 2.1 + - [`static bool TryWriteUInt64LittleEndian(Span, ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.trywriteuint64littleendian) .NET Core 2.1 + - [`static byte ReverseEndianness(byte)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-byte)) .NET Core 2.1 + - [`static double ReadDoubleBigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readdoublebigendian) .NET Core 2.1 + - [`static double ReadDoubleLittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readdoublelittleendian) .NET Core 2.1 + - [`static float ReadSingleBigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readsinglebigendian) .NET Core 2.1 + - [`static float ReadSingleLittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readsinglelittleendian) .NET Core 2.1 + - [`static int ReadInt32BigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint32bigendian) .NET Core 2.1 + - [`static int ReadInt32LittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint32littleendian) .NET Core 2.1 + - [`static int ReverseEndianness(int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-int32)) .NET Core 2.1 + - [`static long ReadInt64BigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint64bigendian) .NET Core 2.1 + - [`static long ReadInt64LittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint64littleendian) .NET Core 2.1 + - [`static long ReverseEndianness(long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-int64)) .NET Core 2.1 + - [`static sbyte ReverseEndianness(sbyte)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-sbyte)) .NET Core 2.1 + - [`static short ReadInt16BigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint16bigendian) .NET Core 2.1 + - [`static short ReadInt16LittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readint16littleendian) .NET Core 2.1 + - [`static short ReverseEndianness(short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-int16)) .NET Core 2.1 + - [`static uint ReadUInt32BigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint32bigendian) .NET Core 2.1 + - [`static uint ReadUInt32LittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint32littleendian) .NET Core 2.1 + - [`static uint ReverseEndianness(uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-uint32)) .NET Core 2.1 + - [`static ulong ReadUInt64BigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint64bigendian) .NET Core 2.1 + - [`static ulong ReadUInt64LittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint64littleendian) .NET Core 2.1 + - [`static ulong ReverseEndianness(ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-uint64)) .NET Core 2.1 + - [`static ushort ReadUInt16BigEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint16bigendian) .NET Core 2.1 + - [`static ushort ReadUInt16LittleEndian(ReadOnlySpan)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.readuint16littleendian) .NET Core 2.1 + - [`static ushort ReverseEndianness(ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.reverseendianness#system-buffers-binary-binaryprimitives-reverseendianness(system-uint16)) .NET Core 2.1 + - [`static void WriteDoubleBigEndian(Span, double)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writedoublebigendian) .NET Core 2.1 + - [`static void WriteDoubleLittleEndian(Span, double)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writedoublelittleendian) .NET Core 2.1 + - [`static void WriteInt16BigEndian(Span, short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint16bigendian) .NET Core 2.1 + - [`static void WriteInt16LittleEndian(Span, short)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint16littleendian) .NET Core 2.1 + - [`static void WriteInt32BigEndian(Span, int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint32bigendian) .NET Core 2.1 + - [`static void WriteInt32LittleEndian(Span, int)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint32littleendian) .NET Core 2.1 + - [`static void WriteInt64BigEndian(Span, long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint64bigendian) .NET Core 2.1 + - [`static void WriteInt64LittleEndian(Span, long)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeint64littleendian) .NET Core 2.1 + - [`static void WriteSingleBigEndian(Span, float)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writesinglebigendian) .NET Core 2.1 + - [`static void WriteSingleLittleEndian(Span, float)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writesinglelittleendian) .NET Core 2.1 + - [`static void WriteUInt16BigEndian(Span, ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint16bigendian) .NET Core 2.1 + - [`static void WriteUInt16LittleEndian(Span, ushort)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint16littleendian) .NET Core 2.1 + - [`static void WriteUInt32BigEndian(Span, uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint32bigendian) .NET Core 2.1 + - [`static void WriteUInt32LittleEndian(Span, uint)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint32littleendian) .NET Core 2.1 + - [`static void WriteUInt64BigEndian(Span, ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint64bigendian) .NET Core 2.1 + - [`static void WriteUInt64LittleEndian(Span, ulong)`](https://learn.microsoft.com/dotnet/api/system.buffers.binary.binaryprimitives.writeuint64littleendian) .NET Core 2.1 - `BinaryReader` - [`int Read(Span)`](https://learn.microsoft.com/dotnet/api/system.io.binaryreader.read#system-io-binaryreader-read(system-span((system-byte)))) .NET Core 2.1 - [`int Read(Span)`](https://learn.microsoft.com/dotnet/api/system.io.binaryreader.read#system-io-binaryreader-read(system-span((system-char)))) .NET Core 2.1