feat(Async): StartTaskImmediate - #20258
Conversation
# Conflicts: # tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs
❗ Release notes requiredYou can open this PR in browser to add release notes: open in github.dev
|
There was a problem hiding this comment.
Pull request overview
This PR introduces Async.StartTaskImmediate, a new FSharp.Core API that runs a task factory with the ambient Async.CancellationToken and then awaits the produced task/task-like value using Async.Await (non-AggregateException wrapping) semantics. It also updates documentation and unit tests to cover the new behavior and updates the public-surface baselines and release notes accordingly.
Changes:
- Add
Async.StartTaskImmediateoverloads forTask,Task<'T>,ValueTask,ValueTask<'T>, plus an SRTP-based overload for task-like.GetAwaiter()values. - Update
Await/AwaitTaskxmldoc to point users toStartTaskImmediatefor the “start + await with cancellation” scenario. - Add/extend unit tests and update surface area baselines + release notes.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs | Adds coverage for StartTaskImmediate across Task/ValueTask and task-like awaitables. |
| tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.release.bsl | Updates netstandard2.1 release surface area baseline for the new APIs. |
| tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.debug.bsl | Updates netstandard2.1 debug surface area baseline for the new APIs. |
| tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard20.release.bsl | Updates netstandard2.0 release surface area baseline for the new Task-only APIs. |
| tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard20.debug.bsl | Updates netstandard2.0 debug surface area baseline for the new Task-only APIs. |
| src/FSharp.Core/async.fsi | Adds public API declarations and xmldoc for StartTaskImmediate, plus cross-references from Await/AwaitTask. |
| src/FSharp.Core/async.fs | Implements StartTaskImmediate in terms of binding Async.CancellationToken and awaiting via Async.Await. |
| docs/release-notes/.FSharp.Core/11.0.100.md | Adds a release note entry for Async.StartTaskImmediate. |
Suppressed comments (1)
tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs:906
- This new test module should also be part of NotThreadSafeResourceCollection, otherwise it may run in parallel with tests that mutate the global default cancellation token (Async.CancelDefaultToken), causing nondeterministic failures.
module AsyncStartTaskImmediateTaskLikeTests =
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Addresses the task start+await aspect of fsharp/fslang-suggestions#1284
See also fsharp/fslang-suggestions#1467
Checklist
Async.AwaitTaskoverloads which helps with CancellationToken passing, and a new warning fsharp/fslang-suggestions#1284 ?