Skip to content

Argument validation methods, for example: this.user = Argument.NotNull("user", user).

License

Notifications You must be signed in to change notification settings

ashmind/Argument

Repository files navigation

Overview

This project includes a single class, Argument, useful for argument validation/guard methods.
You can get the NuGet package at: https://nuget.org/packages/Argument.

Build status

Example

public MyService(OtherService other) {
   _other = Argument.NotNull("other", other);
}

Features

  1. ReSharper annotations (Argument.ExternalAnnotations.xml).
    Note that there is [NotNull] annotation on values that are being tested — that is so you do not forget to add [NotNull] to your arguments.

  2. For .NET 4.5 Code Contracts: [ContractArgumentValidator].
    I did not have time to test if it actually works in Visual Studio though.

  3. Argument.Ex is an extensibility point. Example:

     public static T Magic<T>(this Argument.Extensible _, string name, T value) {
         //..
     }
    
     Argument.Ex.Magic("name", value);
    

About

Argument validation methods, for example: this.user = Argument.NotNull("user", user).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages