diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets
index e2c289c10..055a6803e 100644
--- a/src/Directory.Build.targets
+++ b/src/Directory.Build.targets
@@ -55,17 +55,34 @@
+
+
-
+
+
+
+
diff --git a/src/ImageSharp/Common/Helpers/Guard.Numeric.cs b/src/ImageSharp/Common/Helpers/Guard.Numeric.cs
new file mode 100644
index 000000000..72262e0b9
--- /dev/null
+++ b/src/ImageSharp/Common/Helpers/Guard.Numeric.cs
@@ -0,0 +1,1154 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using System;
+using System.Runtime.CompilerServices;
+
+namespace SixLabors
+{
+ ///
+ /// Provides methods to protect against invalid parameters.
+ ///
+ internal static partial class Guard
+ {
+ ///
+ /// Ensures that the specified value is less than a maximum value.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThan(byte value, byte max, string parameterName)
+ {
+ if (value >= max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is less than or equal to a maximum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThanOrEqualTo(byte value, byte max, string parameterName)
+ {
+ if (value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThan(byte value, byte min, string parameterName)
+ {
+ if (value <= min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThanOrEqualTo(byte value, byte min, string parameterName)
+ {
+ if (value < min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value and less than
+ /// or equal to a maximum value and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value of greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeBetweenOrEqualTo(byte value, byte min, byte max, string parameterName)
+ {
+ if (value < min || value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ }
+ }
+
+ ///
+ /// Ensures that the specified value is less than a maximum value.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThan(sbyte value, sbyte max, string parameterName)
+ {
+ if (value >= max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is less than or equal to a maximum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThanOrEqualTo(sbyte value, sbyte max, string parameterName)
+ {
+ if (value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThan(sbyte value, sbyte min, string parameterName)
+ {
+ if (value <= min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThanOrEqualTo(sbyte value, sbyte min, string parameterName)
+ {
+ if (value < min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value and less than
+ /// or equal to a maximum value and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value of greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeBetweenOrEqualTo(sbyte value, sbyte min, sbyte max, string parameterName)
+ {
+ if (value < min || value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ }
+ }
+
+ ///
+ /// Ensures that the specified value is less than a maximum value.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThan(short value, short max, string parameterName)
+ {
+ if (value >= max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is less than or equal to a maximum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThanOrEqualTo(short value, short max, string parameterName)
+ {
+ if (value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThan(short value, short min, string parameterName)
+ {
+ if (value <= min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThanOrEqualTo(short value, short min, string parameterName)
+ {
+ if (value < min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value and less than
+ /// or equal to a maximum value and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value of greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeBetweenOrEqualTo(short value, short min, short max, string parameterName)
+ {
+ if (value < min || value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ }
+ }
+
+ ///
+ /// Ensures that the specified value is less than a maximum value.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThan(ushort value, ushort max, string parameterName)
+ {
+ if (value >= max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is less than or equal to a maximum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThanOrEqualTo(ushort value, ushort max, string parameterName)
+ {
+ if (value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThan(ushort value, ushort min, string parameterName)
+ {
+ if (value <= min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThanOrEqualTo(ushort value, ushort min, string parameterName)
+ {
+ if (value < min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value and less than
+ /// or equal to a maximum value and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value of greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeBetweenOrEqualTo(ushort value, ushort min, ushort max, string parameterName)
+ {
+ if (value < min || value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ }
+ }
+
+ ///
+ /// Ensures that the specified value is less than a maximum value.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThan(char value, char max, string parameterName)
+ {
+ if (value >= max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is less than or equal to a maximum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThanOrEqualTo(char value, char max, string parameterName)
+ {
+ if (value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThan(char value, char min, string parameterName)
+ {
+ if (value <= min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThanOrEqualTo(char value, char min, string parameterName)
+ {
+ if (value < min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value and less than
+ /// or equal to a maximum value and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value of greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeBetweenOrEqualTo(char value, char min, char max, string parameterName)
+ {
+ if (value < min || value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ }
+ }
+
+ ///
+ /// Ensures that the specified value is less than a maximum value.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThan(int value, int max, string parameterName)
+ {
+ if (value >= max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is less than or equal to a maximum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThanOrEqualTo(int value, int max, string parameterName)
+ {
+ if (value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThan(int value, int min, string parameterName)
+ {
+ if (value <= min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThanOrEqualTo(int value, int min, string parameterName)
+ {
+ if (value < min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value and less than
+ /// or equal to a maximum value and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value of greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeBetweenOrEqualTo(int value, int min, int max, string parameterName)
+ {
+ if (value < min || value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ }
+ }
+
+ ///
+ /// Ensures that the specified value is less than a maximum value.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThan(uint value, uint max, string parameterName)
+ {
+ if (value >= max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is less than or equal to a maximum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThanOrEqualTo(uint value, uint max, string parameterName)
+ {
+ if (value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThan(uint value, uint min, string parameterName)
+ {
+ if (value <= min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThanOrEqualTo(uint value, uint min, string parameterName)
+ {
+ if (value < min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value and less than
+ /// or equal to a maximum value and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value of greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeBetweenOrEqualTo(uint value, uint min, uint max, string parameterName)
+ {
+ if (value < min || value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ }
+ }
+
+ ///
+ /// Ensures that the specified value is less than a maximum value.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThan(float value, float max, string parameterName)
+ {
+ if (value >= max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is less than or equal to a maximum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThanOrEqualTo(float value, float max, string parameterName)
+ {
+ if (value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThan(float value, float min, string parameterName)
+ {
+ if (value <= min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThanOrEqualTo(float value, float min, string parameterName)
+ {
+ if (value < min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value and less than
+ /// or equal to a maximum value and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value of greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeBetweenOrEqualTo(float value, float min, float max, string parameterName)
+ {
+ if (value < min || value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ }
+ }
+
+ ///
+ /// Ensures that the specified value is less than a maximum value.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThan(long value, long max, string parameterName)
+ {
+ if (value >= max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is less than or equal to a maximum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThanOrEqualTo(long value, long max, string parameterName)
+ {
+ if (value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThan(long value, long min, string parameterName)
+ {
+ if (value <= min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThanOrEqualTo(long value, long min, string parameterName)
+ {
+ if (value < min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value and less than
+ /// or equal to a maximum value and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value of greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeBetweenOrEqualTo(long value, long min, long max, string parameterName)
+ {
+ if (value < min || value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ }
+ }
+
+ ///
+ /// Ensures that the specified value is less than a maximum value.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThan(ulong value, ulong max, string parameterName)
+ {
+ if (value >= max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is less than or equal to a maximum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThanOrEqualTo(ulong value, ulong max, string parameterName)
+ {
+ if (value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThan(ulong value, ulong min, string parameterName)
+ {
+ if (value <= min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThanOrEqualTo(ulong value, ulong min, string parameterName)
+ {
+ if (value < min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value and less than
+ /// or equal to a maximum value and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value of greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeBetweenOrEqualTo(ulong value, ulong min, ulong max, string parameterName)
+ {
+ if (value < min || value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ }
+ }
+
+ ///
+ /// Ensures that the specified value is less than a maximum value.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThan(double value, double max, string parameterName)
+ {
+ if (value >= max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is less than or equal to a maximum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThanOrEqualTo(double value, double max, string parameterName)
+ {
+ if (value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThan(double value, double min, string parameterName)
+ {
+ if (value <= min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThanOrEqualTo(double value, double min, string parameterName)
+ {
+ if (value < min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value and less than
+ /// or equal to a maximum value and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value of greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeBetweenOrEqualTo(double value, double min, double max, string parameterName)
+ {
+ if (value < min || value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ }
+ }
+
+ ///
+ /// Ensures that the specified value is less than a maximum value.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThan(decimal value, decimal max, string parameterName)
+ {
+ if (value >= max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is less than or equal to a maximum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeLessThanOrEqualTo(decimal value, decimal max, string parameterName)
+ {
+ if (value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThan(decimal value, decimal min, string parameterName)
+ {
+ if (value <= min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value
+ /// and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeGreaterThanOrEqualTo(decimal value, decimal min, string parameterName)
+ {
+ if (value < min)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ }
+ }
+
+ ///
+ /// Verifies that the specified value is greater than or equal to a minimum value and less than
+ /// or equal to a maximum value and throws an exception if it is not.
+ ///
+ /// The target value, which should be validated.
+ /// The minimum value.
+ /// The maximum value.
+ /// The name of the parameter that is to be checked.
+ ///
+ /// is less than the minimum value of greater than the maximum value.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void MustBeBetweenOrEqualTo(decimal value, decimal min, decimal max, string parameterName)
+ {
+ if (value < min || value > max)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ }
+ }
+ }
+}
diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj
index 7872bb5c5..24d4f4a00 100644
--- a/src/ImageSharp/ImageSharp.csproj
+++ b/src/ImageSharp/ImageSharp.csproj
@@ -37,11 +37,16 @@
+
True
True
Guard.Numeric.tt
-
+
+
True
True
@@ -209,6 +214,7 @@
Guard.Numeric.cs
+ TextTemplatingFileGenerator