Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dailydevops/arguments
Provides a set of backward compatible `throw` helper methods, which have been added in previous .NET versions.
https://github.com/dailydevops/arguments
dotnet guard source-only
Last synced: about 2 months ago
JSON representation
Provides a set of backward compatible `throw` helper methods, which have been added in previous .NET versions.
- Host: GitHub
- URL: https://github.com/dailydevops/arguments
- Owner: dailydevops
- License: mit
- Created: 2023-08-28T15:04:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-22T07:04:10.000Z (9 months ago)
- Last Synced: 2024-05-22T11:01:28.036Z (9 months ago)
- Topics: dotnet, guard, source-only
- Language: C#
- Homepage:
- Size: 157 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# NetEvolve.Arguments
Provides a set of backward compatible argument `throw` helper methods added in the latest .NET versions.
Especially intended for projects with multiple `TargetFrameworks`, for usage, standardization and maintainability.## Method Overview
The following methods are currently provided.### `Argument.ThrowIfEqual(T, T, string?)`
Throws an `ArgumentOutOfRangeException` if the first argument is equal to the second argument. Inplace replacement for [`ArgumentOutOfRangeException.ThrowIfEqual(T, T, string)`](https://learn.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception.throwifequal), which was introduced with **.NET 8**.### `Argument.ThrowIfGreaterThan(T, T, string?)`
Throws an `ArgumentOutOfRangeException` if the first argument is greater than the second argument. Inplace replacement for [`ArgumentOutOfRangeException.ThrowIfGreaterThan(T, T, string)`](https://learn.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception.throwifgreaterthan), which was introduced with **.NET 8**.### `Argument.ThrowIfGreaterThanOrEqual(T, T, string?)`
Throws an `ArgumentOutOfRangeException` if the first argument is greater than or equal to the second argument. Inplace replacement for [`ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(T, T, string)`](https://learn.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception.throwifgreaterthanorequal), which was introduced with **.NET 8**.### `Argument.ThrowIfLessThan(T, T, string?)`
Throws an `ArgumentOutOfRangeException` if the first argument is less than the second argument. Inplace replacement for [`ArgumentOutOfRangeException.ThrowIfLessThan(T, T, string)`](https://learn.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception.throwiflessthan), which was introduced with **.NET 8**.### `Argument.ThrowIfLessThanOrEqual(T, T, string?)`
Throws an `ArgumentOutOfRangeException` if the first argument is less than or equal to the second argument. Inplace replacement for [`ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(T, T, string)`](https://learn.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception.throwiflessthanorequal), which was introduced with **.NET 8**.### `Argument.ThrowIfNotEqual(T, T, string?)`
Throws an `ArgumentOutOfRangeException` if the first argument is not equal to the second argument. Inplace replacement for [`ArgumentOutOfRangeException.ThrowIfNotEqual(T, T, string)`](https://learn.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception.throwifnotequal), which was introduced with **.NET 8**.### `Argument.ThrowIfNull(object?, string?)`
Throws an `ArgumentNullException` if the argument is `null`. Inplace replacement for [`ArgumentNullException.ThrowIfNull(object, string)`](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception.throwifnull), which was introduced with **.NET 6**.### `Argument.ThrowIfNull(void*, string?)`
Throws an `ArgumentNullException` if the argument is `null`. Inplace replacement for [`ArgumentNullException.ThrowIfNull(void*, string)`](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception.throwifnull?view=net-8.0#system-argumentnullexception-throwifnull(system-void*-system-string), which was introduced with **.NET 7**.### `Argument.ThrowIfNullOrEmpty(string?, string?)`
Throws an `ArgumentNullException` if the argument is `null` or throws an `ArgumentException` if the argument is empty. Inplace replacement for [`ArgumentException.ThrowIfNullOrEmpty(string, string)`](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception.throwifnullorempty), which was introduced with **.NET 7**.### `Argument.ThrowIfNullOrEmpty(IEnumerable?, string?)` (Individuall extension)
Throws an `ArgumentNullException` if the argument is `null` or throws an `ArgumentException` if the argument is empty.### `Argument.ThrowIfNullOrWhiteSpace(string?, string?)`
Throws an `ArgumentNullException` if the argument is `null` or throws an `ArgumentException` if the argument is empty or contains only white-space characters. Inplace replacement for [`ArgumentException.ThrowIfNullOrWhiteSpace(string, string)`](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception.throwifnullorwhitespace), which was introduced with **.NET 8**.