This is a ( single file ) library I wrote as an helper to check arguments validity.Here below a sample usage:public class Demo    {        /// <summary>        /// Classical not null verification        /// </summary>        /// <param name=arg1></param>        public void DoSomething(string arg1)        {            Contract.Expect(() => arg1).IsNotNull();        }        /// <summary>        /// Asserting an argument greather than another        /// </summary>        /// <param name=min></param>        /// <param name=max></param>        public void DoSomething(int min,int max)        {            Contract.Expect(() => min)                .IsLessThan(int.MaxValue)                .Meet(a => a <= max);        }        /// <summary>        /// Validate an integer argument in a certain range        /// </summary>        /// <param name=arg1></param>        public void DoSomething(int arg1)        {            Contract.Expect(() => arg1).IsGreatherThan(0)                                       .IsLessThan(100);                ;        }        /// <summary>        /// Validate an array in length and asserts first element should be zero        /// </summary>        /// <param name=array></param>        public void DoSomething(int[] array)        {            Contract.Expect(() => array).Meet(a => a.Length > 0 && a.First() == 0);        }    }Exception message are auto generated based on the argument names, so we don't need magic strings at all. What about it ? Improvement and suggestions? Entire code is hosted here. EDITjust to clarify the pourpose of the library: I'm trying to avoid code such as:if (stringParameter == null)    throw new ArgumentNullException(stringParameter);in which we need to write a string to specify the parameter name. This is not refactory friendly, neither DRY since you write twice stringParameter instead of:Contract.Expect(() => stringParameter).IsNotNull();That is once, and refactor friendly ( at least in my opinion ;) ).
An argument checking library
c#