Hello Light.GuardClauses
First version of Light.GuardClauses
Includes the following functionality:
- Check: CompileAssertionsSymbol and methods That and Against as minimal functionality for creating assertions that can be selectively compiled.
- CommonAssertions: MustNotBeNull (probably the most important one), MustBeNull, MustBeType, MustHaveValue, MustNotHaveValue, MustBeValidEnumValue, and MustNotBeEmpty for GUIDs
- ComparableAssertions: MustNotBeLessThan(OrEqualTo), MustNotBeGreaterThan(OrEqualTo), MustBeIn and MustNotBeIn for ranges
- DictionaryAssertions: MustBeKeyOf, MustNotBeKeyOf, MustHaveKey(s), MustNotHaveKey(s)
- EnumerableAssertions: MustBeOneOf, MustNotBeOneOf, MustNotBeNullOrEmpty, MustHaveNoDuplicates, MustNotContainNull, MustContain, MustNotContain, MustBeSubsetOf
- EqualityAssertions: MustBe, MustNotBe, MustBeEqualTo and MustNotBeEqualTo for IEquatable instances, MustBeEqualToValue and MustNotBeEqualToValue for IEquatable instances that are value types
- NotNull: a struct holding a reference to an instance of a reference type and ensures that this reference is not null. Overrides Equals and GetHashCode so that it behaves exactly as the referenced object in this regard (calls are forwarded). Overloads several version fo the == and != operators and provides implicit conversion so that it is easy to use. If you use this struct on a parameter, you can definitely be sure that the reference is not null, but there might be some other issues with the usage of this type (e.g. when resolving via a DI container). As it is a struct, there should be minimal performance overhead and no pressure on the garbage collector as no new object is created when this type is used.