Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/NetEvolve.Arguments/Argument_ThrowArgumentException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#if !NET8_0_OR_GREATER
namespace NetEvolve.Arguments;

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

public static partial class Argument
{
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/>.</summary>
[DoesNotReturn]
[MethodImpl(MethodImplOptions.NoInlining)]
[StackTraceHidden]
private static void ThrowArgumentException(string? paramName)
{
throw new ArgumentException(null, paramName);
}
}
#endif
20 changes: 20 additions & 0 deletions src/NetEvolve.Arguments/Argument_ThrowArgumentNullException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#if !NET8_0_OR_GREATER
namespace NetEvolve.Arguments;

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

public static partial class Argument
{
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/>.</summary>
[DoesNotReturn]
[MethodImpl(MethodImplOptions.NoInlining)]
[StackTraceHidden]
private static void ThrowArgumentNullException(string? paramName)
{
throw new ArgumentNullException(paramName);
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#if !NET8_0_OR_GREATER
namespace NetEvolve.Arguments;

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

public static partial class Argument
{
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/>.</summary>
[DoesNotReturn]
[MethodImpl(MethodImplOptions.NoInlining)]
[StackTraceHidden]
private static void ThrowArgumentOutOfRangeException<T>(string? paramName, T value)
where T : IComparable<T>
{
throw new ArgumentOutOfRangeException(paramName, value, null);
}
}
#endif
3 changes: 2 additions & 1 deletion src/NetEvolve.Arguments/Argument_ThrowIfGreaterThan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

public static partial class Argument
Expand All @@ -25,7 +26,7 @@ public static void ThrowIfGreaterThan<T>(
#else
if (value.CompareTo(other) > 0)
{
throw new ArgumentOutOfRangeException(paramName, value, null);
ThrowArgumentOutOfRangeException(paramName, value);
}
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void ThrowIfGreaterThanOrEqual<T>(
#else
if (value.CompareTo(other) >= 0)
{
throw new ArgumentOutOfRangeException(paramName, value, null);
ThrowArgumentOutOfRangeException(paramName, value);
}
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/NetEvolve.Arguments/Argument_ThrowIfLessThan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void ThrowIfLessThan<T>(
#else
if (value.CompareTo(other) < 0)
{
throw new ArgumentOutOfRangeException(paramName, value, null);
ThrowArgumentOutOfRangeException(paramName, value);
}
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/NetEvolve.Arguments/Argument_ThrowIfLessThanOrEqual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void ThrowIfLessThanOrEqual<T>(
#else
if (value.CompareTo(other) <= 0)
{
throw new ArgumentOutOfRangeException(paramName, value, null);
ThrowArgumentOutOfRangeException(paramName, value);
}
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/NetEvolve.Arguments/Argument_ThrowIfNull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void ThrowIfNull(
#else
if (argument is null)
{
throw new ArgumentNullException(paramName);
ThrowArgumentNullException(paramName);
}
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions src/NetEvolve.Arguments/Argument_ThrowIfNullOrEmpty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public static void ThrowIfNullOrEmpty(
#else
if (argument is null)
{
throw new ArgumentNullException(paramName);
ThrowArgumentNullException(paramName);
}

if (string.IsNullOrEmpty(argument))
{
throw new ArgumentException(null, paramName);
ThrowArgumentException(paramName);
}
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions src/NetEvolve.Arguments/Argument_ThrowIfNullOrWhiteSpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public static void ThrowIfNullOrWhiteSpace(
#else
if (argument is null)
{
throw new ArgumentNullException(paramName);
ThrowArgumentNullException(paramName);
}

if (string.IsNullOrWhiteSpace(argument))
{
throw new ArgumentException(null, paramName);
ThrowArgumentException(paramName);
}
#endif
}
Expand Down