Skip to content

bernarden/Ensure.Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ensure.Net

Build status NuGet

Ensure.Net is a simple yet functional argument validation library.

Project goals

  1. Simple to use.
  2. Support most needed functionality.
  3. Be available for most .NET frameworks.
  4. Take a fresh perspective.

Examples

Constructor

public class YourClass
{
    private IYourDependency _dependency;
    private int _intValue;
    private Guid _recordId;

    public YourClass(IYourDependency dependency, int? intValue, Guid recordId)
    {
        _dependency = Ensure.NotNull(dependency).Value;
        _intValue = Ensure.NotNull(intValue).Value;
        _recordId = Ensure.NotDefault(recordId).Value;
    }
    ...
}

Method

    ...
    public void YourMethod(IYourDependency dependency)
    {
        Ensure.NotNull(dependency);
        ...
    }
    ...

ReSharper

Update ReSharper's settings to auto generate null checks using this library. Refer to this .DotSettings file for an example.