Skip to content

Commit

Permalink
use ArgumentException.ThrowIfNullOrWhiteSpace
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Nov 13, 2024
1 parent 7adb11b commit 810c8d0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Polyfill/Guard_NotNullOrWhiteSpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public static string NotNullOrWhiteSpace(
[NotNull] string? value,
[CallerArgumentExpression("value")] string argumentName = "")
{
#if NET8_0_OR_GREATER
ArgumentException.ThrowIfNullOrWhiteSpace(value, argumentName);
return value;
#else
if (value == null)
{
throw new ArgumentNullException(argumentName);
Expand All @@ -38,6 +42,7 @@ public static string NotNullOrWhiteSpace(
}

throw new ArgumentException("Argument cannot be whitespace.", argumentName);
#endif
}

#if FeatureMemory
Expand Down

0 comments on commit 810c8d0

Please sign in to comment.