Releases: maiconheck/krafted
5.1.0
Improvements
Package: Krafted.Guards
Guard.Against.Null(...)
: where T : class generic constraint removed to increase the parameter types allowed.
5.0.0
New Features
Package: Krafted.Guards
The parameterName
parameter is no longer required thanks the CallerArgumentExpression
attribute (C# 10).
So instead of do this:
return Guard.Against
.Null(name, nameof(name))
.NullOrWhiteSpace(shortDescription, nameof(shortDescription))
.Length(5, 200, shortDescription, nameof(shortDescription))
.Null(category, nameof(category))
.Null(price, nameof(price));
Now, you just need to do this:
return Guard.Against
.Null(name)
.NullOrWhiteSpace(shortDescription)
.Length(5, 200, shortDescription)
.Null(category)
.Null(price);
Read more about the CallerArgumentExpression
attribute.
Bypass-nullable-types
The parameter
argument, for all the guard clause methods was changed to nullable.
Therefore now if the parameter
argument is null
, the validation is ignored (i.e. does not throw an Exception).
This is useful for optional parameters whose default value is null
.
New Guard Clauses
InvalidCpf(...)
InvalidCnpj(...)
Package: Krafted.UnitTests
New AssertExtension methods to verifies that a type contains (or not) Null Guard Clauses
for all parameters of it constructor.
Assert.ContainsNullGuardClause<T>(...)
Assert.DoesNotContainNullGuardClause<T>(...)
Package: Krafted.Extensions
New extension method
EnumExtension.GetDisplayName(...)
Package: Krafted.ValueObjects
ActivatorHelper.CreateInstance()
method overloaded to support Value Objects with DateTime
.
When using Entity Framework with Lazy Loading, the ActivatorHelper
provides a helper method to bypass the Guard Clauses via reflection, during the Value Object materialization.
Read more
Improvements
-
The target framework moniker (TFM) was changed from
netstandard2.0
tonet7.0
for all projects of solution in order to take the benefits of C# 11 and latest SDK. -
Code cleanup removing all
nameof(param)
for Guard Clauses internal uses; -
Nullable reference type (NRT) enabled for almost all projects of solution;
-
New optional
message
parameter added to all guard clause methods.
If this parameter is provided, it will override the error message described in the summary section. -
Analyzers rulesets replaced for .editorconfig
-
Nuget packages updated.
-
Refactor
- The guard clause methods were cleaned due to the call of the new Validate method;
- Guard clauses classes moved to GuardClauses folder;
internal NewRegex
factory method moved toRegexFactory
class
.
Breaking Changes
- The
parameterName
parameter of all guard clauses was moved to the end to compliance with this sonar analyzer rule. - The
NotExists
guard clause now includes theparameterName
value in it's exception message. - The
InvalidEmail
guard clause now thows anArgumentException
instead ofFormatException
to includes theparameterName
value in it's exception message. - The
Email
value object now thows anArgumentException
instead ofFormatException
to includes theparameterName
value in it's exception message. Guard.Empty<T>()
was renamed toGuard.NotAny<T>()
to fit better with theSystem.Linq.Any()
name;Guard.NotEmpty<T>()
was renamed toGuard.Any<T>()
to fit better with theSystem.Linq.Any()
name;
Full Changelog: v4.2.2...v5.0.0
4.2.2
Bug Fixes
- Package: Krafted.Guards
Validator.ValidateNif(string nif)
: NIF (Número de Identificação Fiscal) starting with '7' must also be considered valid.Thanks to @vitoreduardo for the contribution that fixes this bug!
4.2.1
Bug Fixes
- Package: Krafted.ValueObjects
Money.ToString()
: The number of decimal places varied when the culture was not explicitly specified.Internal format string
"F"
changed to"F2"
to enforce the two digits decimal precision, regardless of the current culture.
This behavior started since I changed the TFM fromnetcoreapp3.1
tonet5.0
, and this happened probably due to the
Floating-Point Parsing and Formatting improvements that started in .NET Core 2.1
4.2.0
New Features
-
Package: Krafted.ValueObjects
ActivatorHelper: When using Entity Framework with Lazy Loading, provides a helper method to bypass the Guard Clauses via reflection, during the Value Object materialization.
-
Package: Krafted.Guards
Guard.Guid
Improvements
HttpResponseMessageExtension.DeserializeAsync<T>(...)
: where T : class constraint removed in order to deserialize literal values.Guard.String
: ArgumentException changed to ArgumentOutOfRangeException on Length guard clauses.
4.1.0
New Features
- Package: Krafted.Extensions
ListExtension.Move<T>(this IList<T> list, int oldIndex, int newIndex)
: Moves an item from a specified old index to a specified new index.
4.0.0
New Features
-
Package: Krafted.Extensions
StringExtension.ToSlug()
: Converts a phrase to its slug representation. -
Package: Krafted.UnitTests
HttpMessageHandlerMock: Provides a mock to the HttpClient and HttpClientMockFactory
-
Package: Krafted.ValueObjects
Url: Represents an URL (Uniform Resource Locator) value object.
-
Package: Krafted.Guards
Guard.Regex
Improvements
Guard.Lenght(...)
: If the parameter is null or empty, no exception will be thrown.
Breaking Changes
The overload Guard.NullOrEmpty<T>(IEnumerable<T> parameter, string parameterName)
was deleted because now there are other method (Empty<T>(IEnumerable<T> collection, string parameterName)
) that does the same.
3.2.0
New Features
-
Package: Krafted.Extensions
New extension methods implemented:
-
HttpResponseMessageExtension
EnsureContentType
DeserializeAsync
-
EnumerableExtension
Empty
3.1.0
Improvements
- Krafted.Guards
- On
Guard.Against.Empty
andGuard.Against.NotEmpty
, theICollection
was replaced byIEnumerable<T>
to be available to any enumerator.
- On
3.0.0
Improvements
- FxCopAnalyzers migrated to NetAnalyzers
Breaking Changes
-
In order to improve even more the decoupling between the modules, Krafted project/package was splitted into 3 new packages:
-
As the main goal of Krafted is to provide just useful and general purpose set of libraries, I struggle to put in them just this kind of packages, and the packages bellow, despite being useful for me in some projects, doesn't fit well in the Krafted, so I marked them as obsolete, end delete the projects from the solution:
- Krafted.Abstractions
- Krafted.Configuration
- Krafted.EntityFrameworkCore
- Krafted.Rfc
-
The artifacts bellow are moved from Krafted to other code bases:
- Krafted.DesignPatterns/Ddd/* moved to developrdream-framework
- Krafted.EntityFrameworkCore moved to developrdream-framework