Add and use ArgumentOutOfRangeException.ThrowIfNotInRange

このコミットが含まれているのは:
Sergio Pedri committed 2023-02-25 16:49:43 +01:00
1 親 98fb8e68ce
コミット 56031f443a
8ファイル変更
+88 -69

検索条件に一致するファイルはありません

+17
ファイルの表示
@@ -38,6 +38,23 @@ internal static class ArgumentOutOfRangeExceptionExtensions
}
}
/// <summary>
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is not in the specified range.
/// </summary>
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
/// <param name="value">The argument to validate as non-zero or non-negative.</param>
/// <param name="minimum">The inclusive starting value for the range.</param>
/// <param name="maximum">The exclusive ending value for the range.</param>
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ThrowIfNotInRange(this ArgumentOutOfRangeException? _, int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
{
if (value < minimum || value >= maximum)
{
Throw(parameterName, value);
}
}
/// <summary>
/// Throws an <see cref="ArgumentOutOfRangeException"/> for a given parameter name.
/// </summary>
+9 -8
ファイルの表示
@@ -1,3 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
using CommunityToolkit.Diagnostics;
using ComputeSharp.Graphics.Commands;
@@ -36,7 +37,7 @@ public abstract class StructuredBuffer<T> : Buffer<T>
internal override unsafe void CopyTo(ref T destination, int sourceOffset, int count)
{
Guard.IsBetweenOrEqualTo(count, 0, Length);
Guard.IsInRange(sourceOffset, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, Length);
Guard.IsLessThanOrEqualTo(sourceOffset + count, Length, nameof(sourceOffset));
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
@@ -109,9 +110,9 @@ public abstract class StructuredBuffer<T> : Buffer<T>
{
Guard.IsBetweenOrEqualTo(count, 0, Length);
Guard.IsBetweenOrEqualTo(count, 0, destination.Length);
Guard.IsInRange(sourceOffset, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, Length);
Guard.IsLessThanOrEqualTo(sourceOffset + count, Length, nameof(sourceOffset));
Guard.IsInRange(destinationOffset, 0, destination.Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffset, 0, destination.Length);
Guard.IsLessThanOrEqualTo(destinationOffset + count, destination.Length, nameof(destinationOffset));
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
@@ -157,9 +158,9 @@ public abstract class StructuredBuffer<T> : Buffer<T>
{
Guard.IsBetweenOrEqualTo(count, 0, Length);
Guard.IsBetweenOrEqualTo(count, 0, destination.Length);
Guard.IsInRange(sourceOffset, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, Length);
Guard.IsLessThanOrEqualTo(sourceOffset + count, Length, nameof(sourceOffset));
Guard.IsInRange(destinationOffset, 0, destination.Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffset, 0, destination.Length);
Guard.IsLessThanOrEqualTo(destinationOffset + count, destination.Length, nameof(destinationOffset));
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
@@ -200,7 +201,7 @@ public abstract class StructuredBuffer<T> : Buffer<T>
internal override unsafe void CopyFrom(ref T source, int offset, int length)
{
Guard.IsBetweenOrEqualTo(length, 0, Length);
Guard.IsInRange(offset, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(offset, 0, Length);
Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(offset));
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
@@ -277,9 +278,9 @@ public abstract class StructuredBuffer<T> : Buffer<T>
{
Guard.IsBetweenOrEqualTo(count, 0, Length);
Guard.IsBetweenOrEqualTo(count, 0, source.Length);
Guard.IsInRange(sourceOffset, 0, source.Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, source.Length);
Guard.IsLessThanOrEqualTo(sourceOffset + count, source.Length, nameof(sourceOffset));
Guard.IsInRange(destinationOffset, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffset, 0, Length);
Guard.IsLessThanOrEqualTo(destinationOffset + count, Length, nameof(destinationOffset));
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
+8 -8
ファイルの表示
@@ -165,7 +165,7 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
/// <param name="width">The width of the memory area to copy.</param>
internal void CopyTo(ref T destination, int size, int sourceOffsetX, int width)
{
Guard.IsInRange(sourceOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
Guard.IsGreaterThanOrEqualTo(size, width);
@@ -247,8 +247,8 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
/// <param name="width">The width of the memory area to copy.</param>
internal void CopyTo(Texture1D<T> destination, int sourceOffsetX, int destinationOffsetX, int width)
{
Guard.IsInRange(sourceOffsetX, 0, Width);
Guard.IsInRange(destinationOffsetX, 0, destination.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(width, 1, destination.Width);
Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
@@ -307,8 +307,8 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
/// <param name="width">The width of the memory area to copy.</param>
internal void CopyTo(ReadBackTexture1D<T> destination, int sourceOffsetX, int destinationOffsetX, int width)
{
Guard.IsInRange(sourceOffsetX, 0, Width);
Guard.IsInRange(destinationOffsetX, 0, destination.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(width, 1, destination.Width);
Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
@@ -363,7 +363,7 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
/// <param name="width">The width of the memory area to write to.</param>
internal void CopyFrom(ref T source, int size, int destinationOffsetX, int width)
{
Guard.IsInRange(destinationOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
Guard.IsGreaterThanOrEqualTo(size, width);
@@ -445,8 +445,8 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
/// <param name="width">The width of the memory area to write to.</param>
internal void CopyFrom(UploadTexture1D<T> source, int sourceOffsetX, int destinationOffsetX, int width)
{
Guard.IsInRange(sourceOffsetX, 0, source.Width);
Guard.IsInRange(destinationOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, source.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(width, 1, source.Width);
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, source.Width, nameof(sourceOffsetX));
+16 -16
ファイルの表示
@@ -177,8 +177,8 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
/// <param name="height">The height of the memory area to copy.</param>
internal void CopyTo(ref T destination, int size, int sourceOffsetX, int sourceOffsetY, int width, int height)
{
Guard.IsInRange(sourceOffsetX, 0, Width);
Guard.IsInRange(sourceOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
@@ -267,10 +267,10 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
/// <param name="height">The height of the memory area to copy.</param>
internal void CopyTo(Texture2D<T> destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
{
Guard.IsInRange(sourceOffsetX, 0, Width);
Guard.IsInRange(sourceOffsetY, 0, Height);
Guard.IsInRange(destinationOffsetX, 0, destination.Width);
Guard.IsInRange(destinationOffsetY, 0, destination.Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, destination.Height);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
Guard.IsBetweenOrEqualTo(width, 1, destination.Width);
@@ -336,10 +336,10 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
/// <param name="height">The height of the memory area to copy.</param>
internal void CopyTo(ReadBackTexture2D<T> destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
{
Guard.IsInRange(sourceOffsetX, 0, Width);
Guard.IsInRange(sourceOffsetY, 0, Height);
Guard.IsInRange(destinationOffsetX, 0, destination.Width);
Guard.IsInRange(destinationOffsetY, 0, destination.Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, destination.Height);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
Guard.IsBetweenOrEqualTo(width, 1, destination.Width);
@@ -400,8 +400,8 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
/// <param name="height">The height of the memory area to write to.</param>
internal void CopyFrom(ref T source, int size, int destinationOffsetX, int destinationOffsetY, int width, int height)
{
Guard.IsInRange(destinationOffsetX, 0, Width);
Guard.IsInRange(destinationOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, Height);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
@@ -490,10 +490,10 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
/// <param name="height">The height of the memory area to write to.</param>
internal void CopyFrom(UploadTexture2D<T> source, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
{
Guard.IsInRange(sourceOffsetX, 0, source.Width);
Guard.IsInRange(sourceOffsetY, 0, source.Height);
Guard.IsInRange(destinationOffsetX, 0, Width);
Guard.IsInRange(destinationOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, source.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, source.Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, Height);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
Guard.IsBetweenOrEqualTo(width, 1, source.Width);
+24 -24
ファイルの表示
@@ -189,9 +189,9 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
/// <param name="depth">The depth of the memory area to copy.</param>
internal void CopyTo(ref T destination, int size, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
{
Guard.IsInRange(sourceOffsetX, 0, Width);
Guard.IsInRange(sourceOffsetY, 0, Height);
Guard.IsInRange(sourceOffsetZ, 0, Depth);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetZ, 0, Depth);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
Guard.IsBetweenOrEqualTo(depth, 1, Depth);
@@ -288,12 +288,12 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
/// <param name="depth">The depth of the memory area to copy.</param>
internal void CopyTo(Texture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
{
Guard.IsInRange(sourceOffsetX, 0, Width);
Guard.IsInRange(sourceOffsetY, 0, Height);
Guard.IsInRange(sourceOffsetZ, 0, Depth);
Guard.IsInRange(destinationOffsetX, 0, destination.Width);
Guard.IsInRange(destinationOffsetY, 0, destination.Height);
Guard.IsInRange(destinationOffsetZ, 0, destination.Depth);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetZ, 0, Depth);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, destination.Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetZ, 0, destination.Depth);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
Guard.IsBetweenOrEqualTo(depth, 1, Depth);
@@ -366,12 +366,12 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
/// <param name="depth">The depth of the memory area to copy.</param>
internal void CopyTo(ReadBackTexture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
{
Guard.IsInRange(sourceOffsetX, 0, Width);
Guard.IsInRange(sourceOffsetY, 0, Height);
Guard.IsInRange(sourceOffsetZ, 0, Depth);
Guard.IsInRange(destinationOffsetX, 0, destination.Width);
Guard.IsInRange(destinationOffsetY, 0, destination.Height);
Guard.IsInRange(destinationOffsetZ, 0, destination.Depth);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetZ, 0, Depth);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, destination.Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetZ, 0, destination.Depth);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
Guard.IsBetweenOrEqualTo(depth, 1, Depth);
@@ -438,9 +438,9 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
/// <param name="depth">The depth of the memory area to write to.</param>
internal void CopyFrom(ref T source, int size, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
{
Guard.IsInRange(destinationOffsetX, 0, Width);
Guard.IsInRange(destinationOffsetY, 0, Height);
Guard.IsInRange(destinationOffsetZ, 0, Depth);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetZ, 0, Depth);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
Guard.IsBetweenOrEqualTo(depth, 1, Depth);
@@ -537,12 +537,12 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
/// <param name="depth">The depth of the memory area to write to.</param>
internal void CopyFrom(UploadTexture3D<T> source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
{
Guard.IsInRange(sourceOffsetX, 0, source.Width);
Guard.IsInRange(sourceOffsetY, 0, source.Height);
Guard.IsInRange(sourceOffsetZ, 0, source.Depth);
Guard.IsInRange(destinationOffsetX, 0, Width);
Guard.IsInRange(destinationOffsetY, 0, Height);
Guard.IsInRange(destinationOffsetZ, 0, Depth);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, source.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, source.Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetZ, 0, source.Depth);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetZ, 0, Depth);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
Guard.IsBetweenOrEqualTo(depth, 1, Depth);
+5 -4
ファイルの表示
@@ -1,3 +1,4 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
@@ -61,7 +62,7 @@ public sealed class ConstantBuffer<T> : Buffer<T>
internal override unsafe void CopyTo(ref T destination, int offset, int length)
{
Guard.IsBetweenOrEqualTo(length, 0, Length);
Guard.IsInRange(offset, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(offset, 0, Length);
Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(offset));
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
@@ -89,9 +90,9 @@ public sealed class ConstantBuffer<T> : Buffer<T>
{
Guard.IsBetweenOrEqualTo(length, 0, Length);
Guard.IsBetweenOrEqualTo(length, 0, destination.Length);
Guard.IsInRange(sourceOffset, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, Length);
Guard.IsLessThanOrEqualTo(sourceOffset + length, Length, nameof(sourceOffset));
Guard.IsInRange(destinationOffset, 0, destination.Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffset, 0, destination.Length);
Guard.IsLessThanOrEqualTo(destinationOffset + length, destination.Length, nameof(destinationOffset));
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
@@ -126,7 +127,7 @@ public sealed class ConstantBuffer<T> : Buffer<T>
internal override unsafe void CopyFrom(ref T source, int offset, int length)
{
Guard.IsBetweenOrEqualTo(length, 0, Length);
Guard.IsInRange(offset, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(offset, 0, Length);
Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(offset));
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
+3 -3
ファイルの表示
@@ -127,8 +127,8 @@ public readonly unsafe ref struct TextureView2D<T>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
Guard.IsInRange(x, 0, this.width);
Guard.IsInRange(y, 0, this.height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(x, 0, this.width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(y, 0, this.height);
return ref *((T*)((byte*)this.pointer + (y * this.strideInBytes)) + x);
}
@@ -297,7 +297,7 @@ public readonly unsafe ref struct TextureView2D<T>
/// <returns>The resulting row <see cref="Span{T}"/>.</returns>
public Span<T> GetRowSpan(int y)
{
Guard.IsInRange(y, 0, this.height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(y, 0, this.height);
return new((byte*)this.pointer + (y * this.strideInBytes), this.width);
}
+6 -6
ファイルの表示
@@ -152,9 +152,9 @@ public readonly unsafe ref struct TextureView3D<T>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
Guard.IsInRange(x, 0, this.width);
Guard.IsInRange(y, 0, this.height);
Guard.IsInRange(z, 0, this.depth);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(x, 0, this.width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(y, 0, this.height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(z, 0, this.depth);
return ref *((T*)((byte*)this.pointer + (z * this.height * this.strideInBytes) + (y * this.strideInBytes)) + x);
}
@@ -336,8 +336,8 @@ public readonly unsafe ref struct TextureView3D<T>
/// <returns>The resulting row <see cref="Span{T}"/>.</returns>
public Span<T> GetRowSpan(int y, int z)
{
Guard.IsInRange(y, 0, this.height);
Guard.IsInRange(z, 0, this.depth);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(y, 0, this.height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(z, 0, this.depth);
return new((byte*)this.pointer + (z * this.height * this.strideInBytes) + (y * this.strideInBytes), this.width);
}
@@ -350,7 +350,7 @@ public readonly unsafe ref struct TextureView3D<T>
/// <returns>The resulting row <see cref="TextureView2D{T}"/>.</returns>
public TextureView2D<T> GetDepthView(int z)
{
Guard.IsInRange(z, 0, this.depth);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(z, 0, this.depth);
return new(
(T*)((byte*)this.pointer + (z * this.height * this.strideInBytes)),