ArgumentAssert 1.0.0
See the version list below for details.
dotnet add package ArgumentAssert --version 1.0.0
NuGet\Install-Package ArgumentAssert -Version 1.0.0
<PackageReference Include="ArgumentAssert" Version="1.0.0" />
paket add ArgumentAssert --version 1.0.0
#r "nuget: ArgumentAssert, 1.0.0"
// 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
Overview
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();
}
License
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
http://www.apache.org/licenses/LICENSE-2.0
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 | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
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.