Skip to content

Commit

Permalink
ResultHelper.MergeWithValue enumerates results parameter multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
altmann committed Sep 18, 2022
1 parent dfa786e commit 09644a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/FluentResults/Factories/ResultHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ public static Result Merge(IEnumerable<ResultBase> results)

public static Result<IEnumerable<TValue>> MergeWithValue<TValue>(IEnumerable<Result<TValue>> results)
{
var resultList = results.ToList();

var finalResult = Result.Ok<IEnumerable<TValue>>(new List<TValue>())
.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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/FluentResults/FluentResults.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<PackageId>FluentResults</PackageId>
<Version>3.12.0.0</Version>
<Version>3.13.0.0</Version>
<Authors>Michael Altmann</Authors>
<Description>A lightweight Result object implementation for .NET</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReleaseNotes>
ADDED - Add Bind() method #140
FIXED - ResultHelper.MergeWithValue enumerates results parameter multiple times #148
</PackageReleaseNotes>
<Copyright>Copyright 2022 (c) Michael Altmann. All rights reserved.</Copyright>
<PackageTags>Result Results exception error handling</PackageTags>
Expand Down

0 comments on commit 09644a5

Please sign in to comment.