Skip to content

Releases: maiconheck/krafted

5.1.0

23 Jan 19:03
b708865
Compare
Choose a tag to compare

Improvements

Package: Krafted.Guards

  • Guard.Against.Null(...): where T : class generic constraint removed to increase the parameter types allowed.

5.0.0

08 Dec 18:14
Compare
Choose a tag to compare

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 to net7.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 to RegexFactory class.

Breaking Changes

  • The parameterNameparameter of all guard clauses was moved to the end to compliance with this sonar analyzer rule.
  • The NotExists guard clause now includes the parameterName value in it's exception message.
  • The InvalidEmail guard clause now thows an ArgumentExceptioninstead of FormatException to includes the parameterName value in it's exception message.
  • The Email value object now thows an ArgumentExceptioninstead of FormatException to includes the parameterName value in it's exception message.
  • Guard.Empty<T>() was renamed to Guard.NotAny<T>() to fit better with the System.Linq.Any() name;
  • Guard.NotEmpty<T>() was renamed to Guard.Any<T>() to fit better with the System.Linq.Any() name;

Full Changelog: v4.2.2...v5.0.0

4.2.2

12 May 11:21
Compare
Choose a tag to compare

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

25 Nov 08:40
Compare
Choose a tag to compare

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 from netcoreapp3.1 to net5.0, and this happened probably due to the
    Floating-Point Parsing and Formatting improvements that started in .NET Core 2.1

4.2.0

24 Nov 10:50
Compare
Choose a tag to compare

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

27 Mar 21:44
Compare
Choose a tag to compare

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

13 Feb 16:14
Compare
Choose a tag to compare

New Features

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

26 Dec 17:51
Compare
Choose a tag to compare

New Features

  • Package: Krafted.Extensions

    New extension methods implemented:

  • HttpResponseMessageExtension

    • EnsureContentType
    • DeserializeAsync
  • EnumerableExtension

    • Empty

3.1.0

19 Dec 11:31
Compare
Choose a tag to compare

Improvements

  • Krafted.Guards
    • On Guard.Against.Empty and Guard.Against.NotEmpty, the ICollection was replaced by IEnumerable<T> to be available to any enumerator.

3.0.0

19 Dec 00:26
Compare
Choose a tag to compare

Improvements

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