public static T OrFailIfCollectionEmpty <T>( [CanBeNull, AssertionCondition(AssertionConditionType.IS_NOT_NULL)] this T collection, [NotNull][System.Diagnostics.CodeAnalysis.NotNull] string collectionName ) where T : IEnumerable { Fail.RequiresCollectionName(collectionName); if (collection == null) { throw Fail.Because(Violation.WhenCollectionIsNull(collectionName)); } if (collection.IsEmpty()) { throw Fail.Because(Violation.WhenCollectionIsEmpty(collectionName)); } return(collection); }