Skip to content

Inpired by CodeContracts, small piece of code that allows you to lower the ciclomatic complexity of code by removing some branching.

License

Notifications You must be signed in to change notification settings

spiri91/Ensure.NET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installing

Package manager: Install-Package Ensure4Net

.NET CLI: dotnet add package Ensure4Net

Ensure.NET

Inpired by CodeContracts, small piece of code that allows you to lower the ciclomatic complexity of code by removing some branching. Branching like most precondition, if - else - throw or if - else - set value.

Examples

if (foo == null)
    throw new NullReferenceException();
=> becomes
	Ensure.Condition(foo == boo, new NullReferenceException());

if (foo == goo)
    foo = boo;
=> becomes
    Ensure.Condition(foo == boo, ref foo, boo);

if (ObjectIsValid(foo))
    DoSomething();
=> becomes
    Ensure.Condition(() => ObjectIsValid(foo), () => DoSomething());

About

Inpired by CodeContracts, small piece of code that allows you to lower the ciclomatic complexity of code by removing some branching.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages