Added FisheryLib.Collections.FishTable and Mono.Cecil extension methods
A bit of refactoring has been done too
This commit is contained in:
@@ -10,19 +10,19 @@ namespace PerformanceFish.Utility.Diagnostics;
|
||||
partial class Guard
|
||||
{
|
||||
<#
|
||||
GenerateTextForItems(NumericTypes, typeInfo =>
|
||||
{
|
||||
var (type, prefix) = typeInfo;
|
||||
GenerateTextForItems(NumericTypes, typeInfo =>
|
||||
{
|
||||
var (type, prefix) = typeInfo;
|
||||
#>
|
||||
/// <summary>
|
||||
/// Asserts that the input value must be equal to a specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
|
||||
/// <param name="target">The target <see <#=prefix#>="<#=type#>"/> value to test for.</param>
|
||||
/// <param name="value">The input <see <#= prefix #>="<#= type #>"/> value to test.</param>
|
||||
/// <param name="target">The target <see <#= prefix #>="<#= type #>"/> value to test for.</param>
|
||||
/// <param name="name">The name of the input parameter being tested.</param>
|
||||
/// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is != <paramref name="target"/>.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void IsEqualTo(<#=type#> value, <#=type#> target, [CallerArgumentExpression("value")] string name = "")
|
||||
public static void IsEqualTo(<#= type #> value, <#= type #> target, [CallerArgumentExpression("value")] string name = "")
|
||||
{
|
||||
if (value == target)
|
||||
{
|
||||
@@ -35,13 +35,13 @@ var (type, prefix) = typeInfo;
|
||||
/// <summary>
|
||||
/// Asserts that the input value must be not equal to a specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
|
||||
/// <param name="target">The target <see <#=prefix#>="<#=type#>"/> value to test for.</param>
|
||||
/// <param name="value">The input <see <#= prefix #>="<#= type #>"/> value to test.</param>
|
||||
/// <param name="target">The target <see <#= prefix #>="<#= type #>"/> value to test for.</param>
|
||||
/// <param name="name">The name of the input parameter being tested.</param>
|
||||
/// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception>
|
||||
/// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void IsNotEqualTo(<#=type#> value, <#=type#> target, [CallerArgumentExpression("value")] string name = "")
|
||||
public static void IsNotEqualTo(<#= type #> value, <#= type #> target, [CallerArgumentExpression("value")] string name = "")
|
||||
{
|
||||
if (value != target)
|
||||
{
|
||||
@@ -54,13 +54,13 @@ var (type, prefix) = typeInfo;
|
||||
/// <summary>
|
||||
/// Asserts that the input value must be less than a specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
|
||||
/// <param name="maximum">The exclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="value">The input <see <#= prefix #>="<#= type #>"/> value to test.</param>
|
||||
/// <param name="maximum">The exclusive maximum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="name">The name of the input parameter being tested.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception>
|
||||
/// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void IsLessThan(<#=type#> value, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
public static void IsLessThan(<#= type #> value, <#= type #> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
{
|
||||
if (value < maximum)
|
||||
{
|
||||
@@ -73,13 +73,13 @@ var (type, prefix) = typeInfo;
|
||||
/// <summary>
|
||||
/// Asserts that the input value must be less than or equal to a specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
|
||||
/// <param name="maximum">The inclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="value">The input <see <#= prefix #>="<#= type #>"/> value to test.</param>
|
||||
/// <param name="maximum">The inclusive maximum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="name">The name of the input parameter being tested.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception>
|
||||
/// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void IsLessThanOrEqualTo(<#=type#> value, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
public static void IsLessThanOrEqualTo(<#= type #> value, <#= type #> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
{
|
||||
if (value <= maximum)
|
||||
{
|
||||
@@ -92,13 +92,13 @@ var (type, prefix) = typeInfo;
|
||||
/// <summary>
|
||||
/// Asserts that the input value must be greater than a specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
|
||||
/// <param name="minimum">The exclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="value">The input <see <#= prefix #>="<#= type #>"/> value to test.</param>
|
||||
/// <param name="minimum">The exclusive minimum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="name">The name of the input parameter being tested.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is <= <paramref name="minimum"/>.</exception>
|
||||
/// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void IsGreaterThan(<#=type#> value, <#=type#> minimum, [CallerArgumentExpression("value")] string name = "")
|
||||
public static void IsGreaterThan(<#= type #> value, <#= type #> minimum, [CallerArgumentExpression("value")] string name = "")
|
||||
{
|
||||
if (value > minimum)
|
||||
{
|
||||
@@ -111,13 +111,13 @@ var (type, prefix) = typeInfo;
|
||||
/// <summary>
|
||||
/// Asserts that the input value must be greater than or equal to a specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
|
||||
/// <param name="minimum">The inclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="value">The input <see <#= prefix #>="<#= type #>"/> value to test.</param>
|
||||
/// <param name="minimum">The inclusive minimum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="name">The name of the input parameter being tested.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is < <paramref name="minimum"/>.</exception>
|
||||
/// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void IsGreaterThanOrEqualTo(<#=type#> value, <#=type#> minimum, [CallerArgumentExpression("value")] string name = "")
|
||||
public static void IsGreaterThanOrEqualTo(<#= type #> value, <#= type #> minimum, [CallerArgumentExpression("value")] string name = "")
|
||||
{
|
||||
if (value >= minimum)
|
||||
{
|
||||
@@ -130,9 +130,9 @@ var (type, prefix) = typeInfo;
|
||||
/// <summary>
|
||||
/// Asserts that the input value must be in a given range.
|
||||
/// </summary>
|
||||
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
|
||||
/// <param name="minimum">The inclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="maximum">The exclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="value">The input <see <#= prefix #>="<#= type #>"/> value to test.</param>
|
||||
/// <param name="minimum">The inclusive minimum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="maximum">The exclusive maximum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="name">The name of the input parameter being tested.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is < <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception>
|
||||
/// <remarks>
|
||||
@@ -140,7 +140,7 @@ var (type, prefix) = typeInfo;
|
||||
/// The method is generic to avoid boxing the parameters, if they are value types.
|
||||
/// </remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void IsInRange(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
public static void IsInRange(<#= type #> value, <#= type #> minimum, <#= type #> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
{
|
||||
if (value >= minimum && value < maximum)
|
||||
{
|
||||
@@ -153,9 +153,9 @@ var (type, prefix) = typeInfo;
|
||||
/// <summary>
|
||||
/// Asserts that the input value must not be in a given range.
|
||||
/// </summary>
|
||||
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
|
||||
/// <param name="minimum">The inclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="maximum">The exclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="value">The input <see <#= prefix #>="<#= type #>"/> value to test.</param>
|
||||
/// <param name="minimum">The inclusive minimum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="maximum">The exclusive maximum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="name">The name of the input parameter being tested.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or < <paramref name="maximum"/>.</exception>
|
||||
/// <remarks>
|
||||
@@ -163,7 +163,7 @@ var (type, prefix) = typeInfo;
|
||||
/// The method is generic to avoid boxing the parameters, if they are value types.
|
||||
/// </remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void IsNotInRange(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
public static void IsNotInRange(<#= type #> value, <#= type #> minimum, <#= type #> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
{
|
||||
if (value < minimum || value >= maximum)
|
||||
{
|
||||
@@ -176,9 +176,9 @@ var (type, prefix) = typeInfo;
|
||||
/// <summary>
|
||||
/// Asserts that the input value must be in a given interval.
|
||||
/// </summary>
|
||||
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
|
||||
/// <param name="minimum">The exclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="maximum">The exclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="value">The input <see <#= prefix #>="<#= type #>"/> value to test.</param>
|
||||
/// <param name="minimum">The exclusive minimum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="maximum">The exclusive maximum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="name">The name of the input parameter being tested.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is <= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception>
|
||||
/// <remarks>
|
||||
@@ -186,7 +186,7 @@ var (type, prefix) = typeInfo;
|
||||
/// The method is generic to avoid boxing the parameters, if they are value types.
|
||||
/// </remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void IsBetween(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
public static void IsBetween(<#= type #> value, <#= type #> minimum, <#= type #> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
{
|
||||
if (value > minimum && value < maximum)
|
||||
{
|
||||
@@ -199,9 +199,9 @@ var (type, prefix) = typeInfo;
|
||||
/// <summary>
|
||||
/// Asserts that the input value must not be in a given interval.
|
||||
/// </summary>
|
||||
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
|
||||
/// <param name="minimum">The exclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="maximum">The exclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="value">The input <see <#= prefix #>="<#= type #>"/> value to test.</param>
|
||||
/// <param name="minimum">The exclusive minimum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="maximum">The exclusive maximum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="name">The name of the input parameter being tested.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or < <paramref name="maximum"/>.</exception>
|
||||
/// <remarks>
|
||||
@@ -209,7 +209,7 @@ var (type, prefix) = typeInfo;
|
||||
/// The method is generic to avoid boxing the parameters, if they are value types.
|
||||
/// </remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void IsNotBetween(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
public static void IsNotBetween(<#= type #> value, <#= type #> minimum, <#= type #> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
{
|
||||
if (value <= minimum || value >= maximum)
|
||||
{
|
||||
@@ -222,9 +222,9 @@ var (type, prefix) = typeInfo;
|
||||
/// <summary>
|
||||
/// Asserts that the input value must be in a given interval.
|
||||
/// </summary>
|
||||
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
|
||||
/// <param name="minimum">The inclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="maximum">The inclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="value">The input <see <#= prefix #>="<#= type #>"/> value to test.</param>
|
||||
/// <param name="minimum">The inclusive minimum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="maximum">The inclusive maximum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="name">The name of the input parameter being tested.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is < <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception>
|
||||
/// <remarks>
|
||||
@@ -232,7 +232,7 @@ var (type, prefix) = typeInfo;
|
||||
/// The method is generic to avoid boxing the parameters, if they are value types.
|
||||
/// </remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void IsBetweenOrEqualTo(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
public static void IsBetweenOrEqualTo(<#= type #> value, <#= type #> minimum, <#= type #> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
{
|
||||
if (value >= minimum && value <= maximum)
|
||||
{
|
||||
@@ -245,9 +245,9 @@ var (type, prefix) = typeInfo;
|
||||
/// <summary>
|
||||
/// Asserts that the input value must not be in a given interval.
|
||||
/// </summary>
|
||||
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
|
||||
/// <param name="minimum">The inclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="maximum">The inclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
|
||||
/// <param name="value">The input <see <#= prefix #>="<#= type #>"/> value to test.</param>
|
||||
/// <param name="minimum">The inclusive minimum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="maximum">The inclusive maximum <see <#= prefix #>="<#= type #>"/> value that is accepted.</param>
|
||||
/// <param name="name">The name of the input parameter being tested.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or <= <paramref name="maximum"/>.</exception>
|
||||
/// <remarks>
|
||||
@@ -255,7 +255,7 @@ var (type, prefix) = typeInfo;
|
||||
/// The method is generic to avoid boxing the parameters, if they are value types.
|
||||
/// </remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void IsNotBetweenOrEqualTo(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
public static void IsNotBetweenOrEqualTo(<#= type #> value, <#= type #> minimum, <#= type #> maximum, [CallerArgumentExpression("value")] string name = "")
|
||||
{
|
||||
if (value < minimum || value > maximum)
|
||||
{
|
||||
@@ -265,6 +265,6 @@ var (type, prefix) = typeInfo;
|
||||
ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(value, minimum, maximum, name);
|
||||
}
|
||||
<#
|
||||
});
|
||||
});
|
||||
#>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user