From ba7d015a7596d130544bfcc6ff2143feebee4846 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 1 Oct 2023 00:56:36 +0200 Subject: [PATCH] Remove leftover methods --- .../ArrayPoolBinaryWriterExtensions.cs | 92 ------------------- 1 file changed, 92 deletions(-) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Buffers/ArrayPoolBinaryWriterExtensions.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Buffers/ArrayPoolBinaryWriterExtensions.cs index a4d08422..1b9baf7a 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Buffers/ArrayPoolBinaryWriterExtensions.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Buffers/ArrayPoolBinaryWriterExtensions.cs @@ -1,10 +1,6 @@ using System; -#if NET6_0_OR_GREATER -using System.Buffers.Text; -#endif using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Text; namespace ComputeSharp.D2D1.Shaders.Interop.Buffers; @@ -30,22 +26,6 @@ internal static class ArrayPoolBinaryWriterExtensions writer.Advance(sizeof(T)); } - /// - /// Writes the raw value of type into the buffer. - /// - /// The type of value to write. - /// The target instance to write data to. - /// The value to write. - public static unsafe void WriteRaw(this ref ArrayPoolBufferWriter writer, scoped in T value) - where T : unmanaged - { - Span span = writer.GetSpan(1); - - MemoryMarshal.GetReference(span) = value; - - writer.Advance(1); - } - /// /// Writes the raw data from the input into the buffer. /// @@ -61,76 +41,4 @@ internal static class ArrayPoolBinaryWriterExtensions writer.Advance(data.Length); } - -#if !NET6_0_OR_GREATER - /// - /// Writes the raw data from the input into the buffer. - /// - /// The target instance to write data to. - /// The data to write. - public static void WriteRaw(this ref ArrayPoolBufferWriter writer, string data) - { - Span span = writer.GetSpan(data.Length); - - data.AsSpan().CopyTo(span); - - writer.Advance(data.Length); - } -#endif - - /// - /// Writes an value as UTF8 bytes into the buffer. - /// - /// The target instance to write data to. - /// The value to write. - public static void WriteAsUtf8(this ref ArrayPoolBufferWriter writer, int value) - { -#if NET6_0_OR_GREATER - // Get a span of at least 10 elements (10 is the length of int.MaxValue as text) - Span span = writer.GetSpan(10); - - _ = Utf8Formatter.TryFormat(value, span, out int bytesWritten); - - writer.Advance(bytesWritten); -#else - // Just accept the allocation on .NET Standard 2.0 - writer.WriteAsUtf8(value.ToString()); -#endif - } - - /// - /// Writes text as UTF8 bytes into the buffer. - /// - /// The target instance to write data to. - /// The text to write. - public static void WriteAsUtf8(this ref ArrayPoolBufferWriter writer, string text) - { - int maximumByteSize = Encoding.UTF8.GetMaxByteCount(text.Length); - - Span span = writer.GetSpan(maximumByteSize); - - int writtenBytes = Encoding.UTF8.GetBytes(text.AsSpan(), span); - - writer.Advance(writtenBytes); - } - - /// - /// Writes an value as Unicode bytes into the buffer. - /// - /// The target instance to write data to. - /// The value to write. - public static void WriteAsUnicode(this ref ArrayPoolBufferWriter writer, int value) - { -#if NET6_0_OR_GREATER - // Get a span of at least 10 elements (10 is the length of int.MaxValue as text) - Span span = writer.GetSpan(10); - - _ = value.TryFormat(span, out int charsWritten); - - writer.Advance(charsWritten); -#else - // Just accept the allocation on .NET Standard 2.0 - writer.WriteRaw(value.ToString().AsSpan()); -#endif - } } \ No newline at end of file