Swevo.AutoGuard 1.0.1

Prefix Reserved
dotnet add package Swevo.AutoGuard --version 1.0.1
                    
NuGet\Install-Package Swevo.AutoGuard -Version 1.0.1
                    
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="Swevo.AutoGuard" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Swevo.AutoGuard" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Swevo.AutoGuard" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Swevo.AutoGuard --version 1.0.1
                    
#r "nuget: Swevo.AutoGuard, 1.0.1"
                    
#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.
#:package Swevo.AutoGuard@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Swevo.AutoGuard&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Swevo.AutoGuard&version=1.0.1
                    
Install as a Cake Tool

Swevo.AutoGuard

Compile-time guard clauses for .NET.

Apply [AutoGuard] to a partial class with a primary constructor, then decorate constructor parameters with guard attributes:

using AutoGuard;

[AutoGuard]
public partial class CreateOrderCommand(
    [NotNull] string id,
    [NotEmpty] string customer,
    [InRange(1, 100)] int quantity,
    [Matches(@"^[A-Z0-9]+$")] string sku)
{
}

The source generator emits a private field initializer that validates arguments during construction and throws the expected framework exceptions.

Guard attributes

  • [NotNull]
  • [NotEmpty] for string and IEnumerable<T>
  • [InRange(min, max)]
  • [Matches(pattern)]

Package

  • Package ID: Swevo.AutoGuard
  • Target: Roslyn source generator / analyzer package
  • Assembly packed to analyzers/dotnet/cs
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.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.0.1 121 6/26/2026
1.0.0 89 6/26/2026