Skip to content

dailydevops/arguments

Repository files navigation

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, T, string?)

Throws an ArgumentOutOfRangeException if the first argument is equal to the second argument. Inplace replacement for ArgumentOutOfRangeException.ThrowIfEqual<T>(T, T, string), which was introduced with .NET 8.

Argument.ThrowIfGreaterThan<T>(T, T, string?)

Throws an ArgumentOutOfRangeException if the first argument is greater than the second argument. Inplace replacement for ArgumentOutOfRangeException.ThrowIfGreaterThan<T>(T, T, string), which was introduced with .NET 8.

Argument.ThrowIfGreaterThanOrEqual<T>(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, T, string), which was introduced with .NET 8.

Argument.ThrowIfLessThan<T>(T, T, string?)

Throws an ArgumentOutOfRangeException if the first argument is less than the second argument. Inplace replacement for ArgumentOutOfRangeException.ThrowIfLessThan<T>(T, T, string), which was introduced with .NET 8.

Argument.ThrowIfLessThanOrEqual<T>(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, T, string), which was introduced with .NET 8.

Argument.ThrowIfNotEqual<T>(T, T, string?)

Throws an ArgumentOutOfRangeException if the first argument is not equal to the second argument. Inplace replacement for ArgumentOutOfRangeException.ThrowIfNotEqual<T>(T, T, string), 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), 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), which was introduced with .NET 7.

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), which was introduced with .NET 8.

About

Provides a set of backward compatible `throw` helper methods, which have been added in previous .NET versions.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Contributors 4

  •  
  •  
  •  
  •