This project is read-only.

Guard and Removing the value parameter.

Dec 7, 2012 at 3:11 AM

Why are both "expression" and "value" passed in as parameters, when you can derive the value from the expression?


public static void NotNull<T>(Expression<Func<T>> reference)
    T value = reference.Compile()();
    if (value == null)
        throw new ArgumentNullException(GetParameterName(reference), "Parameter cannot be null.");

Is Compile so expensive you must also pass in the value separately?