Repository navigation
Add HttpContent.CopyToAsync polyfills with CancellationToken - #149
Conversation
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…c tests Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
|
@copilot resolve merge conflicts by merging latest |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The success tests call existing instance overloads rather than the new polyfills.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds .NET 5 HttpContent.CopyToAsync cancellation-token polyfills for older targets.
Changes:
- Adds both cancellation-aware overloads.
- Adds success and cancellation tests.
- Regenerates API signatures.
| File | Description |
|---|---|
Signatures.md |
Documents the new overloads. |
PolyShim/Net50/HttpContent.cs |
Implements both polyfills. |
PolyShim.Tests/Net50/HttpClientTests.cs |
Adds copy and cancellation tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…s-for-httpcontent-copytoasync # Conflicts: # Signatures.md Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Merged the latest |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## prime #149 +/- ##
==========================================
+ Coverage 88.12% 88.18% +0.05%
==========================================
Files 347 347
Lines 7773 7811 +38
Branches 557 557
==========================================
+ Hits 6850 6888 +38
Misses 754 754
Partials 169 169 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|

HttpContent.CopyToAsyncgained twoCancellationToken-accepting overloads in .NET 5. The existingHttpContentpolyfills coveredReadAsStreamAsync/ReadAsByteArrayAsync/ReadAsStringAsyncbut notCopyToAsync, leaving no way to pass a cancellation token on older target frameworks.Polyfills added (
PolyShim/Net50/HttpContent.cs)Task CopyToAsync(Stream, CancellationToken)Task CopyToAsync(Stream, TransportContext?, CancellationToken)Both follow the established pattern for this file: check
cancellationToken.ThrowIfCancellationRequested()up front, then delegate to the native non-cancellable overload.The other two overloads documented on the
CopyToAsyncAPI page —CopyToAsync(Stream)andCopyToAsync(Stream, TransportContext?)— already exist on every supported target framework via the abstractHttpContentbase class, so they don't require a polyfill.Other changes
PolyShim.Tests/Net50/HttpClientTests.cscovering both new overloads, including cancellation behavior.Signatures.mdto reflect the new polyfills.