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
feat: Added additional Methods, for better support (#523)
* feat: Added additional Methods, for better support
* refactor(test): ArgumentExceptionPolyfills and expand tests
Simplified collection count and duplicate checks in ArgumentExceptionPolyfills. Improved default value comparison. Added comprehensive unit tests for null and empty collections across all overloads. Updated test for Guid default value. Suppressed IDE1006 warnings in test project.
* fix: Improve argument validation in ArgumentException polyfills and update README for .NET Framework support
Copy file name to clipboardExpand all lines: src/NetEvolve.Arguments/ArgumentOutOfRangeExceptionPolyfills.cs
+161Lines changed: 161 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -331,5 +331,166 @@ public static void ThrowIfLessThanOrEqual<T>(
331
331
}
332
332
}
333
333
#endif
334
+
335
+
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is outside the specified range [<paramref name="min"/>, <paramref name="max"/>].</summary>
336
+
/// <typeparam name="T">The type of the objects to compare.</typeparam>
337
+
/// <param name="value">The argument to validate as within the range.</param>
338
+
/// <param name="min">The minimum allowed value (inclusive).</param>
339
+
/// <param name="max">The maximum allowed value (inclusive).</param>
340
+
/// <param name="paramName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
341
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is outside the range [<paramref name="min"/>, <paramref name="max"/>].</exception>
$"Value must be between {min} and {max} (inclusive)."
356
+
);
357
+
}
358
+
}
359
+
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>
364
+
/// <param name="paramName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
365
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is in the past.</exception>
$"Value must not be in the past. Current time: {now}."
379
+
);
380
+
}
381
+
}
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>
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
+
/// <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>
$"Value must not be in the future. Current time: {now}."
401
+
);
402
+
}
403
+
}
404
+
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>
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
+
/// <param name="paramName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
409
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is in the past.</exception>
$"Value must not be in the past. Current time: {now}."
423
+
);
424
+
}
425
+
}
426
+
427
+
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is in the future relative to the current time.</summary>
428
+
/// <param name="value">The <see cref="DateTime"/> argument to validate as not in the future.</param>
429
+
/// <param name="timeProvider">The time provider to use for getting the current time. If <see langword="null"/>, <see cref="TimeProvider.System"/> is used.</param>
430
+
/// <param name="paramName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
431
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is in the future.</exception>
$"Value must not be in the future. Current time: {now}."
445
+
);
446
+
}
447
+
}
448
+
#endif
449
+
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>
454
+
/// <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>
$"Value must not be in the past. Current date: {today}."
469
+
);
470
+
}
471
+
}
472
+
473
+
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is in the future relative to the current date.</summary>
474
+
/// <param name="value">The <see cref="DateOnly"/> argument to validate as not in the future.</param>
475
+
/// <param name="timeProvider">The time provider to use for getting the current date. If <see langword="null"/>, <see cref="TimeProvider.System"/> is used.</param>
476
+
/// <param name="paramName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
477
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is in the future.</exception>
0 commit comments