You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(deps): update dependency sonaranalyzer.csharp to 10.25.0.139117 (#664)
* chore(deps): update dependency sonaranalyzer.csharp to 10.25.0.139117
* refactor: Refactor argument validation polyfills for .NET 8+
Reorganize and update ThrowIfInPast/ThrowIfInFuture overloads for DateOnly, DateTime, and DateTimeOffset. Move ThrowIfNullOrWhiteSpace under !NET8_0_OR_GREATER. Update XML docs to match new signatures and behaviors.
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Martin Stühmer <me@samtrion.net>
Copy file name to clipboardExpand all lines: src/NetEvolve.Arguments/ArgumentExceptionPolyfill.cs
+27-25Lines changed: 27 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -34,31 +34,6 @@ public static void ThrowIfNullOrEmpty(
34
34
thrownewArgumentException("The value cannot be an empty string.",paramName);
35
35
}
36
36
}
37
-
38
-
/// <summary>Throws an exception if <paramref name="argument"/> is <see langword="null"/>, empty, or consists only of white-space characters.</summary>
39
-
/// <param name="argument">The string argument to validate.</param>
40
-
/// <param name="paramName">The name of the parameter with which <paramref name="argument"/> corresponds.</param>
41
-
/// <exception cref="ArgumentNullException"><paramref name="argument"/> is <see langword="null"/>.</exception>
42
-
/// <exception cref="ArgumentException"><paramref name="argument"/> is empty or consists only of white-space characters.</exception>
"The value cannot be an empty string or composed entirely of whitespace.",
58
-
paramName
59
-
);
60
-
}
61
-
}
62
37
#endif
63
38
64
39
/// <summary>Throws an exception if <paramref name="argument"/> is <see langword="null"/> or empty.</summary>
@@ -149,6 +124,33 @@ public static void ThrowIfNullOrEmpty<T>(
149
124
}
150
125
}
151
126
127
+
#if !NET8_0_OR_GREATER
128
+
/// <summary>Throws an exception if <paramref name="argument"/> is <see langword="null"/>, empty, or consists only of white-space characters.</summary>
129
+
/// <param name="argument">The string argument to validate.</param>
130
+
/// <param name="paramName">The name of the parameter with which <paramref name="argument"/> corresponds.</param>
131
+
/// <exception cref="ArgumentNullException"><paramref name="argument"/> is <see langword="null"/>.</exception>
132
+
/// <exception cref="ArgumentException"><paramref name="argument"/> is empty or consists only of white-space characters.</exception>
Copy file name to clipboardExpand all lines: src/NetEvolve.Arguments/ArgumentOutOfRangeExceptionPolyfills.cs
+27-29Lines changed: 27 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -358,62 +358,62 @@ public static void ThrowIfOutOfRange<T>(
358
358
}
359
359
360
360
#if NET8_0_OR_GREATER
361
-
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is in the past relative to the current time.</summary>
362
-
/// <param name="value">The <see cref="DateTimeOffset"/> argument to validate as not in the past.</param>
363
-
/// <param name="timeProvider">The time provider to use for getting the current time. If <see langword="null"/>, <see cref="TimeProvider.System"/> is used.</param>
361
+
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is in the past relative to the current date.</summary>
362
+
/// <param name="value">The <see cref="DateOnly"/> argument to validate as not in the past.</param>
363
+
/// <param name="timeProvider">The time provider to use for getting the current date. If <see langword="null"/>, <see cref="TimeProvider.System"/> is used.</param>
364
364
/// <param name="paramName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
365
365
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is in the past.</exception>
$"Value must not be in the past. Current time: {now}."
378
+
$"Value must not be in the past. Current date: {today}."
379
379
);
380
380
}
381
381
}
382
382
383
-
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is in the future relative to the current time.</summary>
384
-
/// <param name="value">The <see cref="DateTimeOffset"/> argument to validate as not in the future.</param>
383
+
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is in the past relative to the current time.</summary>
384
+
/// <param name="value">The <see cref="DateTime"/> argument to validate as not in the past.</param>
385
385
/// <param name="timeProvider">The time provider to use for getting the current time. If <see langword="null"/>, <see cref="TimeProvider.System"/> is used.</param>
386
386
/// <param name="paramName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
387
-
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is in the future.</exception>
388
-
publicstaticvoidThrowIfInFuture(
389
-
DateTimeOffsetvalue,
387
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is in the past.</exception>
$"Value must not be in the future. Current time: {now}."
400
+
$"Value must not be in the past. Current time: {now}."
401
401
);
402
402
}
403
403
}
404
404
405
405
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is in the past relative to the current time.</summary>
406
-
/// <param name="value">The <see cref="DateTime"/> argument to validate as not in the past.</param>
406
+
/// <param name="value">The <see cref="DateTimeOffset"/> argument to validate as not in the past.</param>
407
407
/// <param name="timeProvider">The time provider to use for getting the current time. If <see langword="null"/>, <see cref="TimeProvider.System"/> is used.</param>
408
408
/// <param name="paramName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
409
409
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is in the past.</exception>
@@ -445,27 +445,25 @@ public static void ThrowIfInFuture(
445
445
);
446
446
}
447
447
}
448
-
#endif
449
448
450
-
#if NET8_0_OR_GREATER
451
-
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is in the past relative to the current date.</summary>
452
-
/// <param name="value">The <see cref="DateOnly"/> argument to validate as not in the past.</param>
453
-
/// <param name="timeProvider">The time provider to use for getting the current date. If <see langword="null"/>, <see cref="TimeProvider.System"/> is used.</param>
449
+
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is in the future relative to the current time.</summary>
450
+
/// <param name="value">The <see cref="DateTimeOffset"/> argument to validate as not in the future.</param>
451
+
/// <param name="timeProvider">The time provider to use for getting the current time. If <see langword="null"/>, <see cref="TimeProvider.System"/> is used.</param>
454
452
/// <param name="paramName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
455
-
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is in the past.</exception>
456
-
publicstaticvoidThrowIfInPast(
457
-
DateOnlyvalue,
453
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is in the future.</exception>
0 commit comments