ThrowIfArgument 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ThrowIfArgument --version 1.0.0
NuGet\Install-Package ThrowIfArgument -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="ThrowIfArgument" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ThrowIfArgument --version 1.0.0
#r "nuget: ThrowIfArgument, 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 ThrowIfArgument as a Cake Addin
#addin nuget:?package=ThrowIfArgument&version=1.0.0

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


NuGet Status NuGet

This is just another guard clause library for validating your arguments, but I enjoy the way using this API reads quite fluently. If you're like me, then you've been recreating a library of guard clauses from company to company. I finally got tired and uploaded my own version of a guard clause library.

NuGet Installation

Install the ThrowIfArgument NuGet package:

dotnet add package ThrowIfArgument


public void HelloWorld(FooBar fooBar)
    Console.WriteLine($"The narwhal bacons at {fooBar.BaconsAt}");


If you feel the package is missing a feature, you can extend with your own features:

public static ThrowIfArgumentExtensions
    public static string StartsWithThunderclap
        this IThrowIfArgumentBuilder,
        string argument,
        string? message = null,
        [CallerArgumentExpression("argument")] string? argumentName = null
        if (!argument.StartsWith("thunderclap", StringComparison.OrdinalIgnoreCase))
            return argument;
        throw new ArgumentException(
                ? $"Cannot start with 'thunderclap'."
                : message,

Ping me if you want any new features added to the library ❤️

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 (1)

Showing the top 1 NuGet packages that depend on ThrowIfArgument:

Package Downloads

Easily add dependencies to your dependency injection container with attributes. This includes services, options, and HTTP clients.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 14,557 12/9/2022
1.0.2 830 12/7/2022
1.0.1 290 12/7/2022
1.0.0 288 12/6/2022
0.0.0-alpha04 90 12/6/2022
0.0.0-alpha03 126 12/2/2022
0.0.0-alpha02 96 12/2/2022
0.0.0-alpha01 129 12/2/2022

Initial Release