BrutalHack.Bouncer 0.4.1

Lightweight Runtime-Only Contracts for .Net Standard 2.0. Focus lies on Readability and Extensibility. Under MIT License.

Install-Package BrutalHack.Bouncer -Version 0.4.1
dotnet add package BrutalHack.Bouncer --version 0.4.1
<PackageReference Include="BrutalHack.Bouncer" Version="0.4.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BrutalHack.Bouncer --version 0.4.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Bouncer

Bouncer provides lightweight runtime-only "contracts" for .Net applications.
Focus lies on readability and extensibility.

Build Status

| Framework | Status|
|--|--|
| .Net Core 2.1 | Build Status |

Usage

Import the Nuget Package and check constraints for your methods parameters in a few readable lines.
When a constraint is violated, you receive a readable exception including stack trace.

with Bouncer

IBouncer Bouncer;

public CreateNewUser(string name, int age)
{
  Bouncer.IsNotNullOrEmpty(name);
  Bouncer.IsPositive(age)
  // Do Stuff
}

without Bouncer

public CreateNewUser(string name, int age)
{
  if (name == null)
  {
    throw new ArgumentNullException(nameof(name), "Must not be null.");
  }
  if (name.length == 0)
  {
    throw new ArgumentOutOfRangeException(nameof(name), "Must not be empty.");
  }
  if (age < 0)
  (
    throw new ArgumentOutOfRangeException(nameof(age), "Must be positive.");
  }
  
  // Do Stuff
}

Planned Features

  • More constraints
  • Easily disable all constraints in production mode
  • Guide on extending Validate with your own constraints

Naming

We finally found a name that we like!

Bouncer

Bouncer provides lightweight runtime-only "contracts" for .Net applications.
Focus lies on readability and extensibility.

Build Status

| Framework | Status|
|--|--|
| .Net Core 2.1 | Build Status |

Usage

Import the Nuget Package and check constraints for your methods parameters in a few readable lines.
When a constraint is violated, you receive a readable exception including stack trace.

with Bouncer

IBouncer Bouncer;

public CreateNewUser(string name, int age)
{
  Bouncer.IsNotNullOrEmpty(name);
  Bouncer.IsPositive(age)
  // Do Stuff
}

without Bouncer

public CreateNewUser(string name, int age)
{
  if (name == null)
  {
    throw new ArgumentNullException(nameof(name), "Must not be null.");
  }
  if (name.length == 0)
  {
    throw new ArgumentOutOfRangeException(nameof(name), "Must not be empty.");
  }
  if (age < 0)
  (
    throw new ArgumentOutOfRangeException(nameof(age), "Must be positive.");
  }
  
  // Do Stuff
}

Planned Features

  • More constraints
  • Easily disable all constraints in production mode
  • Guide on extending Validate with your own constraints

Naming

We finally found a name that we like!

Release Notes

Added Bouncer.IsNullOrWhitespace(params string[]); Fixed small issue in an Exception Message.

  • .NETStandard 2.0

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.4.1 370 8/20/2019
0.3.0 372 6/23/2019