// the find
ardalis/GuardClauses
A simple package with guard clause extensions.
A .NET library that formalizes the guard clause pattern into a fluent, extensible API. You get `Guard.Against.Null(x)` instead of scattered `if (x == null) throw` blocks. Aimed at teams following clean architecture who want consistent input validation at method boundaries.
The extension-method design on `IGuardClause` is the right call — you can add your own guards in the same namespace and they show up on `Guard.Against` with zero ceremony. `CallerArgumentExpression` support means you get the actual parameter name in exceptions without manually passing `nameof(x)`. The test suite covers enumerable variants for every numeric type, which is more thorough than most guard libraries bother with. Active maintenance (last push May 2026) and 3k+ stars means it's not going to be abandoned mid-project.
The clause set has real gaps for modern .NET: no `Guard.Against.NullOrEmpty` for `IEnumerable<T>`, no `Guard.Against.Negative` for `TimeSpan`, and nothing for `Uri` or `Guid` formats beyond null/empty. `Guard.Against.Expression` and `Guard.Against.InvalidFormat` overlap awkwardly — two different ways to do the same thing with no clear guidance on when to use which. The library returns the input value from most guards (so you can assign inline), but the docs barely mention this, which means most users write two lines where one would do. No async guard support, so if your validation needs to hit a DB (duplicate check, existence check), you're writing that yourself anyway.