Removed leftover ThrowHelper class
このコミットが含まれているのは:
1 親
b68d51f75e
コミット
ebeec1c397
3ファイル変更
+11
-91
検索条件に一致するファイルはありません
@@ -2,7 +2,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Resources.Views;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
|
||||
#pragma warning disable CS0809
|
||||
|
||||
@@ -128,11 +128,8 @@ public readonly unsafe ref partial struct TextureView2D<T>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
if ((uint)x >= (uint)this.width ||
|
||||
(uint)y >= (uint)this.height)
|
||||
{
|
||||
ThrowHelper.ThrowIndexOutOfRangeException();
|
||||
}
|
||||
Guard.IsInRange(x, 0, this.width, nameof(x));
|
||||
Guard.IsInRange(y, 0, this.height, nameof(y));
|
||||
|
||||
return ref *((T*)((byte*)this.pointer + (y * this.pitchInBytes)) + x);
|
||||
}
|
||||
@@ -181,10 +178,7 @@ public readonly unsafe ref partial struct TextureView2D<T>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Length > destination.Length)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentExceptionForDestinationTooShort();
|
||||
}
|
||||
Guard.HasSizeGreaterThanOrEqualTo(destination, Length, nameof(destination));
|
||||
|
||||
for (int y = 0, j = 0; y < this.height; y++, j += this.width)
|
||||
{
|
||||
@@ -308,10 +302,7 @@ public readonly unsafe ref partial struct TextureView2D<T>
|
||||
[Pure]
|
||||
public Span<T> GetRowSpan(int y)
|
||||
{
|
||||
if ((uint)y >= (uint)this.height)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow();
|
||||
}
|
||||
Guard.IsInRange(y, 0, this.height, nameof(y));
|
||||
|
||||
return new((byte*)this.pointer + (y * this.pitchInBytes), this.width);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Resources.Views;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
|
||||
#pragma warning disable CS0809
|
||||
|
||||
@@ -153,12 +153,9 @@ public readonly unsafe ref partial struct TextureView3D<T>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
if ((uint)x >= (uint)this.width ||
|
||||
(uint)y >= (uint)this.height ||
|
||||
(uint)z >= (uint)this.depth)
|
||||
{
|
||||
ThrowHelper.ThrowIndexOutOfRangeException();
|
||||
}
|
||||
Guard.IsInRange(x, 0, this.width, nameof(x));
|
||||
Guard.IsInRange(y, 0, this.height, nameof(y));
|
||||
Guard.IsInRange(z, 0, this.depth, nameof(z));
|
||||
|
||||
return ref *((T*)((byte*)this.pointer + (z * this.height * this.strideInBytes) + (y * this.strideInBytes)) + x);
|
||||
}
|
||||
@@ -344,15 +341,8 @@ public readonly unsafe ref partial struct TextureView3D<T>
|
||||
[Pure]
|
||||
public Span<T> GetRowSpan(int y, int z)
|
||||
{
|
||||
if ((uint)y >= (uint)this.height)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow();
|
||||
}
|
||||
|
||||
if ((uint)z >= (uint)this.depth)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentOutOfRangeExceptionForZ();
|
||||
}
|
||||
Guard.IsInRange(y, 0, this.height, nameof(y));
|
||||
Guard.IsInRange(z, 0, this.depth, nameof(z));
|
||||
|
||||
return new((byte*)this.pointer + (z * this.height * this.strideInBytes) + (y * this.strideInBytes), this.width);
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.Resources.Views;
|
||||
|
||||
/// <summary>
|
||||
/// A helper class to throw exceptions for view types.
|
||||
/// </summary>
|
||||
internal static class ThrowHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentException"/> when the target span is too short.
|
||||
/// </summary>
|
||||
public static void ThrowArgumentExceptionForDestinationTooShort()
|
||||
{
|
||||
throw new ArgumentException("The target span is too short to copy all the current items to");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="IndexOutOfRangeException"/> when the a given coordinate is invalid.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Throwing <see cref="IndexOutOfRangeException"/> is technically discouraged in the docs, but
|
||||
/// we're doing that here for consistency with the official <see cref="Span{T}"/> type(s) from the BCL.
|
||||
/// </remarks>
|
||||
public static void ThrowIndexOutOfRangeException()
|
||||
{
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> when more than one parameter are invalid.
|
||||
/// </summary>
|
||||
public static void ThrowArgumentException()
|
||||
{
|
||||
throw new ArgumentException("One or more input parameters were invalid");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> when the "row" parameter is invalid.
|
||||
/// </summary>
|
||||
public static void ThrowArgumentOutOfRangeExceptionForRow()
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("row");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> when the "column" parameter is invalid.
|
||||
/// </summary>
|
||||
public static void ThrowArgumentOutOfRangeExceptionForColumn()
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("column");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> when the "z" parameter is invalid.
|
||||
/// </summary>
|
||||
public static void ThrowArgumentOutOfRangeExceptionForZ()
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("z");
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする