ArgumentAssert 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ArgumentAssert --version 1.0.0
NuGet\Install-Package ArgumentAssert -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ArgumentAssert" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ArgumentAssert --version 1.0.0
#r "nuget: ArgumentAssert, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ArgumentAssert as a Cake Addin
#addin nuget:?package=ArgumentAssert&version=1.0.0

// Install ArgumentAssert as a Cake Tool
#tool nuget:?package=ArgumentAssert&version=1.0.0



ArgumentAssert is a library that simplifies asserting conditions on arguments. If the condition is not met, an ArgumentAssertException is thrown with a description of the failed check. In addition, the Assert() method informs code-analysis that the check must have been true if execution continues.

Add the following package reference to include ArgumentAssert package in your project.

<PackageReference Include="ArgumentAssert" Version="1.0.0" />

Sample: Assertion throws exception

The following code asserts the value argument is within the expected range or throws an ArgumentAssertException exception.

int AssertValueIsInRange(int value) {
    ArgumentAssertException.Assert(value is > 0 and < 10);
    return value;

When the assertion fails, the exception message shows the failed expression.

Unhandled exception. System.ArgumentAssertException: value is > 0 and < 10

Sample: Assertion informs code analysis

The following code asserts the value argument is not null. Code analysis knows that the pattern is true when Assert() returns successfully. Therefore, there is no warning for the return statement.

string AssertValueIsNotNull(string? value) {
    ArgumentAssertException.Assert(value is not null);

    // no warning on the following line
    return value.ToUpper();


Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 129 8/21/2023
1.0.0 254 2/15/2022