diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Buffers/ArrayPoolBinaryWriter{T}.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Buffers/ArrayPoolBinaryWriter{T}.cs index db8ab67c..c5378083 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Buffers/ArrayPoolBinaryWriter{T}.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Buffers/ArrayPoolBinaryWriter{T}.cs @@ -59,7 +59,7 @@ internal ref struct ArrayPoolBufferWriter if (array is null) { - ThrowObjectDisposedException(); + ArrayPoolBufferWriterHelpers.ThrowObjectDisposedException(); } return array.AsSpan(0, this.index); @@ -80,17 +80,17 @@ internal ref struct ArrayPoolBufferWriter if (array is null) { - ThrowObjectDisposedException(); + ArrayPoolBufferWriterHelpers.ThrowObjectDisposedException(); } if (count < 0) { - ThrowArgumentOutOfRangeExceptionForNegativeCount(); + ArrayPoolBufferWriterHelpers.ThrowArgumentOutOfRangeExceptionForNegativeCount(); } if (this.index > array.Length - count) { - ThrowArgumentExceptionForAdvancedTooFar(); + ArrayPoolBufferWriterHelpers.ThrowArgumentExceptionForAdvancedTooFar(); } this.index += count; @@ -120,12 +120,12 @@ internal ref struct ArrayPoolBufferWriter if (array is null) { - ThrowObjectDisposedException(); + ArrayPoolBufferWriterHelpers.ThrowObjectDisposedException(); } if (sizeHint < 0) { - ThrowArgumentOutOfRangeExceptionForNegativeSizeHint(); + ArrayPoolBufferWriterHelpers.ThrowArgumentOutOfRangeExceptionForNegativeSizeHint(); } if (sizeHint == 0) @@ -181,12 +181,18 @@ internal ref struct ArrayPoolBufferWriter ArrayPool.Shared.Return(array); } +} +/// +/// Private helpers for . +/// +file static class ArrayPoolBufferWriterHelpers +{ /// /// Throws an when the requested count is negative. /// [DoesNotReturn] - private static void ThrowArgumentOutOfRangeExceptionForNegativeCount() + public static void ThrowArgumentOutOfRangeExceptionForNegativeCount() { throw new ArgumentOutOfRangeException("count", "The count can't be a negative value."); } @@ -195,7 +201,7 @@ internal ref struct ArrayPoolBufferWriter /// Throws an when the size hint is negative. /// [DoesNotReturn] - private static void ThrowArgumentOutOfRangeExceptionForNegativeSizeHint() + public static void ThrowArgumentOutOfRangeExceptionForNegativeSizeHint() { throw new ArgumentOutOfRangeException("sizeHint", "The size hint can't be a negative value."); } @@ -204,16 +210,16 @@ internal ref struct ArrayPoolBufferWriter /// Throws an when the requested count is negative. /// [DoesNotReturn] - private static void ThrowArgumentExceptionForAdvancedTooFar() + public static void ThrowArgumentExceptionForAdvancedTooFar() { throw new ArgumentException("The buffer writer has advanced too far."); } /// - /// Throws an when is . + /// Throws an when the array is . /// [DoesNotReturn] - private static void ThrowObjectDisposedException() + public static void ThrowObjectDisposedException() { throw new ObjectDisposedException("The current buffer has already been disposed."); }