TheNephalim / Ensure.That

Yet another guard clause project for .Net C#'ers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ensure.That

Ensure.That is a simple guard clause argument validation lib, that helps you with validation of your arguments.

NuGet(dll)

Nuget

NuGet(src)

Nuget

Turn On/Off - default is On

Could be used with different profiles. Like Debug and CI is On while Release is Off.

#if RELEASE
    Ensure.Off()
#endif

Samples

Ensure.That(myString, nameof(myArg)).IsNotNullOrWhiteSpace();

Ensure.That(myString, "myArg").IsNotNullOrWhiteSpace();

NOTE! I personally would not use the lambda version below to get the name of the argument. I would rather use the nameof construct or manually defining the name of the argument.

From v3.1.0 support for lambdas to extract the param-name and/or value has been added, hence you can now do:

//Note! Makes a compile of the lambda to get the value. Also extracts the param name "person.Name" from the expression.
Ensure.That(() => person.Name).IsNotNullOrWhiteSpace();

//Note! Makes a compile of the lambda to get the value. Does NOT extract the param name "person.Name" from the expression.
Ensure.That(() => person.Name, "The name param").IsNotNullOrWhiteSpace();

//Note! Does NOT make a compile of the lambda. Only parses the expression to get the param name "person.Name" from the expression.
Ensure.That(person.Name, () => person.Name).IsNotNullOrWhiteSpace();

Release notes

Available from v2.0.0, https://github.com/danielwertheim/Ensure.That/wiki/Release-notes

Portable libary or Source via NuGet

Ensure.That is distributed via NuGet. Either as a portable library (for .Net4+, Silverlight, Windows Phone, WinRT) or as an includable source package.

vNext

Since v3.0.0 there's included support for vNext.

Documentation

The documentation is contained in the project wiki.

Get up and running with the source code

The main solution is maintained using Visual Studio 2015.

Please note. No NuGet packages are checked in. If you are using the latest version of NuGet (v2.7.1+) you should be able to just build and the packages will be restored. If this does not work, you could install the missing NuGet packages using a simple PowerShell script as covered here

Unit-tests are written using xUnit and there are no integration tests, hence you should just be able to: Pull-Compile&Run the tests.

Deploy

There's a gulp.js file under .\deploy. It requires that you have nuget.exe in your path. Other than that, you should be able to run the tasks to restore tools, build, run tests and pack NuPkgs.

How-to Contribute

This is described in the wiki, under: "How-to Contribute".

Pull request should be against the develop branch

Issues, questions, etc

So you have issues or questions... Great! That means someone is using it. Use the issues function here at the project page or contact me via mail: firstname@lastname.se; or Twitter: @danielwertheim

About

Yet another guard clause project for .Net C#'ers

License:MIT License


Languages

Language:C# 97.0%Language:JavaScript 3.0%