Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

guard

> 数据库
Open source

A high-performance, extensible argument validation library.

705 stars0 likes3 views
WebsiteGitHub

About

A high-performance, extensible argument validation library.

Guard

Warning

This project is no longer actively maintained.

I apologise to everyone who depended on Guard for my three-year-long silence. Guard was my passion project for the longest time, helping me get better at C#, automated builds, Visual Studio extensibility, documentation, and how to be part of a community regardless of how small we've been. It also kickstarted my journey of creating terrible gifs.

But my life has changed - I moved to a different country, changed jobs, lost someone very dear to me, and started spending less and less time coding outside my work hours. I always believed I'd be back and release v2 with all my bright ideas, but I just didn't know when. I only noticed today that I've been avoiding my GitHub notifications out of guilt for over a year, and I figured it was time for closure.

Why I'm stopping this

  • I can no longer find the time to maintain an open-source project, as I want to spend most of my free time with my family and on other hobbies.

  • Guard has always been in an awkward position:

    Library authors avoid adding unnecessary dependencies to their packages, and Guard didn't bring enough value to be worth being a runtime dependency. I wanted to experiment with IL weaving and source generators to make Guard a compile-time dependency that would replace call sites with simple if-then-throw statements, but I never got the chance.

    App developers didn't need Guard, as their validation scenarios don't involve throwing argument exceptions. For example, a web API would use something like DataAnnotation attributes or FluentValidation to validate its requests. So as a library that specifically targeted library authors, Guard has mostly been irrelevant to app developers.

What was I looking to do in v2:

  • New style with using static and [CallerArgumentExpression]:

    csharp
    // using static Dawn.Validation.Argument;
    
    Require(firstName).NotNullOrWhiteSpace();
  • Light validations with [CallerArgumentExpression]:

…

c# public Person(string name, int age) { if (name == null) throw new ArgumentNullException(nameof(name), "Name cannot be null.");

if (name.Length == 0)
    throw new ArgumentException("Name cannot be empty.", nameof(name));

if (age 7.2` or later added in your .csproj file.

.NET Standard 1.0 and above are supported. Microsoft Docs lists the following platform versions as .NET Standard 1.0 compliant but keep in mind that currently, the unit tests are only targeting .NET Core 3.0.

Platform Version
.NET Core 1.0
.NET Framework 4.5
Mono 4.6
Xamarin.iOS 10.0
Xamarin.Mac 3.0
Xamarin.Android 7.0
Universal Windows Platform 10.0
Windows 8.0
Windows Phone 8.1
Windows Phone Silverlight 8.0
Unity 2018.1

More

The default branch (dev) is the development branch, so it may contain changes/features that are not published to NuGet yet. See the master branch for the latest published version.

Standard Validations

Click here for a list of the validations that are included in the library.

Design Decisions

Click here for the document that explains the motives behind the Guard's API design and more advanced features.

Extensibility

Click here to see how to add custom validations to Guard by writing simple extension methods.

Code Snippets

Code snippets can be found in the snippets folder. Currently, only the Visual Studio is supported.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#argumentsc-sharpcsharpdotnet-standard

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库