Skip to content

feat: CatchAsync takes a ValueTask, and TraverseAsync reaches Option and Patch - #94

Merged
CaffeinatedCoder merged 1 commit into
release/2.3.0from
feat/catch-async-valuetask
Oct 28, 2026
Merged

CaffeinatedCoder merged 1 commit into
release/2.3.0from
feat/catch-async-valuetask

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #88

Problem

A call that returns a ValueTask, such as stream.ReadAsync(buffer), reached Result.CatchAsync only through .AsTask() or an async lambda. Decision 30 left ValueTask overloads out because they made every async lambda ambiguous. Option<T> and Patch<T> had Traverse but no TraverseAsync, so an asynchronous check of an optional input or a patch field needed a Match by hand.

Change

  • CatchAsync over a ValueTask: four forms (valued and command, wide and narrowed), each [OverloadResolutionPriority(-1)]. They catch as the Task forms do. An async lambda still binds to the Task form. Catch still refuses a ValueTask at run time, because a compile error there would break a build that works today.
  • TraverseAsync on Option<T> and Patch<T>, with token forms: the synchronous Traverse with the operation awaited. None, a clear and an absent field call nothing and check no token.
  • Decision 110 records both. Decision 30's index row points to it, and the option-result note says so.
  • Docs:
    • docs/result.md: the compiled TraverseAsync sample has an Option line and a Patch line, and the surface table has a row for each.
    • The core README: the Traverse sentences, the CatchAsync bullets, and "A task given to Catch".
    • The changelog. The roadmap item is removed.

Tests

  • CatchAsyncValueTaskTests:
    • Every form: the value or a success, an exception before the task or after its first await, a narrowed form letting others propagate, a cancellation and a wrapped cancellation passed through, a timeout as the error, a null value and a task of a task refused.
    • A consumer compilation over 18 calls pins which form each binds to: every async lambda and every Task delegate binds to the Task form, and every ValueTask delegate or method group to the new form.
  • OptionPatchTraverseAsyncTests: a value awaited into Some, Value or the error; None, a clear and an absence pass through without a call, even with a cancelled token; the token is handed on; a cancelled token starts nothing.
  • The completeness tests (null delegate, null task, asynchronous context, uninitialized result) have cases for the eight new members.
  • Seeded and caught:
    • The priority attribute removed: the existing CatchAsync calls in the tests are CS0121.
    • No catch after the await: 2 tests fail.
    • None checking the token: 1.
    • A clear passed through as absent: 1.
    • The token not handed on: 1.
  • Full suite: 18,273 passed. The core package packs with package validation against 2.2.0.

🤖 Generated with Claude Code

…and Patch

Result.CatchAsync gains four ValueTask forms, valued and command, wide and
narrowed, catching as the Task forms do. Each is
[OverloadResolutionPriority(-1)], so an async lambda binds to the Task form
as before; without it the repository's own CatchAsync calls are CS0121, the
ambiguity decision 30 measured. Catch keeps refusing a ValueTask at run time.

Option<T>.TraverseAsync and Patch<T>.TraverseAsync, with token forms, are the
synchronous Traverse with the operation awaited: None, a clear and an absent
field call nothing and check no token.

Decision 110 records both. The completeness tests (null delegate, null task,
asynchronous context, uninitialized result) cover the eight new members.

Closes #88

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 2.3.0 milestone Oct 28, 2026
@CaffeinatedCoder CaffeinatedCoder added enhancement New feature or request package/core Affects CodoMetis.TypeKit area/option-result Option, Result and their extensions labels Oct 28, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit c45ab90 into release/2.3.0 Oct 28, 2026
16 of 19 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/catch-async-valuetask branch October 28, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/option-result Option, Result and their extensions enhancement New feature or request package/core Affects CodoMetis.TypeKit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant