Skip to content

Consume ValueTask result - #3314

Merged
martincostello merged 1 commit into
mainfrom
address-feedback-on-3313
Nov 7, 2026
Merged

martincostello merged 1 commit into
mainfrom
address-feedback-on-3313

Conversation

@martincostello

Copy link
Copy Markdown
Member

Address GitHub Copilot feedback on #3313.

Address GitHub Copilot feedback on #3313.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the ValueTask result-consumption change.

No open issues 🎉

What changed in this PR

This PR follows up on #3313 by consuming successfully completed, non-generic ValueTask results in Polly’s outcome conversion fast path, allowing source-backed tasks to release their resources.

Changes:

  • Calls GetResult() before returning a successful void outcome.
  • Adds a tracking test helper and regression tests for exactly-once consumption across outcome conversion and pipeline overloads.
  • Adds benchmarks for non-generic asynchronous callbacks that complete synchronously.
File Description
test/​Polly.Core.Tests/​ResiliencePipelineTests.AsyncT.cs Tests exactly-once consumption for result-returning pipeline overloads.
test/​Polly.Core.Tests/​ResiliencePipelineTests.Async.cs Tests exactly-once consumption for void pipeline overloads.
test/​Polly.Core.Tests/​OutcomeTests.cs Tests consumption during generic and non-generic outcome conversion.
test/​Polly.Core.Tests/​Helpers/​CompletedValueTaskSource.cs Adds a completed task source that counts result consumption.
src/​Polly.Core/​Outcome.cs Consumes completed void tasks before returning the outcome.
bench/​Polly.Core.Benchmarks/​ResiliencePipelineBenchmark.cs Adds void callback benchmarks for context/state and cancellation-token overloads.

Review effort: Balanced

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.04%. Comparing base (ed9c694) to head (b0cd2ce).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3314   +/-   ##
=======================================
  Coverage   98.04%   98.04%           
=======================================
  Files         321      321           
  Lines        7157     7158    +1     
  Branches     1107     1107           
=======================================
+ Hits         7017     7018    +1     
  Misses         98       98           
  Partials       42       42           
Flag Coverage Δ
linux 98.03% <100.00%> (+<0.01%) ⬆️
macos 98.03% <100.00%> (+<0.01%) ⬆️
windows 98.04% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@martincostello
martincostello marked this pull request as ready for review November 7, 2026 15:38
@martincostello
martincostello enabled auto-merge (squash) November 7, 2026 15:38
@martincostello
martincostello merged commit 8c62032 into main Nov 7, 2026
29 checks passed
@martincostello
martincostello deleted the address-feedback-on-3313 branch November 7, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants