Be notified of new releases
Create your free GitHub account today to subscribe to this repository for new releases and build software alongside 28 million developers.Sign up
- Added support for .snupkg NuGet Symbol package
- Added static
Rangeclass to simplify the creation of
- Light.GuardClauses is now available as source code distribution with internal types (see Light.GuardClauses.SingleFile.cs in the top-level folder of the repository). You can also create you custom single source file by using the Light.GuardClauses.SourceCodeTransformation project.
string.Equalsextension method which allows comparing strings ignoring the white space. Added corresponding
MustNotBeoverloads for strings.
- fixed some typos in XML comments
- Fixed typo in type: EqualivalentTypeComparer is now called EquivalentTypeComparer
MustBeValidEnumValuenow use the new
where T : Enumconstraint of C# 7.3
New logic for custom exception and messages:
- When an exceptionFactory is provided, the resulting exception is always thrown, no matter what check fails inside an assertion
- Messages are passed to all exceptions that are thrown by Light.GuardClauses
See #53 for details.
Important note: there are a lot of breaking changes in between version 3.5 and 4.0 - mainly because a lot of assertions were removed. If you are missing a particular assertion and think it should come back, please open an issue and let me know.
- Support for .NET Standard 2.0 and 1.0, .NET 4.5, .NET 4.0, .NET 3.5 and .NET 3.5 Compact Framework, as well as Silverlight 5 - thanks to @onovotny for his awesome MSBuildSdkExtras.
- performance improvements across the board - thanks to @redknightlois for his consulting and @AndreyAkinshin and @adamsitnik for their awesome tool Benchmark.NET, many assertions are now about as fast as your imperative code (benchmarks performed in .NET 4.7.x and .NET Core 2.x).
- ReSharper support via Contract Annotations - ReSharper now understands when Light.GuardClauses assertions do not return a null value and thus removes squiggly lines indicating a possible
- Collection assertions are way faster now, do not allocate, and the returned value actually is the same collection type that was passed in.
- New assertions and functionality:
Check.InvalidStatethat throw an
MustNotBeDefaultasserts that a value is not
MustNotBeNullReferenceis the same as
MustNotBeNullbut for generic scenarios where
Tis not contrained to be a reference type.
IsValidEnumValuenow supports enums marked with the
- All assertions are now in the static
- All assertions that throw exceptions were split into two overloads: one throwing the default exception, and one where a custom delegate
- Removed all
DictionaryAssertions- use the normal
Valuescollection of a dictionary if necessary.
- Removed the following assertions because this is not an assertion library for unit testing:
- Collection assertions:
IngoreCaseInfoand corresponding assertions for strings, instead overloads were added that use the well known
- The following string assertions were removed:
- Removed extension methods
Equalityis now called
- More fine-grained exception hierarchy.
StringBuilderExtensionsare now called
Typesclass is now in namespace
EqualityAssertionscan now be found in
TypeAssertionshas the following breaking changes:
- All assertions that throw exceptions were removed
- Generally, everything in the context of
TypeInfowas removed. The traditional reflection model already provides the members that achieve the most of the goals -
TypeInfois regarded as obsolete since .NET Standard 2.0.
NotNull<T>because when used as a parameter, you cannot be sure that it wasn't created using the default struct initializer.
New Features in version 3.5.0
- added structural equality testing for collections:
- added overloads for
AsReadOnlyListthat allow you to specify a create-collection-delegate
New Features in version 3.3.0
New Features in version 3.2.0
New Features in version 3.1.0
Added assertion methods for generic types:
Added boolean assertion methods:
Added more variants of existing assertion methods throwing no exception:
- IsStartingWith and IsEndingWith