Skip to content

feat(Async): StartTaskImmediate - #20258

Merged
T-Gro merged 15 commits into
dotnet:mainfrom
bartelink:async-sti
Aug 18, 2026
Merged

feat(Async): StartTaskImmediate#20258
T-Gro merged 15 commits into
dotnet:mainfrom
bartelink:async-sti

Conversation

@bartelink

@bartelink bartelink commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Addresses the task start+await aspect of fsharp/fslang-suggestions#1284

See also fsharp/fslang-suggestions#1467

Checklist

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev


✅ Found changes and release notes in following paths:

Change path Release notes path Description
`src/FSharp.Core` docs/release-notes/.FSharp.Core/11.0.100.md

@bartelink
bartelink marked this pull request as ready for review August 13, 2026 16:46
@bartelink
bartelink requested a review from a team as a code owner August 13, 2026 16:46
Copilot AI lite review requested due to automatic review settings August 13, 2026 16:46

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.

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.StartTaskImmediate overloads for Task, Task<'T>, ValueTask, ValueTask<'T>, plus an SRTP-based overload for task-like .GetAwaiter() values.
  • Update Await/AwaitTask xmldoc to point users to StartTaskImmediate for 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.

@github-actions github-actions Bot added the AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files label Aug 13, 2026
@T-Gro
T-Gro enabled auto-merge (squash) August 17, 2026 12:15
@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling Aug 17, 2026
auto-merge was automatically disabled August 17, 2026 13:04

Head branch was pushed to by a user without write access

@bartelink

bartelink commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@T-Gro I hit the merge button on the PR page around the time you approved, which seems to have mangled things - have force-pushed a fresh (local) merge. I've yet to do a local build and/or validate it's actually any more healthy (the conflict was in the release notes but it appears that surface area tests are failing, which I guess you understand re the net10.0 TFM changes - I put NET in the #ifdefs but maybe !NETFRAMEWORK is better?) Silenced build fails post merge by adding | NET to NETSTANDARD_21 in guards to correct baseline validation re net10 package validation (maybe that should be !NETFRAMEWORK instead)

@T-Gro
T-Gro merged commit 161c13d into dotnet:main Aug 18, 2026
49 checks passed
@T-Gro

T-Gro commented Aug 18, 2026

Copy link
Copy Markdown
Member

The ifdef guard is correct, thanks for actioning this !

Pls let me know if I am owing any other reviews - I believe we might be finished with all the Async/Task/Value task improvements for NET11 by now? 🥇 👍

@bartelink

Copy link
Copy Markdown
Contributor Author

Thanks for shepherding these through, great to see them in!

Pls let me know if I am owing any other reviews

@T-Gro these were my notes regarding potential additions fsharp/fslang-suggestions#1467 (comment)

I personally have a fondness for startAsyncImmediate (piping and forcing a CT to be supplied is very unintuitive IME without it and tends to be wrong in most codebases)

The parallelDo for Async pops up in every codebase IME. And once you have Async.Parallel you want the Task equivalent and its easy to forget cancellation so I think that impl (plus the cancellable task ehancements in that other PR are subtle enough to help enough people - having to drag in FsToolkit.ErrorHandling is very annoying for a relatively common thing)

All that said I do know your previous attitude has been to defer that from this batch of things - if that remains your stance, I might fork off a new pair of suggestions (this also would allow me to close the temp issues in TaskSeq thatnhave sat there annoying the RepoAssist bot for years!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants