Skip to content

refactor(CancellableTasks): Delegate to Task.sequential/parallelLimit - #20695

Merged
T-Gro merged 5 commits into
dotnet:mainfrom
bartelink:apply-parallel-limit
Oct 14, 2026
Merged

T-Gro merged 5 commits into
dotnet:mainfrom
bartelink:apply-parallel-limit

Conversation

@bartelink

@bartelink bartelink commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Follow up to #20128 as noted in #20128 (comment) - Replace bodies of CancellableTask.whenAllThrottled and sequential with Task.parallelLimit and sequential

Copilot AI balanced review requested due to automatic review settings October 3, 2026 23:09
@bartelink
bartelink requested a review from a team as a code owner October 3, 2026 23:09
@bartelink bartelink changed the title refactor(CancellableTasks): Apply Task.sequential/parallelLimit refactor(CancellableTasks): Delegate to Task.sequential/parallelLimit Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

✅ Release-note check exempted

The NO_RELEASE_NOTES label exempts this pull request.

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.

Copilot review overview

🟡 Changes recommended

The sequential delegation can continue queued work after cancellation.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Refactors editor cancellable-task helpers to reuse FSharp.Core task combinators.

Changes:

  • Delegates throttled parallel and sequential execution to Task helpers.
  • Adds the follow-up PR to Visual Studio release notes.
File Description
CancellableTasks.fs Replaces custom scheduling implementations.
18.vNext.md Adds the follow-up PR reference.

@bartelink
bartelink force-pushed the apply-parallel-limit branch 10 times, most recently from 5ac18b9 to dfe59e9 Compare October 5, 2026 08:53

@T-Gro T-Gro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤖 🕵️ AI review — verify independently.

@T-Gro
T-Gro self-requested a review October 7, 2026 12:51
@T-Gro T-Gro added the AI-reviewed PR reviewed by AI review council label Oct 7, 2026
@bartelink
bartelink force-pushed the apply-parallel-limit branch from 6db3c40 to d1ba03f Compare October 7, 2026 20:40
@bartelink
bartelink force-pushed the apply-parallel-limit branch from d1ba03f to 7740b07 Compare October 7, 2026 20:43
@T-Gro T-Gro added the NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes label Oct 14, 2026
@T-Gro
T-Gro enabled auto-merge (squash) October 14, 2026 12:02
@T-Gro
T-Gro disabled auto-merge October 14, 2026 12:03
@T-Gro
T-Gro merged commit daacf37 into dotnet:main Oct 14, 2026
55 of 56 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in F# Compiler and Tooling Oct 14, 2026
@bartelink
bartelink deleted the apply-parallel-limit branch October 14, 2026 12:04
bartelink added a commit to bartelink/FsToolkit.ErrorHandling that referenced this pull request Oct 14, 2026
TheAngryByrd added a commit to bartelink/FsToolkit.ErrorHandling that referenced this pull request Nov 13, 2026
…demystifyfp#384)

The net10 shim of Task.sequential and Task.sequentialDo follows dotnet/fsharp main, which checks the token before each factory (dotnet/fsharp#20695). FSharp.Core 11.0.101 was built without that change, and net11 consumers bind to it directly.

- New tests: a canceled token cancels the task and calls no factory. They run on net10 and are pending on net11 until FSharp.Core ships dotnet/fsharp#20695.
- A NOTE above sequential links to demystifyfp#384, which lists the steps for that release.
- The net11 Obsolete messages and module docs now say net11.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TheAngryByrd added a commit to bartelink/FsToolkit.ErrorHandling that referenced this pull request Nov 17, 2026
netstandard2.0 already gets the Async.Await ValueTask overloads and the
ValueTask module through Microsoft.Bcl.AsyncInterfaces. Task.ofValueTask
had a NETSTANDARD2_1 || NET guard, so netstandard2.0 did not get it.

- Remove the guard. This adds API only.
- Tests: completed, pending, and faulted value tasks.
- RELEASE_NOTES.md: the netstandard2.0 ValueTask surface, and the known
  Task.sequential difference on net11 until FSharp.Core ships
  dotnet/fsharp#20695 (demystifyfp#384).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TheAngryByrd added a commit to demystifyfp/FsToolkit.ErrorHandling that referenced this pull request Nov 17, 2026
* tidy(Async.parallelMap*): Remove unnecessary ifdef

* feat(net10): Add TFM-specific build, omitting duplicates present in FSharp.Core

* feat(Task): FSharp.Core 11 shims for < net10 builds

* refactor(Task): rename/Obsolete singleton -> result

* feat(Task)!: Implement breaking changes re FSharp.Core 11

* feat(Async): FSharp.Core V11 shims

* refactor(Async.singleton)!: Obsolete singleton in favor of result

* refactor(singleton): Replace with result/ok/some

* refactor(TaskResult)!: Align with Task names

* refactor(catch, ofCatchTash): Replace with catchWith/catch

* feat: ValueTask shims

* chore: Shim and replace Async.AwaitTask -> Await

includes transition to Async.StartTaskImmediate
added net10.0 TFMs and coverage

* tidy(Async): Apply StartTaskImmediate/StartImmediateAsTask consistently

* feat(Result): Conditionally remove dups for net6

* feat(net10): Exclude builtins

* doc(JobOption.eitherBind): Fix signature/example

* Changelog

* feat(net10): Exclude dups of intrinsics

* review

* feat: ofTaskUnit

* fix(ofAsync/ofTask/ofResult): Obsolete inconsistent semantics

* review

* chore(Task): Sync parallelLimit etc from upstream

See dotnet/fsharp#20695

* review

* review: Address slips, nits, inconsistencies and doc/comment inaccuracies

* fix(Await): Correct SyncContext honoring

NOTE introduces extra noise in stacktrace relative to previous impl
See also: dotnet/fsharp#20868

* review(TaskResult): Restore full semantics to Obsolete catch/ofCatchTask, document behavior difference

ref #373 (comment)

* review(Async): Remove erroneous dups to align with Task

ref: #373 (comment)

* review(Async): Adjust conditional compilation to surface shims to Fable

ref #373 (comment)

* review(Shims): Include forwarders in >= net10

* review: Self-review pass

* review: Correct absence of Async forwarders

* review: Correct Obsoletion semantics

* review: doc/lint

* review: More cleanups

* refactor(Result,Option): Move shims to separate files

* fix(Agent): Warn about not using build for Format check

* test(Shims): Happy path tests validating shimming

* refactor(Option): Remove superfluous shims

* build: Move to SDK 11 and test on net10.0 and net11.0

- global.json: SDK 11.0.100.
- Test projects, benchmarks, and FunctionMap target net10.0 and net11.0. The FAKE build project targets net11.0. .NET 8 and 9 reached end of support on 2026-11-10.
- CI: a local composite action, .github/actions/setup-dotnet, now holds the setup-dotnet version and the runtime list for build.yml and publish.yml.
- FunctionMap: nonNull for DeclaringType.FullName, which the net10 BCL marks as nullable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* build(deps): Update FAKE to 6.2.0 to remove vulnerable build packages

FAKE 5.22.0 brought 8 advisories into the build project, 2 of them critical (NuGet.Packaging GHSA-68w7-72jg-6qpp, System.Drawing.Common GHSA-rxg9-xrhp-64gj). The library packages had none.

- Fake.* 5.22.0 -> 6.2.0, NuGet.Protocol 6.6.1 -> 6.12.5.
- Direct MSBuild.StructuredLogger and NuGet.Protocol references lift the System.Drawing.Common and NuGet.Packaging versions that FAKE 6.2.0 still brings in.
- FAKE 6 reads a "### [x.y.z]" heading as the latest release. With the 4.15.3 and 4.16.0 headings, it parsed version 2024. Remove the brackets from those headings.
- build.fs fails when the parsed version does not match the first heading, so a release cannot publish or tag a wrong version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat: Add net11.0 and forward to FSharp.Core 11 only on net11.0

The net10.0 asset depended on FSharp.Core 11 rc3. A default net10 app on SDK 10 gets FSharp.Core 10.x, so it built with NU1605 and failed at start with FileNotFoundException for FSharp.Core 11.0.0.0.

- Add net11.0 to FsToolkit.ErrorHandling, AsyncSeq, JobResult, and IcedTasks. Keep net9.0 and net6.0.
- Async and Task shims forward to FSharp.Core 11 under NET11_0_OR_GREATER. The net10.0 asset compiles the shims.
- FSharp.Core minimum: netstandard2.x and net6.0 6.0.4, net9.0 9.0.300, net10.0 10.0.100, net11.0 11.0.101. Tests use the same versions, so the net10.0 run tests the shims and the net11.0 run tests FSharp.Core 11.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* build: Update Fable to 5.27.0 for SDK 11

Fable 4.28.0 and 4.29.0 hang on SDK 11 after the project restore, with no CPU use. Fable 5.27.0 compiles the tests to JavaScript and Python.

- .config/dotnet-tools.json: fable 4.28.0 -> 5.27.0.
- Directory.Build.props: keep Nullable off when FABLE_COMPILER is true. Fable 5 checks nullness, and Nullness.fs polyfills non-nullable types for Fable, so isNull on SeqNull failed with FS3261.
- build.yml: Fable Python tests run on Python 3.12 and 3.13. Fable 5 emits PEP 695 generics, which need Python 3.12 or newer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* build: Install the matching fable-library before the Python tests

Fable 5 no longer bundles its Python runtime library in the NuGet package. It publishes fable-library on PyPI with the same version as the fable tool. Without it, the tests fail with "ModuleNotFoundError: No module named 'fable_library'".

runPythonTests reads the fable version from .config/dotnet-tools.json and installs fable-library at that version, so one pin controls both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test: Make Async.never cancellable and fail an unfinished JS run

With Fable 5, the JavaScript run stopped at "ParallelAsyncResult.zip tests - Error result fails fast 1" and node exited with code 0, so NpmTest passed without about 50 tests.

- The JS Async.never was a Promise that never resolves and ignored cancellation. Fable 4 Async.Parallel failed fast like Promise.all. Fable 5 cancels the other computations and waits for them, as .NET does, so it waited forever. Async.never now registers on the cancellation token on every platform. This also removes the Async.Sleep loop.
- The Fable JS entry point sets exit code 1 on "beforeExit". Pyxpecto ends every finished run with process.exit, so "beforeExit" fires only when a test never completes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test: Add behavior tests for the FSharp.Core 11 shims

The net10.0 test run uses the FsToolkit shims and the net11.0 run uses FSharp.Core 11, so each test also checks that both implementations behave the same.

- Async.Await: one fault raises the inner exception, two faults keep AggregateException. A mutant that changes "InnerExceptions.Count = 1" to "= 0" now fails a test.
- Task.catch, Task.catchWith, Async.catch, Async.catchWith: success, fault, and canceled input.
- Task.sequential, Task.sequentialDo, Task.parallelLimit, Task.parallelDoLimit: start order and concurrency limit, with TaskCompletionSource gates.
- Task.map: a mapper that throws OperationCanceledException gives Faulted for a completed input and Canceled for a pending input. RELEASE_NOTES.md now describes this change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(Async): Limit parallelLimit concurrency on Fable Python

fable-library for Python implements Async.Parallel without the maxDegreeOfParallelism argument, so Async.parallelLimit and Async.parallelDoLimit failed with "parallel() takes 1 positional argument but 2 were given". Fable 5 for JavaScript supports the argument.

- Under FABLE_COMPILER_PYTHON, parallelLimit runs min(limit, count) workers. Each worker takes the next computation when it finishes, and results keep the input order.
- New AsyncParallelLimit tests run on .NET, Fable JavaScript, and Fable Python. They hold each computation on a continuation and check how many started before each release. A mutant that starts one worker per computation fails 3 tests.
- The net11 Obsolete messages and module docs now say net11, to match the NET11_0_OR_GREATER gate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(Task): Pin sequential cancellation and track the FSharp.Core gap (#384)

The net10 shim of Task.sequential and Task.sequentialDo follows dotnet/fsharp main, which checks the token before each factory (dotnet/fsharp#20695). FSharp.Core 11.0.101 was built without that change, and net11 consumers bind to it directly.

- New tests: a canceled token cancels the task and calls no factory. They run on net10 and are pending on net11 until FSharp.Core ships dotnet/fsharp#20695.
- A NOTE above sequential links to #384, which lists the steps for that release.
- The net11 Obsolete messages and module docs now say net11.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(ParallelAsyncResult): Avoid a generic exception type test under Fable

On Linux CI, Fable 5 reports "Generic args are ignored in type testing" for `:? AsyncResultErrorException<'error>` at ParallelAsyncResult.fs(36,12). TreatWarningsAsErrors makes it an error, so NpmTest and PythonTest failed to compile. Fable 4 did not report it. Fable consumers compile this source too, so they can hit the same error.

Under FABLE_COMPILER, AsyncResultErrorException is non-generic and carries the error boxed. map2 and map3 unbox it. The .NET code does not change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* build(devcontainer): Use SDK 11 with runtime 10 and Python 3.13

global.json asks for SDK 11.0.100, so the dev container failed with "A compatible .NET SDK was not found". The tests run on net10.0 and net11.0, and Fable 5 Python output needs Python 3.12 or newer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test: Use Async.result in the #380 taskValidation test

The merge from master brought in a test that calls Async.singleton, which this PR marks obsolete. TreatWarningsAsErrors turned FS0044 into a build error in every dotnet-build job.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: correct shim examples, obsolete messages, and doc claims

- Async XML examples: printfn, and Async.RunSynchronously (the shim
  file compiles only where FSharp.Core has no RunSynchronouslyImmediate).
- AsyncResult.ofTask/ofTaskAction obsolete message: Async.Await is the
  function that unwraps a single-inner AggregateException.
- getOrReraise.md: use Async.Await, Async.catch, and catchWith.
- SUMMARY.md: Result.ignore is not from FSharp.Core.
- jobResult/fromAsync.md: the example returns Ok.
- RELEASE_NOTES.md: the Result removals apply to all TFMs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: Async and Task removals are binary breaks on all TFMs

The shim modules hold map, bind, and ignore on every TFM. Each release
note now names its shim module and the TFMs where it is AutoOpen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: complete the JobResult.catchWith cancellation note

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(Task): ofValueTask on netstandard2.0

netstandard2.0 already gets the Async.Await ValueTask overloads and the
ValueTask module through Microsoft.Bcl.AsyncInterfaces. Task.ofValueTask
had a NETSTANDARD2_1 || NET guard, so netstandard2.0 did not get it.

- Remove the guard. This adds API only.
- Tests: completed, pending, and faulted value tasks.
- RELEASE_NOTES.md: the netstandard2.0 ValueTask surface, and the known
  Task.sequential difference on net11 until FSharp.Core ships
  dotnet/fsharp#20695 (#384).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Jimmy Byrd <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-reviewed PR reviewed by AI review council NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants