From 09644a52a23e913201a6e7a675cf0633766a6a81 Mon Sep 17 00:00:00 2001 From: Michael Altmann Date: Sun, 18 Sep 2022 14:31:06 +0200 Subject: [PATCH] ResultHelper.MergeWithValue enumerates results parameter multiple times --- src/FluentResults/Factories/ResultHelper.cs | 6 ++++-- src/FluentResults/FluentResults.csproj | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/FluentResults/Factories/ResultHelper.cs b/src/FluentResults/Factories/ResultHelper.cs index 627eea5..ea34927 100644 --- a/src/FluentResults/Factories/ResultHelper.cs +++ b/src/FluentResults/Factories/ResultHelper.cs @@ -14,11 +14,13 @@ public static Result Merge(IEnumerable results) public static Result> MergeWithValue(IEnumerable> results) { + var resultList = results.ToList(); + var finalResult = Result.Ok>(new List()) - .WithReasons(results.SelectMany(result => result.Reasons)); + .WithReasons(resultList.SelectMany(result => result.Reasons)); if (finalResult.IsSuccess) - finalResult.WithValue(results.Select(r => r.Value).ToList()); + finalResult.WithValue(resultList.Select(r => r.Value).ToList()); return finalResult; } diff --git a/src/FluentResults/FluentResults.csproj b/src/FluentResults/FluentResults.csproj index 7e8e230..fc74c9a 100644 --- a/src/FluentResults/FluentResults.csproj +++ b/src/FluentResults/FluentResults.csproj @@ -2,13 +2,13 @@ netstandard2.0;netstandard2.1 FluentResults - 3.12.0.0 + 3.13.0.0 Michael Altmann A lightweight Result object implementation for .NET false MIT - ADDED - Add Bind() method #140 + FIXED - ResultHelper.MergeWithValue enumerates results parameter multiple times #148 Copyright 2022 (c) Michael Altmann. All rights reserved. Result Results exception error handling