From 5ba714d689d7284ab67bca01134fb805f883d28a Mon Sep 17 00:00:00 2001 From: Maicon Heck <13810070+maiconheck@users.noreply.github.com> Date: Sat, 19 Dec 2020 10:59:34 +0000 Subject: [PATCH] :recycle: (Guard.Collection) ICollection replaced by IEnumerable --- src/Krafted/Directory.build.props | 4 ++-- src/Krafted/Krafted.Guards/Guard.Collection.cs | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Krafted/Directory.build.props b/src/Krafted/Directory.build.props index b26c1e3..592055f 100644 --- a/src/Krafted/Directory.build.props +++ b/src/Krafted/Directory.build.props @@ -1,8 +1,8 @@ Maicon Heck - 3.0.0 - 3.0.0 + 3.1.0 + 3.1.0 Krafted Krafted $(MSBuildProjectName) diff --git a/src/Krafted/Krafted.Guards/Guard.Collection.cs b/src/Krafted/Krafted.Guards/Guard.Collection.cs index 15a191a..f967a6f 100644 --- a/src/Krafted/Krafted.Guards/Guard.Collection.cs +++ b/src/Krafted/Krafted.Guards/Guard.Collection.cs @@ -1,5 +1,6 @@ using System; -using System.Collections; +using System.Collections.Generic; +using System.Linq; namespace Krafted.Guards { @@ -14,17 +15,18 @@ public partial class Guard /// Throws an if the collection is empty, /// with this error message: Collection cannot be empty. /// + /// The type of enumerable. /// The parameter to check. /// The name of the parameter. /// The guard. /// . - public Guard Empty(ICollection collection, string parameterName) + public Guard Empty(IEnumerable collection, string parameterName) { Guard.Against. Null(collection, nameof(collection)). NullOrWhiteSpace(parameterName, nameof(parameterName)); - if (collection.Count == 0) + if (!collection.Any()) throw new ArgumentException(Texts.CollectionCannotBeEmpty, parameterName); return this; @@ -34,17 +36,18 @@ public Guard Empty(ICollection collection, string parameterName) /// Throws an if the collection is not empty, /// with this error message: Collection should be empty. /// + /// The type of enumerable. /// The parameter to check. /// The name of the parameter. /// The guard. /// . - public Guard NotEmpty(ICollection collection, string parameterName) + public Guard NotEmpty(IEnumerable collection, string parameterName) { Guard.Against. Null(collection, nameof(collection)). NullOrWhiteSpace(parameterName, nameof(parameterName)); - if (collection.Count > 0) + if (collection.Any()) throw new ArgumentException(Texts.CollectionShouldBeEmpty, parameterName); return this;