Argument.Check
3.0.1
See the version list below for details.
dotnet add package Argument.Check --version 3.0.1
NuGet\Install-Package Argument.Check -Version 3.0.1
<PackageReference Include="Argument.Check" Version="3.0.1" />
paket add Argument.Check --version 3.0.1
#r "nuget: Argument.Check, 3.0.1"
// Install Argument.Check as a Cake Addin #addin nuget:?package=Argument.Check&version=3.0.1 // Install Argument.Check as a Cake Tool #tool nuget:?package=Argument.Check&version=3.0.1
Argument.Check
Argument.Check is a very simple library which makes it very easy to check your arguments or variables for different conditions like 'Null'. It is super fast it is using the new [CallerMemberNameAttribute]
Getting started
Prerequisites
Install the package
dotnet add package Argument.Check
Samples
Each Throw helper could also be used like a "Throw Expression".
Null check
public MyClass(object arg)
{
Throw.IfNull(arg);
}
Null check, like 'Throw Expressions'
public MyClass(IService service)
{
_service = Throw.IfNull(service);
}
Null check on a stack variable
public MyClass(IService service)
{
Throw.IfNull(service);
var result = service.GetSomething();
Throw.IfNull(result);
}
File exists
public MyClass(FileInfo fileInfo)
{
Throw.IfExists(fileInfo);
}
Directory exists
public MyClass(DirectoryInfo directoryInfo)
{
Throw.IfExists(directoryInfo);
}
Value is greater than
public MyClass(int value)
{
Throw.IfGreaterThan(value, 10);
}
Value is less than
public MyClass(int value)
{
Throw.IfLessThan(value, 10);
}
Value is out of range
public MyClass(int value)
{
Throw.IfOutOfRange(value, 10, 100);
}
Custom expression
public MyClass(string value)
{
Throw.If(value, v => v.Length > 10 && v.Contains("abc"), "The given string length must not be longer than 10, and must not contain 'abc'");
}
Argument must be an interface
public MyClass(object value)
{
Throw.IfNotInterface(value);
}
Argument must be equal to any expectation
public MyClass(object value)
{
Throw.IfNotEqualsTo(value, new object());
}
And many more.
public MyClass(object value)
{
Throw.If(...)
Throw.IfNot(...)
Throw.IfNull(...)
Throw.IfEmpty(...)
Throw.IfNotEmpty(...)
Throw.IfTypeIs(...)
Throw.IfTypeIsNot(...)
Throw.IfEqualsTo(...)
Throw.IfNotEqualsTo(...)
Throw.IfExists(...)
Throw.IfNotExists(...)
Throw.IfGreaterOrEqual(...)
Throw.IfGreaterThan(...)
Throw.IfLessOrEqual(...)
Throw.IfLessThan(...)
Throw.IfInterface(...)
Throw.IfNotInterface(...)
Throw.IfLengthIs(...)
Throw.IfLengthIsNot(...)
Throw.IfContains(...)
Throw.IfNotContains(...)
Throw.IfNullOrAny(...)
Throw.IfNullOrAnyItemIsNull(...)
Throw.IfNullOrEmpty(...)
Throw.IfNullOrWhiteSpace(...)
Throw.IfOutOfRange(...)
Throw.IfWhitespace(...)
Throw.IfAnyItemIsNullOrWhitespace(...)
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Argument.Check:
Package | Downloads |
---|---|
Extensions.Pack
A set of useful extensions to make your code smooth and nice readable. |
|
CSharp.Parser.Abstraction
A simple abstraction to parse C# files. Target should be a human friendly readable result. But it is just based on the syntax tree. You don't get any semantic informations. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.0.1 | 113 | 9/6/2024 |
4.0.0 | 26,564 | 11/28/2023 |
3.0.1 | 25,420 | 5/29/2023 |
3.0.0 | 84 | 5/29/2023 |
2.0.0 | 19,121 | 7/25/2022 |
2.0.0-alpha.59 | 399 | 7/3/2022 |
2.0.0-alpha.58 | 142 | 7/3/2022 |
2.0.0-alpha.52 | 7,633 | 10/19/2021 |
1.0.4 | 224,482 | 1/19/2020 |
1.0.3 | 1,070 | 1/18/2020 |
1.0.2 | 1,082 | 1/18/2020 |
1.0.1 | 26,895 | 1/3/2020 |
1.0.0 | 518 | 1/3/2020 |
0.9.0 | 5,725 | 12/26/2019 |
Changes:
- Upgrade to Net7
- Remove obsolete argument checks based on Func<T>