PreventR 0.0.4

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

// Install PreventR as a Cake Tool
#tool nuget:?package=PreventR&version=0.0.4                

PreventR

PreventR is a lightweight fluent guard clause library for .Net:

Installing PreventR

You should install PreventRwith NuGet:

Install-Package PreventR

Or via the .NET command line interface (.NET CLI):

dotnet add package PreventR

Either commands, from Package Manager Console or .NET Core CLI, will allow download and installation of PreventR and all its required dependencies.

How to use?

PreventR add methods to all. .Net types

using PreventR;

var strValue = "This is a string";

string mayBeString = strValue.Prevent().NullOrWhiteSpace();

Extending with your own Guard Clauses

To extend your own guards, you can do the following:

// Using the same namespace will make sure your code picks up your 
// extensions no matter where they are in your codebase.

using PreventR;

public static class PreventionExtensions
{
    public static Prevent<T> Foo<T>(this Prevent<T> prevent)
    {
        if (prevent.ToString().Equals("foo")) prevent.ThrowException($"Value 'Foo' is not allowed for argument:  {prevent.Name}");

        return prevent;
    }
}


//Usage

var mayBeString = strValue.Prevent().Foo();

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.
  • net8.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
0.0.6 183 1/23/2024
0.0.4 138 1/16/2024
0.0.3 112 1/15/2024
0.0.2 114 1/14/2024