diff --git a/.gitignore b/.gitignore
index ed0e87e25e0..4e9d1eddb81 100644
--- a/.gitignore
+++ b/.gitignore
@@ -225,3 +225,6 @@ msbuild.binlog
*.project.lock.json
/build/tools/**
!/build/tools/packages.config
+
+# Generated file from .ttinclude
+**/Generated/TypeInfo.g.cs
\ No newline at end of file
diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RadialGauge/RadialGaugeCode.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RadialGauge/RadialGaugeCode.bind
index cfd2706e3d1..9a332b448d4 100644
--- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RadialGauge/RadialGaugeCode.bind
+++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RadialGauge/RadialGaugeCode.bind
@@ -26,6 +26,7 @@
MinAngle="@[MinAngle:Slider:210:0-360]"
MaxAngle="@[MaxAngle:Slider:150:0-360]"
Unit="units"
+ ValueStringFormat="@[ValueStringFormat:String:N0]"
NeedleWidth="@[NeedleWidth:Slider:4:1-10]"
NeedleLength="@[NeedleLength:Slider:100:20-100]"
TickLength="@[TickLength:Slider:10:0-30]"
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/RadialGauge/RadialGauge.cs b/Microsoft.Toolkit.Uwp.UI.Controls/RadialGauge/RadialGauge.cs
index f105bed8a10..256a6268757 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls/RadialGauge/RadialGauge.cs
+++ b/Microsoft.Toolkit.Uwp.UI.Controls/RadialGauge/RadialGauge.cs
@@ -88,7 +88,7 @@ public class RadialGauge : RangeBase
/// Identifies the ValueStringFormat dependency property.
///
public static readonly DependencyProperty ValueStringFormatProperty =
- DependencyProperty.Register(nameof(ValueStringFormat), typeof(string), typeof(RadialGauge), new PropertyMetadata("N0"));
+ DependencyProperty.Register(nameof(ValueStringFormat), typeof(string), typeof(RadialGauge), new PropertyMetadata("N0", (s, e) => OnValueChanged(s)));
///
/// Identifies the TickSpacing dependency property.
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/RadialGauge/RadialGauge.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/RadialGauge/RadialGauge.xaml
index 5a70512d6f9..d9b428eceb5 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls/RadialGauge/RadialGauge.xaml
+++ b/Microsoft.Toolkit.Uwp.UI.Controls/RadialGauge/RadialGauge.xaml
@@ -108,7 +108,6 @@
FontSize="20"
FontWeight="SemiBold"
Foreground="{TemplateBinding Foreground}"
- Text="{TemplateBinding Value}"
TextAlignment="Center" />
public static class EventHandlerExtensions
{
- private static readonly Task CompletedTask = Task.FromResult(0);
-
///
/// Use to invoke an async using .
///
@@ -46,7 +42,7 @@ public static Task InvokeAsync(this EventHandler eventHandler, object send
{
if (eventHandler == null)
{
- return CompletedTask;
+ return Task.CompletedTask;
}
var tasks = eventHandler.GetInvocationList()
@@ -59,7 +55,7 @@ public static Task InvokeAsync(this EventHandler eventHandler, object send
var deferral = eventArgs.GetCurrentDeferralAndReset();
- return deferral?.WaitForCompletion(cancellationToken) ?? CompletedTask;
+ return deferral?.WaitForCompletion(cancellationToken) ?? Task.CompletedTask;
})
.ToArray();
diff --git a/Microsoft.Toolkit.Uwp/Deferred/TypedEventHandlerExtensions.cs b/Microsoft.Toolkit.Uwp/Deferred/TypedEventHandlerExtensions.cs
index 20a50adcd3d..9e7258e9775 100644
--- a/Microsoft.Toolkit.Uwp/Deferred/TypedEventHandlerExtensions.cs
+++ b/Microsoft.Toolkit.Uwp/Deferred/TypedEventHandlerExtensions.cs
@@ -15,8 +15,6 @@ namespace Microsoft.Toolkit.Uwp.Deferred
///
public static class TypedEventHandlerExtensions
{
- private static readonly Task CompletedTask = Task.FromResult(0);
-
///
/// Use to invoke an async using .
///
@@ -47,7 +45,7 @@ public static Task InvokeAsync(this TypedEventHandler eventHandler,
{
if (eventHandler == null)
{
- return CompletedTask;
+ return Task.CompletedTask;
}
var tasks = eventHandler.GetInvocationList()
@@ -60,7 +58,7 @@ public static Task InvokeAsync(this TypedEventHandler eventHandler,
var deferral = eventArgs.GetCurrentDeferralAndReset();
- return deferral?.WaitForCompletion(cancellationToken) ?? CompletedTask;
+ return deferral?.WaitForCompletion(cancellationToken) ?? Task.CompletedTask;
})
.ToArray();
diff --git a/Microsoft.Toolkit/Converters.cs b/Microsoft.Toolkit/Converters.cs
index a7a2ef509ad..20cb290b8b0 100644
--- a/Microsoft.Toolkit/Converters.cs
+++ b/Microsoft.Toolkit/Converters.cs
@@ -2,10 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections.Generic;
-using System.Text;
-
namespace Microsoft.Toolkit
{
///
diff --git a/Microsoft.Toolkit/Diagnostics/Generated/Guard.Collection.g.cs b/Microsoft.Toolkit/Diagnostics/Generated/Guard.Collection.g.cs
new file mode 100644
index 00000000000..346241db8cc
--- /dev/null
+++ b/Microsoft.Toolkit/Diagnostics/Generated/Guard.Collection.g.cs
@@ -0,0 +1,1638 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* ========================
+ * Auto generated file
+ * ===================== */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+
+#nullable enable
+
+namespace Microsoft.Toolkit.Diagnostics
+{
+ ///
+ /// Helper methods to verify conditions when running code.
+ ///
+ public static partial class Guard
+ {
+ ///
+ /// Asserts that the input instance must be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEmpty(Span span, string name)
+ {
+ if (span.Length != 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEmpty(span, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must not be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEmpty(Span span, string name)
+ {
+ if (span.Length == 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmptyWithSpan(name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(Span span, int size, string name)
+ {
+ if (span.Length != size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(span, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size not equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeNotEqualTo(Span span, int size, string name)
+ {
+ if (span.Length == size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeNotEqualTo(span, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size over a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is <= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeOver(Span span, int size, string name)
+ {
+ if (span.Length <= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeOver(span, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of at least or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is < .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeAtLeast(Span span, int size, string name)
+ {
+ if (span.Length < size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeAtLeast(span, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is >= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThan(Span span, int size, string name)
+ {
+ if (span.Length >= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThan(span, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(Span span, int size, string name)
+ {
+ if (span.Length > size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(span, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have the same size of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(Span source, Span destination, string name)
+ {
+ if (source.Length != destination.Length)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(source, destination, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have a size of less than or equal to that of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(Span source, Span destination, string name)
+ {
+ if (source.Length > destination.Length)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(source, destination, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is not valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRangeFor(int index, Span span, string name)
+ {
+ if ((uint)index >= (uint)span.Length)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRangeFor(index, span, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is not valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRangeFor(int index, Span span, string name)
+ {
+ if ((uint)index < (uint)span.Length)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(index, span, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEmpty(ReadOnlySpan span, string name)
+ {
+ if (span.Length != 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEmpty(span, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must not be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEmpty(ReadOnlySpan span, string name)
+ {
+ if (span.Length == 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmptyWithReadOnlySpan(name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(ReadOnlySpan span, int size, string name)
+ {
+ if (span.Length != size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(span, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size not equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeNotEqualTo(ReadOnlySpan span, int size, string name)
+ {
+ if (span.Length == size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeNotEqualTo(span, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size over a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is <= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeOver(ReadOnlySpan span, int size, string name)
+ {
+ if (span.Length <= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeOver(span, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of at least or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is < .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeAtLeast(ReadOnlySpan span, int size, string name)
+ {
+ if (span.Length < size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeAtLeast(span, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is >= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThan(ReadOnlySpan span, int size, string name)
+ {
+ if (span.Length >= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThan(span, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(ReadOnlySpan span, int size, string name)
+ {
+ if (span.Length > size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(span, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have the same size of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(ReadOnlySpan source, Span destination, string name)
+ {
+ if (source.Length != destination.Length)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(source, destination, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have a size of less than or equal to that of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(ReadOnlySpan source, Span destination, string name)
+ {
+ if (source.Length > destination.Length)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(source, destination, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is not valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRangeFor(int index, ReadOnlySpan span, string name)
+ {
+ if ((uint)index >= (uint)span.Length)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRangeFor(index, span, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is not valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRangeFor(int index, ReadOnlySpan span, string name)
+ {
+ if ((uint)index < (uint)span.Length)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(index, span, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEmpty(Memory memory, string name)
+ {
+ if (memory.Length != 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEmpty(memory, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must not be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEmpty(Memory memory, string name)
+ {
+ if (memory.Length == 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmpty>(name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(Memory memory, int size, string name)
+ {
+ if (memory.Length != size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(memory, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size not equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeNotEqualTo(Memory memory, int size, string name)
+ {
+ if (memory.Length == size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeNotEqualTo(memory, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size over a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is <= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeOver(Memory memory, int size, string name)
+ {
+ if (memory.Length <= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeOver(memory, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of at least or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is < .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeAtLeast(Memory memory, int size, string name)
+ {
+ if (memory.Length < size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeAtLeast(memory, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is >= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThan(Memory memory, int size, string name)
+ {
+ if (memory.Length >= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThan(memory, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(Memory memory, int size, string name)
+ {
+ if (memory.Length > size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(memory, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have the same size of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(Memory source, Memory destination, string name)
+ {
+ if (source.Length != destination.Length)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(source, destination, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have a size of less than or equal to that of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(Memory source, Memory destination, string name)
+ {
+ if (source.Length > destination.Length)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(source, destination, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is not valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRangeFor(int index, Memory memory, string name)
+ {
+ if ((uint)index >= (uint)memory.Length)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRangeFor(index, memory, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is not valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRangeFor(int index, Memory memory, string name)
+ {
+ if ((uint)index < (uint)memory.Length)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(index, memory, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEmpty(ReadOnlyMemory memory, string name)
+ {
+ if (memory.Length != 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEmpty(memory, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must not be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEmpty(ReadOnlyMemory memory, string name)
+ {
+ if (memory.Length == 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmpty>(name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(ReadOnlyMemory memory, int size, string name)
+ {
+ if (memory.Length != size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(memory, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size not equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeNotEqualTo(ReadOnlyMemory memory, int size, string name)
+ {
+ if (memory.Length == size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeNotEqualTo(memory, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size over a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is <= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeOver(ReadOnlyMemory memory, int size, string name)
+ {
+ if (memory.Length <= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeOver(memory, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of at least or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is < .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeAtLeast(ReadOnlyMemory memory, int size, string name)
+ {
+ if (memory.Length < size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeAtLeast(memory, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is >= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThan(ReadOnlyMemory memory, int size, string name)
+ {
+ if (memory.Length >= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThan(memory, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(ReadOnlyMemory memory, int size, string name)
+ {
+ if (memory.Length > size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(memory, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have the same size of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(ReadOnlyMemory source, Memory destination, string name)
+ {
+ if (source.Length != destination.Length)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(source, destination, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have a size of less than or equal to that of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(ReadOnlyMemory source, Memory destination, string name)
+ {
+ if (source.Length > destination.Length)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(source, destination, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is not valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRangeFor(int index, ReadOnlyMemory memory, string name)
+ {
+ if ((uint)index >= (uint)memory.Length)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRangeFor(index, memory, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is not valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRangeFor(int index, ReadOnlyMemory memory, string name)
+ {
+ if ((uint)index < (uint)memory.Length)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(index, memory, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input array instance must be empty.
+ ///
+ /// The item of items in the input array instance.
+ /// The input array instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEmpty(T[] array, string name)
+ {
+ if (array.Length != 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEmpty(array, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input array instance must not be empty.
+ ///
+ /// The item of items in the input array instance.
+ /// The input array instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEmpty(T[] array, string name)
+ {
+ if (array.Length == 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmpty(name);
+ }
+ }
+
+ ///
+ /// Asserts that the input array instance must have a size of a specified value.
+ ///
+ /// The item of items in the input array instance.
+ /// The input array instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(T[] array, int size, string name)
+ {
+ if (array.Length != size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(array, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input array instance must have a size not equal to a specified value.
+ ///
+ /// The item of items in the input array instance.
+ /// The input array instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeNotEqualTo(T[] array, int size, string name)
+ {
+ if (array.Length == size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeNotEqualTo(array, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input array instance must have a size over a specified value.
+ ///
+ /// The item of items in the input array instance.
+ /// The input array instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is <= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeOver(T[] array, int size, string name)
+ {
+ if (array.Length <= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeOver(array, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input array instance must have a size of at least or equal to a specified value.
+ ///
+ /// The item of items in the input array instance.
+ /// The input array instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is < .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeAtLeast(T[] array, int size, string name)
+ {
+ if (array.Length < size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeAtLeast(array, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input array instance must have a size of less than a specified value.
+ ///
+ /// The item of items in the input array instance.
+ /// The input array instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is >= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThan(T[] array, int size, string name)
+ {
+ if (array.Length >= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThan(array, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input array instance must have a size of less than or equal to a specified value.
+ ///
+ /// The item of items in the input array instance.
+ /// The input array instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(T[] array, int size, string name)
+ {
+ if (array.Length > size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(array, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source array instance must have the same size of a destination array instance.
+ ///
+ /// The item of items in the input array instance.
+ /// The source array instance to check the size for.
+ /// The destination array instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(T[] source, T[] destination, string name)
+ {
+ if (source.Length != destination.Length)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(source, destination, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source array instance must have a size of less than or equal to that of a destination array instance.
+ ///
+ /// The item of items in the input array instance.
+ /// The source array instance to check the size for.
+ /// The destination array instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(T[] source, T[] destination, string name)
+ {
+ if (source.Length > destination.Length)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(source, destination, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is valid for a given array instance.
+ ///
+ /// The item of items in the input array instance.
+ /// The input index to be used to access .
+ /// The input array instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is not valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRangeFor(int index, T[] array, string name)
+ {
+ if ((uint)index >= (uint)array.Length)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRangeFor(index, array, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is not valid for a given array instance.
+ ///
+ /// The item of items in the input array instance.
+ /// The input index to be used to access .
+ /// The input array instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRangeFor(int index, T[] array, string name)
+ {
+ if ((uint)index < (uint)array.Length)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(index, array, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEmpty(List list, string name)
+ {
+ if (list.Count != 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEmpty((ICollection)list, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must not be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEmpty(List list, string name)
+ {
+ if (list.Count == 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmpty>(name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(List list, int size, string name)
+ {
+ if (list.Count != size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo((ICollection)list, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size not equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeNotEqualTo(List list, int size, string name)
+ {
+ if (list.Count == size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeNotEqualTo((ICollection)list, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size over a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is <= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeOver(List list, int size, string name)
+ {
+ if (list.Count <= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeOver((ICollection)list, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of at least or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is < .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeAtLeast(List list, int size, string name)
+ {
+ if (list.Count < size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeAtLeast((ICollection)list, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is >= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThan(List list, int size, string name)
+ {
+ if (list.Count >= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThan((ICollection)list, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(List list, int size, string name)
+ {
+ if (list.Count > size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo((ICollection)list, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have the same size of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(List source, List destination, string name)
+ {
+ if (source.Count != destination.Count)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo((ICollection)source, destination.Count, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have a size of less than or equal to that of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(List source, List destination, string name)
+ {
+ if (source.Count > destination.Count)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo((ICollection)source, destination.Count, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is not valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRangeFor(int index, List list, string name)
+ {
+ if ((uint)index >= (uint)list.Count)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRangeFor(index, (ICollection)list, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is not valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRangeFor(int index, List list, string name)
+ {
+ if ((uint)index < (uint)list.Count)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(index, (ICollection)list, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEmpty(ICollection collection, string name)
+ {
+ if (collection.Count != 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEmpty(collection, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must not be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEmpty(ICollection collection, string name)
+ {
+ if (collection.Count == 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmpty>(name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(ICollection collection, int size, string name)
+ {
+ if (collection.Count != size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(collection, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size not equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeNotEqualTo(ICollection collection, int size, string name)
+ {
+ if (collection.Count == size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeNotEqualTo(collection, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size over a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is <= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeOver(ICollection collection, int size, string name)
+ {
+ if (collection.Count <= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeOver(collection, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of at least or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is < .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeAtLeast(ICollection collection, int size, string name)
+ {
+ if (collection.Count < size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeAtLeast(collection, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is >= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThan(ICollection collection, int size, string name)
+ {
+ if (collection.Count >= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThan(collection, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(ICollection collection, int size, string name)
+ {
+ if (collection.Count > size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(collection, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have the same size of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(ICollection source, ICollection destination, string name)
+ {
+ if (source.Count != destination.Count)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(source, destination.Count, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have a size of less than or equal to that of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(ICollection source, ICollection destination, string name)
+ {
+ if (source.Count > destination.Count)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(source, destination.Count, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is not valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRangeFor(int index, ICollection collection, string name)
+ {
+ if ((uint)index >= (uint)collection.Count)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRangeFor(index, collection, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is not valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRangeFor(int index, ICollection collection, string name)
+ {
+ if ((uint)index < (uint)collection.Count)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(index, collection, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEmpty(IReadOnlyCollection collection, string name)
+ {
+ if (collection.Count != 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEmpty(collection, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must not be empty.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEmpty(IReadOnlyCollection collection, string name)
+ {
+ if (collection.Count == 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmpty>(name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(IReadOnlyCollection collection, int size, string name)
+ {
+ if (collection.Count != size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(collection, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size not equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeNotEqualTo(IReadOnlyCollection collection, int size, string name)
+ {
+ if (collection.Count == size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeNotEqualTo(collection, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size over a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is <= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeOver(IReadOnlyCollection collection, int size, string name)
+ {
+ if (collection.Count <= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeOver(collection, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of at least or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is < .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeAtLeast(IReadOnlyCollection collection, int size, string name)
+ {
+ if (collection.Count < size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeAtLeast(collection, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is >= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThan(IReadOnlyCollection collection, int size, string name)
+ {
+ if (collection.Count >= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThan(collection, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input instance must have a size of less than or equal to a specified value.
+ ///
+ /// The item of items in the input instance.
+ /// The input instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(IReadOnlyCollection collection, int size, string name)
+ {
+ if (collection.Count > size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(collection, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have the same size of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(IReadOnlyCollection source, ICollection destination, string name)
+ {
+ if (source.Count != destination.Count)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(source, destination.Count, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source instance must have a size of less than or equal to that of a destination instance.
+ ///
+ /// The item of items in the input instance.
+ /// The source instance to check the size for.
+ /// The destination instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(IReadOnlyCollection source, ICollection destination, string name)
+ {
+ if (source.Count > destination.Count)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(source, destination.Count, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is not valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRangeFor(int index, IReadOnlyCollection collection, string name)
+ {
+ if ((uint)index >= (uint)collection.Count)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRangeFor(index, collection, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is not valid for a given instance.
+ ///
+ /// The item of items in the input instance.
+ /// The input index to be used to access .
+ /// The input instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRangeFor(int index, IReadOnlyCollection collection, string name)
+ {
+ if ((uint)index < (uint)collection.Count)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(index, collection, name);
+ }
+ }
+ }
+}
diff --git a/Microsoft.Toolkit/Diagnostics/Generated/Guard.Collection.tt b/Microsoft.Toolkit/Diagnostics/Generated/Guard.Collection.tt
new file mode 100644
index 00000000000..37430fced50
--- /dev/null
+++ b/Microsoft.Toolkit/Diagnostics/Generated/Guard.Collection.tt
@@ -0,0 +1,283 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+<#@include file="TypeInfo.ttinclude" #>
+/* ========================
+ * Auto generated file
+ * ===================== */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+
+#nullable enable
+
+namespace Microsoft.Toolkit.Diagnostics
+{
+ ///
+ /// Helper methods to verify conditions when running code.
+ ///
+ public static partial class Guard
+ {
+<#
+GenerateTextForItems(EnumerableTypes, item =>
+{
+#>
+ ///
+ /// Asserts that the input <#=item.XmlType#> instance must be empty.
+ ///
+ /// The item of items in the input <#=item.XmlType#> instance.
+ /// The input <#=item.XmlType#> instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEmpty(<#=item.Type#> <#=item.Name#>, string name)
+ {
+ if (<#=item.Name#>.<#=item.Size#> != 0)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEmpty(<#=item.Cast#><#=item.Name#>, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input <#=item.XmlType#> instance must not be empty.
+ ///
+ /// The item of items in the input <#=item.XmlType#> instance.
+ /// The input <#=item.XmlType#> instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == 0.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEmpty(<#=item.Type#> <#=item.Name#>, string name)
+ {
+ if (<#=item.Name#>.<#=item.Size#> == 0)
+ {
+<#
+ if (item.Type == "Span")
+ {
+#>
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmptyWithSpan(name);
+<#
+ }
+ else if (item.Type == "ReadOnlySpan")
+ {
+#>
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmptyWithReadOnlySpan(name);
+<#
+ }
+ else
+ {
+#>
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmpty<<#=item.Type#>>(name);
+<#
+ }
+#>
+ }
+ }
+
+ ///
+ /// Asserts that the input <#=item.XmlType#> instance must have a size of a specified value.
+ ///
+ /// The item of items in the input <#=item.XmlType#> instance.
+ /// The input <#=item.XmlType#> instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(<#=item.Type#> <#=item.Name#>, int size, string name)
+ {
+ if (<#=item.Name#>.<#=item.Size#> != size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(<#=item.Cast#><#=item.Name#>, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input <#=item.XmlType#> instance must have a size not equal to a specified value.
+ ///
+ /// The item of items in the input <#=item.XmlType#> instance.
+ /// The input <#=item.XmlType#> instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is == .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeNotEqualTo(<#=item.Type#> <#=item.Name#>, int size, string name)
+ {
+ if (<#=item.Name#>.<#=item.Size#> == size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeNotEqualTo(<#=item.Cast#><#=item.Name#>, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input <#=item.XmlType#> instance must have a size over a specified value.
+ ///
+ /// The item of items in the input <#=item.XmlType#> instance.
+ /// The input <#=item.XmlType#> instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is <= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeOver(<#=item.Type#> <#=item.Name#>, int size, string name)
+ {
+ if (<#=item.Name#>.<#=item.Size#> <= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeOver(<#=item.Cast#><#=item.Name#>, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input <#=item.XmlType#> instance must have a size of at least or equal to a specified value.
+ ///
+ /// The item of items in the input <#=item.XmlType#> instance.
+ /// The input <#=item.XmlType#> instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is < .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeAtLeast(<#=item.Type#> <#=item.Name#>, int size, string name)
+ {
+ if (<#=item.Name#>.<#=item.Size#> < size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeAtLeast(<#=item.Cast#><#=item.Name#>, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input <#=item.XmlType#> instance must have a size of less than a specified value.
+ ///
+ /// The item of items in the input <#=item.XmlType#> instance.
+ /// The input <#=item.XmlType#> instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is >= .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThan(<#=item.Type#> <#=item.Name#>, int size, string name)
+ {
+ if (<#=item.Name#>.<#=item.Size#> >= size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThan(<#=item.Cast#><#=item.Name#>, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input <#=item.XmlType#> instance must have a size of less than or equal to a specified value.
+ ///
+ /// The item of items in the input <#=item.XmlType#> instance.
+ /// The input <#=item.XmlType#> instance to check the size for.
+ /// The target size to test.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(<#=item.Type#> <#=item.Name#>, int size, string name)
+ {
+ if (<#=item.Name#>.<#=item.Size#> > size)
+ {
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(<#=item.Cast#><#=item.Name#>, size, name);
+ }
+ }
+
+ ///
+ /// Asserts that the source <#=item.XmlType#> instance must have the same size of a destination <#=item.XmlType#> instance.
+ ///
+ /// The item of items in the input <#=item.XmlType#> instance.
+ /// The source <#=item.XmlType#> instance to check the size for.
+ /// The destination <#=item.XmlType#> instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is != the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeEqualTo(<#=item.Type#> source, <#=item.DestinationType#> destination, string name)
+ {
+ if (source.<#=item.Size#> != destination.<#=item.Size#>)
+ {
+<#
+ if (item.HasCountProperty)
+ {
+#>
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(<#=item.Cast#>source, destination.<#=item.Size#>, name);
+<#
+ }
+ else
+ {
+#>
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(source, <#=item.Cast#>destination, name);
+<#
+ }
+#>
+ }
+ }
+
+ ///
+ /// Asserts that the source <#=item.XmlType#> instance must have a size of less than or equal to that of a destination <#=item.XmlType#> instance.
+ ///
+ /// The item of items in the input <#=item.XmlType#> instance.
+ /// The source <#=item.XmlType#> instance to check the size for.
+ /// The destination <#=item.XmlType#> instance to check the size for.
+ /// The name of the input parameter being tested.
+ /// Thrown if the size of is > the one of .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void HasSizeLessThanOrEqualTo(<#=item.Type#> source, <#=item.DestinationType#> destination, string name)
+ {
+ if (source.<#=item.Size#> > destination.<#=item.Size#>)
+ {
+<#
+ if (item.HasCountProperty)
+ {
+#>
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(<#=item.Cast#>source, destination.<#=item.Size#>, name);
+<#
+ }
+ else
+ {
+#>
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(source, <#=item.Cast#>destination, name);
+<#
+ }
+#>
+ }
+ }
+
+ ///
+ /// Asserts that the input index is valid for a given <#=item.XmlType#> instance.
+ ///
+ /// The item of items in the input <#=item.XmlType#> instance.
+ /// The input index to be used to access .
+ /// The input <#=item.XmlType#> instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is not valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRangeFor(int index, <#=item.Type#> <#=item.Name#>, string name)
+ {
+<#
+ /* Here we're leveraging the fact that signed integers are represented
+ * in 2-complement to perform the bounds check with a single compare operation.
+ * This is the same trick used throughout CoreCLR as well.
+ * For more info and code sample, see the original conversation here:
+ * https://github.com/windows-toolkit/WindowsCommunityToolkit/pull/3131#discussion_r390682835 */
+#>
+ if ((uint)index >= (uint)<#=item.Name#>.<#=item.Size#>)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRangeFor(index, <#=item.Cast#><#=item.Name#>, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input index is not valid for a given <#=item.XmlType#> instance.
+ ///
+ /// The item of items in the input <#=item.XmlType#> instance.
+ /// The input index to be used to access .
+ /// The input <#=item.XmlType#> instance to use to validate .
+ /// The name of the input parameter being tested.
+ /// Thrown if is valid to access .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRangeFor(int index, <#=item.Type#> <#=item.Name#>, string name)
+ {
+ if ((uint)index < (uint)<#=item.Name#>.<#=item.Size#>)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(index, <#=item.Cast#><#=item.Name#>, name);
+ }
+ }
+<#
+});
+#>
+ }
+}
diff --git a/Microsoft.Toolkit/Diagnostics/Generated/Guard.Comparable.Numeric.g.cs b/Microsoft.Toolkit/Diagnostics/Generated/Guard.Comparable.Numeric.g.cs
new file mode 100644
index 00000000000..ec0d08fd788
--- /dev/null
+++ b/Microsoft.Toolkit/Diagnostics/Generated/Guard.Comparable.Numeric.g.cs
@@ -0,0 +1,2745 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* ========================
+ * Auto generated file
+ * ===================== */
+
+using System;
+using System.Runtime.CompilerServices;
+
+#nullable enable
+
+namespace Microsoft.Toolkit.Diagnostics
+{
+ ///
+ /// Helper methods to verify conditions when running code.
+ ///
+ public static partial class Guard
+ {
+ ///
+ /// Asserts that the input value must be equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEqualTo(byte value, byte target, string name)
+ {
+ if (value != target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be not equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is == .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEqualTo(byte value, byte target, string name)
+ {
+ if (value == target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThan(byte value, byte maximum, string name)
+ {
+ if (value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThanOrEqualTo(byte value, byte maximum, string name)
+ {
+ if (value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThan(byte value, byte minimum, string name)
+ {
+ if (value <= minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThanOrEqualTo(byte value, byte minimum, string name)
+ {
+ if (value < minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or >= .
+ ///
+ /// This API asserts the equivalent of " in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRange(byte value, byte minimum, byte maximum, string name)
+ {
+ if (value < minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or < .
+ ///
+ /// This API asserts the equivalent of " not in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRange(byte value, byte minimum, byte maximum, string name)
+ {
+ if (value >= minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= or >= .
+ ///
+ /// This API asserts the equivalent of " in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetween(byte value, byte minimum, byte maximum, string name)
+ {
+ if (value <= minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > or < .
+ ///
+ /// This API asserts the equivalent of " not in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetween(byte value, byte minimum, byte maximum, string name)
+ {
+ if (value > minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or > .
+ ///
+ /// This API asserts the equivalent of " in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetweenOrEqualTo(byte value, byte minimum, byte maximum, string name)
+ {
+ if (value < minimum || value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or <= .
+ ///
+ /// This API asserts the equivalent of " not in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetweenOrEqualTo(byte value, byte minimum, byte maximum, string name)
+ {
+ if (value >= minimum && value <= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEqualTo(sbyte value, sbyte target, string name)
+ {
+ if (value != target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be not equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is == .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEqualTo(sbyte value, sbyte target, string name)
+ {
+ if (value == target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThan(sbyte value, sbyte maximum, string name)
+ {
+ if (value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThanOrEqualTo(sbyte value, sbyte maximum, string name)
+ {
+ if (value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThan(sbyte value, sbyte minimum, string name)
+ {
+ if (value <= minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThanOrEqualTo(sbyte value, sbyte minimum, string name)
+ {
+ if (value < minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or >= .
+ ///
+ /// This API asserts the equivalent of " in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRange(sbyte value, sbyte minimum, sbyte maximum, string name)
+ {
+ if (value < minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or < .
+ ///
+ /// This API asserts the equivalent of " not in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRange(sbyte value, sbyte minimum, sbyte maximum, string name)
+ {
+ if (value >= minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= or >= .
+ ///
+ /// This API asserts the equivalent of " in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetween(sbyte value, sbyte minimum, sbyte maximum, string name)
+ {
+ if (value <= minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > or < .
+ ///
+ /// This API asserts the equivalent of " not in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetween(sbyte value, sbyte minimum, sbyte maximum, string name)
+ {
+ if (value > minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or > .
+ ///
+ /// This API asserts the equivalent of " in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetweenOrEqualTo(sbyte value, sbyte minimum, sbyte maximum, string name)
+ {
+ if (value < minimum || value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or <= .
+ ///
+ /// This API asserts the equivalent of " not in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetweenOrEqualTo(sbyte value, sbyte minimum, sbyte maximum, string name)
+ {
+ if (value >= minimum && value <= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEqualTo(short value, short target, string name)
+ {
+ if (value != target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be not equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is == .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEqualTo(short value, short target, string name)
+ {
+ if (value == target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThan(short value, short maximum, string name)
+ {
+ if (value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThanOrEqualTo(short value, short maximum, string name)
+ {
+ if (value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThan(short value, short minimum, string name)
+ {
+ if (value <= minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThanOrEqualTo(short value, short minimum, string name)
+ {
+ if (value < minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or >= .
+ ///
+ /// This API asserts the equivalent of " in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRange(short value, short minimum, short maximum, string name)
+ {
+ if (value < minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or < .
+ ///
+ /// This API asserts the equivalent of " not in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRange(short value, short minimum, short maximum, string name)
+ {
+ if (value >= minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= or >= .
+ ///
+ /// This API asserts the equivalent of " in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetween(short value, short minimum, short maximum, string name)
+ {
+ if (value <= minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > or < .
+ ///
+ /// This API asserts the equivalent of " not in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetween(short value, short minimum, short maximum, string name)
+ {
+ if (value > minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or > .
+ ///
+ /// This API asserts the equivalent of " in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetweenOrEqualTo(short value, short minimum, short maximum, string name)
+ {
+ if (value < minimum || value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or <= .
+ ///
+ /// This API asserts the equivalent of " not in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetweenOrEqualTo(short value, short minimum, short maximum, string name)
+ {
+ if (value >= minimum && value <= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEqualTo(ushort value, ushort target, string name)
+ {
+ if (value != target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be not equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is == .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEqualTo(ushort value, ushort target, string name)
+ {
+ if (value == target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThan(ushort value, ushort maximum, string name)
+ {
+ if (value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThanOrEqualTo(ushort value, ushort maximum, string name)
+ {
+ if (value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThan(ushort value, ushort minimum, string name)
+ {
+ if (value <= minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThanOrEqualTo(ushort value, ushort minimum, string name)
+ {
+ if (value < minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or >= .
+ ///
+ /// This API asserts the equivalent of " in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRange(ushort value, ushort minimum, ushort maximum, string name)
+ {
+ if (value < minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or < .
+ ///
+ /// This API asserts the equivalent of " not in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRange(ushort value, ushort minimum, ushort maximum, string name)
+ {
+ if (value >= minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= or >= .
+ ///
+ /// This API asserts the equivalent of " in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetween(ushort value, ushort minimum, ushort maximum, string name)
+ {
+ if (value <= minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > or < .
+ ///
+ /// This API asserts the equivalent of " not in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetween(ushort value, ushort minimum, ushort maximum, string name)
+ {
+ if (value > minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or > .
+ ///
+ /// This API asserts the equivalent of " in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetweenOrEqualTo(ushort value, ushort minimum, ushort maximum, string name)
+ {
+ if (value < minimum || value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or <= .
+ ///
+ /// This API asserts the equivalent of " not in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetweenOrEqualTo(ushort value, ushort minimum, ushort maximum, string name)
+ {
+ if (value >= minimum && value <= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEqualTo(char value, char target, string name)
+ {
+ if (value != target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be not equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is == .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEqualTo(char value, char target, string name)
+ {
+ if (value == target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThan(char value, char maximum, string name)
+ {
+ if (value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThanOrEqualTo(char value, char maximum, string name)
+ {
+ if (value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThan(char value, char minimum, string name)
+ {
+ if (value <= minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThanOrEqualTo(char value, char minimum, string name)
+ {
+ if (value < minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or >= .
+ ///
+ /// This API asserts the equivalent of " in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRange(char value, char minimum, char maximum, string name)
+ {
+ if (value < minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or < .
+ ///
+ /// This API asserts the equivalent of " not in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRange(char value, char minimum, char maximum, string name)
+ {
+ if (value >= minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= or >= .
+ ///
+ /// This API asserts the equivalent of " in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetween(char value, char minimum, char maximum, string name)
+ {
+ if (value <= minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > or < .
+ ///
+ /// This API asserts the equivalent of " not in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetween(char value, char minimum, char maximum, string name)
+ {
+ if (value > minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or > .
+ ///
+ /// This API asserts the equivalent of " in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetweenOrEqualTo(char value, char minimum, char maximum, string name)
+ {
+ if (value < minimum || value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or <= .
+ ///
+ /// This API asserts the equivalent of " not in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetweenOrEqualTo(char value, char minimum, char maximum, string name)
+ {
+ if (value >= minimum && value <= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEqualTo(int value, int target, string name)
+ {
+ if (value != target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be not equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is == .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEqualTo(int value, int target, string name)
+ {
+ if (value == target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThan(int value, int maximum, string name)
+ {
+ if (value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThanOrEqualTo(int value, int maximum, string name)
+ {
+ if (value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThan(int value, int minimum, string name)
+ {
+ if (value <= minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThanOrEqualTo(int value, int minimum, string name)
+ {
+ if (value < minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or >= .
+ ///
+ /// This API asserts the equivalent of " in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRange(int value, int minimum, int maximum, string name)
+ {
+ if (value < minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or < .
+ ///
+ /// This API asserts the equivalent of " not in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRange(int value, int minimum, int maximum, string name)
+ {
+ if (value >= minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= or >= .
+ ///
+ /// This API asserts the equivalent of " in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetween(int value, int minimum, int maximum, string name)
+ {
+ if (value <= minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > or < .
+ ///
+ /// This API asserts the equivalent of " not in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetween(int value, int minimum, int maximum, string name)
+ {
+ if (value > minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or > .
+ ///
+ /// This API asserts the equivalent of " in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetweenOrEqualTo(int value, int minimum, int maximum, string name)
+ {
+ if (value < minimum || value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or <= .
+ ///
+ /// This API asserts the equivalent of " not in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetweenOrEqualTo(int value, int minimum, int maximum, string name)
+ {
+ if (value >= minimum && value <= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEqualTo(uint value, uint target, string name)
+ {
+ if (value != target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be not equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is == .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEqualTo(uint value, uint target, string name)
+ {
+ if (value == target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThan(uint value, uint maximum, string name)
+ {
+ if (value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThanOrEqualTo(uint value, uint maximum, string name)
+ {
+ if (value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThan(uint value, uint minimum, string name)
+ {
+ if (value <= minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThanOrEqualTo(uint value, uint minimum, string name)
+ {
+ if (value < minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or >= .
+ ///
+ /// This API asserts the equivalent of " in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRange(uint value, uint minimum, uint maximum, string name)
+ {
+ if (value < minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or < .
+ ///
+ /// This API asserts the equivalent of " not in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRange(uint value, uint minimum, uint maximum, string name)
+ {
+ if (value >= minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= or >= .
+ ///
+ /// This API asserts the equivalent of " in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetween(uint value, uint minimum, uint maximum, string name)
+ {
+ if (value <= minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > or < .
+ ///
+ /// This API asserts the equivalent of " not in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetween(uint value, uint minimum, uint maximum, string name)
+ {
+ if (value > minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or > .
+ ///
+ /// This API asserts the equivalent of " in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetweenOrEqualTo(uint value, uint minimum, uint maximum, string name)
+ {
+ if (value < minimum || value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or <= .
+ ///
+ /// This API asserts the equivalent of " not in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetweenOrEqualTo(uint value, uint minimum, uint maximum, string name)
+ {
+ if (value >= minimum && value <= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEqualTo(float value, float target, string name)
+ {
+ if (value != target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be not equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is == .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEqualTo(float value, float target, string name)
+ {
+ if (value == target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThan(float value, float maximum, string name)
+ {
+ if (value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThanOrEqualTo(float value, float maximum, string name)
+ {
+ if (value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThan(float value, float minimum, string name)
+ {
+ if (value <= minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThanOrEqualTo(float value, float minimum, string name)
+ {
+ if (value < minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or >= .
+ ///
+ /// This API asserts the equivalent of " in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRange(float value, float minimum, float maximum, string name)
+ {
+ if (value < minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or < .
+ ///
+ /// This API asserts the equivalent of " not in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRange(float value, float minimum, float maximum, string name)
+ {
+ if (value >= minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= or >= .
+ ///
+ /// This API asserts the equivalent of " in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetween(float value, float minimum, float maximum, string name)
+ {
+ if (value <= minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > or < .
+ ///
+ /// This API asserts the equivalent of " not in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetween(float value, float minimum, float maximum, string name)
+ {
+ if (value > minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or > .
+ ///
+ /// This API asserts the equivalent of " in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetweenOrEqualTo(float value, float minimum, float maximum, string name)
+ {
+ if (value < minimum || value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or <= .
+ ///
+ /// This API asserts the equivalent of " not in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetweenOrEqualTo(float value, float minimum, float maximum, string name)
+ {
+ if (value >= minimum && value <= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEqualTo(long value, long target, string name)
+ {
+ if (value != target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be not equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is == .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEqualTo(long value, long target, string name)
+ {
+ if (value == target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThan(long value, long maximum, string name)
+ {
+ if (value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThanOrEqualTo(long value, long maximum, string name)
+ {
+ if (value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThan(long value, long minimum, string name)
+ {
+ if (value <= minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThanOrEqualTo(long value, long minimum, string name)
+ {
+ if (value < minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or >= .
+ ///
+ /// This API asserts the equivalent of " in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRange(long value, long minimum, long maximum, string name)
+ {
+ if (value < minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or < .
+ ///
+ /// This API asserts the equivalent of " not in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRange(long value, long minimum, long maximum, string name)
+ {
+ if (value >= minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= or >= .
+ ///
+ /// This API asserts the equivalent of " in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetween(long value, long minimum, long maximum, string name)
+ {
+ if (value <= minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > or < .
+ ///
+ /// This API asserts the equivalent of " not in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetween(long value, long minimum, long maximum, string name)
+ {
+ if (value > minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or > .
+ ///
+ /// This API asserts the equivalent of " in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetweenOrEqualTo(long value, long minimum, long maximum, string name)
+ {
+ if (value < minimum || value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or <= .
+ ///
+ /// This API asserts the equivalent of " not in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetweenOrEqualTo(long value, long minimum, long maximum, string name)
+ {
+ if (value >= minimum && value <= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEqualTo(ulong value, ulong target, string name)
+ {
+ if (value != target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be not equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is == .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEqualTo(ulong value, ulong target, string name)
+ {
+ if (value == target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThan(ulong value, ulong maximum, string name)
+ {
+ if (value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThanOrEqualTo(ulong value, ulong maximum, string name)
+ {
+ if (value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThan(ulong value, ulong minimum, string name)
+ {
+ if (value <= minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThanOrEqualTo(ulong value, ulong minimum, string name)
+ {
+ if (value < minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or >= .
+ ///
+ /// This API asserts the equivalent of " in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRange(ulong value, ulong minimum, ulong maximum, string name)
+ {
+ if (value < minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or < .
+ ///
+ /// This API asserts the equivalent of " not in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRange(ulong value, ulong minimum, ulong maximum, string name)
+ {
+ if (value >= minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= or >= .
+ ///
+ /// This API asserts the equivalent of " in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetween(ulong value, ulong minimum, ulong maximum, string name)
+ {
+ if (value <= minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > or < .
+ ///
+ /// This API asserts the equivalent of " not in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetween(ulong value, ulong minimum, ulong maximum, string name)
+ {
+ if (value > minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or > .
+ ///
+ /// This API asserts the equivalent of " in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetweenOrEqualTo(ulong value, ulong minimum, ulong maximum, string name)
+ {
+ if (value < minimum || value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or <= .
+ ///
+ /// This API asserts the equivalent of " not in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetweenOrEqualTo(ulong value, ulong minimum, ulong maximum, string name)
+ {
+ if (value >= minimum && value <= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEqualTo(double value, double target, string name)
+ {
+ if (value != target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be not equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is == .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEqualTo(double value, double target, string name)
+ {
+ if (value == target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThan(double value, double maximum, string name)
+ {
+ if (value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThanOrEqualTo(double value, double maximum, string name)
+ {
+ if (value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThan(double value, double minimum, string name)
+ {
+ if (value <= minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThanOrEqualTo(double value, double minimum, string name)
+ {
+ if (value < minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or >= .
+ ///
+ /// This API asserts the equivalent of " in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRange(double value, double minimum, double maximum, string name)
+ {
+ if (value < minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or < .
+ ///
+ /// This API asserts the equivalent of " not in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRange(double value, double minimum, double maximum, string name)
+ {
+ if (value >= minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= or >= .
+ ///
+ /// This API asserts the equivalent of " in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetween(double value, double minimum, double maximum, string name)
+ {
+ if (value <= minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > or < .
+ ///
+ /// This API asserts the equivalent of " not in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetween(double value, double minimum, double maximum, string name)
+ {
+ if (value > minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or > .
+ ///
+ /// This API asserts the equivalent of " in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetweenOrEqualTo(double value, double minimum, double maximum, string name)
+ {
+ if (value < minimum || value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or <= .
+ ///
+ /// This API asserts the equivalent of " not in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetweenOrEqualTo(double value, double minimum, double maximum, string name)
+ {
+ if (value >= minimum && value <= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEqualTo(decimal value, decimal target, string name)
+ {
+ if (value != target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be not equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is == .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEqualTo(decimal value, decimal target, string name)
+ {
+ if (value == target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThan(decimal value, decimal maximum, string name)
+ {
+ if (value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThanOrEqualTo(decimal value, decimal maximum, string name)
+ {
+ if (value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThan(decimal value, decimal minimum, string name)
+ {
+ if (value <= minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThanOrEqualTo(decimal value, decimal minimum, string name)
+ {
+ if (value < minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or >= .
+ ///
+ /// This API asserts the equivalent of " in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRange(decimal value, decimal minimum, decimal maximum, string name)
+ {
+ if (value < minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or < .
+ ///
+ /// This API asserts the equivalent of " not in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRange(decimal value, decimal minimum, decimal maximum, string name)
+ {
+ if (value >= minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= or >= .
+ ///
+ /// This API asserts the equivalent of " in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetween(decimal value, decimal minimum, decimal maximum, string name)
+ {
+ if (value <= minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > or < .
+ ///
+ /// This API asserts the equivalent of " not in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetween(decimal value, decimal minimum, decimal maximum, string name)
+ {
+ if (value > minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or > .
+ ///
+ /// This API asserts the equivalent of " in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetweenOrEqualTo(decimal value, decimal minimum, decimal maximum, string name)
+ {
+ if (value < minimum || value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or <= .
+ ///
+ /// This API asserts the equivalent of " not in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetweenOrEqualTo(decimal value, decimal minimum, decimal maximum, string name)
+ {
+ if (value >= minimum && value <= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+ }
+}
diff --git a/Microsoft.Toolkit/Diagnostics/Generated/Guard.Comparable.Numeric.tt b/Microsoft.Toolkit/Diagnostics/Generated/Guard.Comparable.Numeric.tt
new file mode 100644
index 00000000000..3cb7ee32093
--- /dev/null
+++ b/Microsoft.Toolkit/Diagnostics/Generated/Guard.Comparable.Numeric.tt
@@ -0,0 +1,255 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+<#@include file="TypeInfo.ttinclude" #>
+/* ========================
+ * Auto generated file
+ * ===================== */
+
+using System;
+using System.Runtime.CompilerServices;
+
+#nullable enable
+
+namespace Microsoft.Toolkit.Diagnostics
+{
+ ///
+ /// Helper methods to verify conditions when running code.
+ ///
+ public static partial class Guard
+ {
+<#
+GenerateTextForItems(NumericTypes, type =>
+{
+#>
+ ///
+ /// Asserts that the input value must be equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is != .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsEqualTo(<#=type#> value, <#=type#> target, string name)
+ {
+ if (value != target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be not equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The target value to test for.
+ /// The name of the input parameter being tested.
+ /// Thrown if is == .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotEqualTo(<#=type#> value, <#=type#> target, string name)
+ {
+ if (value == target)
+ {
+ ThrowHelper.ThrowArgumentExceptionForIsNotEqualTo(value, target, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThan(<#=type#> value, <#=type#> maximum, string name)
+ {
+ if (value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThan(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be less than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsLessThanOrEqualTo(<#=type#> value, <#=type#> maximum, string name)
+ {
+ if (value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(value, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than a specified value.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThan(<#=type#> value, <#=type#> minimum, string name)
+ {
+ if (value <= minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThan(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be greater than or equal to a specified value.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < .
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsGreaterThanOrEqualTo(<#=type#> value, <#=type#> minimum, string name)
+ {
+ if (value < minimum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(value, minimum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or >= .
+ ///
+ /// This API asserts the equivalent of " in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsInRange(<#=type#> value, <#=type#> minimum, <#=type#> maximum, string name)
+ {
+ if (value < minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given range.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or < .
+ ///
+ /// This API asserts the equivalent of " not in [, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotInRange(<#=type#> value, <#=type#> minimum, <#=type#> maximum, string name)
+ {
+ if (value >= minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRange(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is <= or >= .
+ ///
+ /// This API asserts the equivalent of " in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetween(<#=type#> value, <#=type#> minimum, <#=type#> maximum, string name)
+ {
+ if (value <= minimum || value >= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The exclusive minimum value that is accepted.
+ /// The exclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is > or < .
+ ///
+ /// This API asserts the equivalent of " not in (, )", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetween(<#=type#> value, <#=type#> minimum, <#=type#> maximum, string name)
+ {
+ if (value > minimum && value < maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetween(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is < or > .
+ ///
+ /// This API asserts the equivalent of " in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsBetweenOrEqualTo(<#=type#> value, <#=type#> minimum, <#=type#> maximum, string name)
+ {
+ if (value < minimum || value > maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+
+ ///
+ /// Asserts that the input value must not be in a given interval.
+ ///
+ /// The input value to test.
+ /// The inclusive minimum value that is accepted.
+ /// The inclusive maximum value that is accepted.
+ /// The name of the input parameter being tested.
+ /// Thrown if is >= or <= .
+ ///
+ /// This API asserts the equivalent of " not in [, ]", using arithmetic notation.
+ /// The method is generic to avoid boxing the parameters, if they are value types.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IsNotBetweenOrEqualTo(<#=type#> value, <#=type#> minimum, <#=type#> maximum, string name)
+ {
+ if (value >= minimum && value <= maximum)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
+ }
+ }
+<#
+});
+#>
+ }
+}
diff --git a/Microsoft.Toolkit/Diagnostics/Generated/Guard.md b/Microsoft.Toolkit/Diagnostics/Generated/Guard.md
new file mode 100644
index 00000000000..6b381a62b90
--- /dev/null
+++ b/Microsoft.Toolkit/Diagnostics/Generated/Guard.md
@@ -0,0 +1,17 @@
+# T4 templates and generated APIs
+
+This folder contains a number of template files (with the `.tt` or `.ttinclude` extensions) and the generated `.g.cs` files generated by those templates. The template files use the T4 format, which is natively supported by Visual Studio (more info is available [here](https://docs.microsoft.com/en-us/visualstudio/modeling/code-generation-and-t4-text-templates?view=vs-2019)).
+
+## Why is this needed?
+
+There are a few reasons why T4 templates are used for the `Guard` class:
+
+ - Especially when a large number of similar overloads are available for the same APIs, using templates makes it much easier to maintain code and spot mistakes, as the actual number of lines of code to review is much smaller: it's just the code in each template!
+ - Using type-specific overloads instead of generic methods can result in faster code. For instance, T4 templates are used to generate overloads for comparison APIs (eg. `Guard.IsGreaterThan(int, int, string)`). This results in more compact and optimized code as opposed to a generic method using `where T : IComparable` as type constraint.
+ - In some cases, using generic methods just isn't possible. For instance, types like `Span` and `ReadOnlySpan` can't be used as generic type parameters, and even if that had been possible, they don't implement an interface we could use in the generic type constraint. Using T4 templates solves this issue, as we can just have specialized method for each supported type or collection type.
+
+## How to make changes
+
+If you need to change an API that is declared in a template, or to add a new one, just edit the right `.tt` file and save it: Visual Studio will take care of updating the generated `.g.cs` file automatically. Don't make changes to those generated `.g.cs` files directly, as those will be overwritten as soon as their source template is updated.
+
+Note that all the `.g.cs` files are checked in into the repository, so if you do make changes to a template file, make sure to also include the updated `.g.cs` file in your commits.
diff --git a/Microsoft.Toolkit/Diagnostics/Generated/ThrowHelper.Collection.g.cs b/Microsoft.Toolkit/Diagnostics/Generated/ThrowHelper.Collection.g.cs
new file mode 100644
index 00000000000..e40c0d94fe5
--- /dev/null
+++ b/Microsoft.Toolkit/Diagnostics/Generated/ThrowHelper.Collection.g.cs
@@ -0,0 +1,817 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* ========================
+ * Auto generated file
+ * ===================== */
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.CompilerServices;
+using Microsoft.Toolkit.Extensions;
+
+#nullable enable
+
+namespace Microsoft.Toolkit.Diagnostics
+{
+ ///
+ /// Helper methods to throw exceptions
+ ///
+ [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1618", Justification = "Internal helper methods")]
+ internal static partial class ThrowHelper
+ {
+ ///
+ /// Throws an when (or an overload) fails.
+ ///
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void ThrowArgumentExceptionForIsEmpty(Span span, string name)
+ {
+ ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must be empty, had a size of {span.Length.ToAssertString()}");
+ }
+
+ ///
+ /// Throws an when (or an overload) fails.
+ ///
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void ThrowArgumentExceptionForHasSizeEqualTo(Span span, int size, string name)
+ {
+ ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must have a size equal to {size}, had a size of {span.Length.ToAssertString()}");
+ }
+
+ ///
+ /// Throws an when (or an overload) fails.
+ ///
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void ThrowArgumentExceptionForHasSizeNotEqualTo(Span span, int size, string name)
+ {
+ ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must have a size not equal to {size}, had a size of {span.Length.ToAssertString()}");
+ }
+
+ ///
+ /// Throws an when (or an overload) fails.
+ ///
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void ThrowArgumentExceptionForHasSizeOver(Span span, int size, string name)
+ {
+ ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must have a size over {size}, had a size of {span.Length.ToAssertString()}");
+ }
+
+ ///
+ /// Throws an when (or an overload) fails.
+ ///
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void ThrowArgumentExceptionForHasSizeAtLeast(Span span, int size, string name)
+ {
+ ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must have a size of at least {size}, had a size of {span.Length.ToAssertString()}");
+ }
+
+ ///
+ /// Throws an when (or an overload) fails.
+ ///
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void ThrowArgumentExceptionForHasSizeLessThan(Span span, int size, string name)
+ {
+ ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span