Skip to content

feat(2): Add ThenEnsure / ThenEnsureAsync pass-through validation helpers#6

Merged
mark-pro merged 8 commits into
mainfrom
copilot/add-thenensure-helpers
Mar 9, 2026
Merged

feat(2): Add ThenEnsure / ThenEnsureAsync pass-through validation helpers#6
mark-pro merged 8 commits into
mainfrom
copilot/add-thenensure-helpers

Conversation

Copilot AI commented Mar 8, 2026

Copy link
Copy Markdown
Contributor
  • Inspect PR state and confirm the README conflict is still reported on GitHub
  • Compare /home/runner/work/fail-or/fail-or/README.md on this branch with main
  • Make the smallest README-only merge resolution needed for the conflicting hunk
  • Re-run verification after the README update
  • Run final automated review/security checks for the documentation change
  • Reply on the PR comment with the commit that resolves the conflict
Original prompt

This section details on the original issue you should resolve

<issue_title>Add ThenEnsure / ThenEnsureAsync pass-through validation helpers</issue_title>
<issue_description>Add success-only guard helpers that run another FailOr check and keep the original TSource when that check succeeds.

A checklist item in this issue is only complete when the implementation, relevant tests, and required documentation updates for that item land together in the same change. ErrorOr<R> from the original request maps to repo-native FailOr<R>, and “all arities” here means mirroring the existing direct and lifted Then family without adding parameterless, CancellationToken, or ValueTask overloads.

API

  • FailOr<TSource> ThenEnsure<TResult>(Func<TSource, FailOr<TResult>> ensure) for FailOr<TSource>
  • Task<FailOr<TSource>> ThenEnsureAsync<TResult>(Func<TSource, Task<FailOr<TResult>>> ensureAsync) for FailOr<TSource>
  • Task<FailOr<TSource>> ThenEnsure<TResult>(Func<TSource, FailOr<TResult>> ensure) for Task<FailOr<TSource>>
  • Task<FailOr<TSource>> ThenEnsureAsync<TResult>(Func<TSource, Task<FailOr<TResult>>> ensureAsync) for Task<FailOr<TSource>>

Expected Behavior

  • Success plus successful ensure returns the original success value unchanged
  • Success plus failed ensure returns the ensure failures as FailOr<TSource>
  • Failed source short-circuits without invoking the delegate
  • Null delegates throw ArgumentNullException
  • Async overloads throw ArgumentNullException when the delegate returns null
  • Delegate exceptions are not wrapped

Documentation

  • XML documentation with exceptions and example for each public function
  • README.md chaining/validation examples updated
  • docs/api-reference.md updated

Verification

  • Direct overload tests for pass-through success behavior
  • Direct overload tests for ensure-produced failures
  • Direct overload tests for failed-source short-circuiting
  • Direct overload tests for null delegate handling
  • Direct async overload tests for null returned task handling
  • Lifted overload parity tests against direct behavior
  • dotnet csharpier format run on changed files
  • dotnet test --solution fail-or.slnx passes
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: mark-pro <20671988+mark-pro@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ThenEnsure and ThenEnsureAsync validation helpers Add pass-through ThenEnsure / ThenEnsureAsync validation helpers Mar 8, 2026
Copilot AI and others added 2 commits March 8, 2026 14:01
Co-authored-by: mark-pro <20671988+mark-pro@users.noreply.github.com>
Co-authored-by: mark-pro <20671988+mark-pro@users.noreply.github.com>
Copilot AI changed the title Add pass-through ThenEnsure / ThenEnsureAsync validation helpers Add ThenEnsure / ThenEnsureAsync pass-through validation helpers Mar 8, 2026
@mark-pro mark-pro marked this pull request as ready for review March 8, 2026 14:18
@mark-pro

mark-pro commented Mar 8, 2026

Copy link
Copy Markdown
Member

There is a conflict that needs to be resolved, can you fix the conflicting file? @copilot

Copilot AI and others added 2 commits March 8, 2026 14:25
Co-authored-by: mark-pro <20671988+mark-pro@users.noreply.github.com>
Co-authored-by: mark-pro <20671988+mark-pro@users.noreply.github.com>
@mark-pro mark-pro changed the title Add ThenEnsure / ThenEnsureAsync pass-through validation helpers feat(2): Add ThenEnsure / ThenEnsureAsync pass-through validation helpers Mar 8, 2026

Copilot AI commented Mar 8, 2026

Copy link
Copy Markdown
Contributor Author

There is a conflict that needs to be resolved, can you fix the conflicting file? @copilot

Resolved in 1ead18d. I merged current main into the branch, kept the README conflict resolution in place, and the PR now shows as mergeable/clean.

@mark-pro mark-pro merged commit 131d882 into main Mar 9, 2026
1 check passed
@mark-pro mark-pro deleted the copilot/add-thenensure-helpers branch March 9, 2026 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ThenEnsure / ThenEnsureAsync pass-through validation helpers

2 participants