CriusNyxUtil

This is a set of utility functions that I find myself using frequently.

They provide a fluent api for tasks I do frequently.

See Introduction or API

Examples

For example, say you want to assign a field to an object before passing it into a method.

Tree.AddChild(
  new Node().Touch(child => { child.name = "Child"; })
);

Or you want to validate that the result of a function is not null before assigning it to a field.

var a = MyClass.From(source).NotNull("a");

Consider the source code for this language parser. If the parser reaches the select statement left, equal and right should be defined. Therefore, left, equal, or right returning a null value would indicate that a bug has slipped. Using the NotNull method will give the developer a crash with a useful error if a bug is introduced during development, rather then letting the construction of an invalid object happen and having it crash later.

var AssignParser =
  from left in LeftHandExpressionParser
  from equal in EqualSignParser
  from right in RightHandExpressionParser
  select new AssignExpression(
    left.NotNull("left"),
    equal.NotNull("equal"),
    right.NotNull("right"));

Or this case where you want to validate a class and throw an exception before returning control flow to the caller.

// Null check a field on initialization.
public class MyClass(string value){
  string Value = value.NotNull("value");
}

Consider looking at the Introduction for a rundown of the library.