Skip to content

Fstoolkit shims - #20868

Draft
bartelink wants to merge 2 commits into
dotnet:mainfrom
bartelink:fstoolkit-shims
Draft

bartelink wants to merge 2 commits into
dotnet:mainfrom
bartelink:fstoolkit-shims

Conversation

@bartelink

@bartelink bartelink commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Testbed for FsToolkit-managed shims in demystifyfp/FsToolkit.ErrorHandling#373
NOT a PR for Fsharp.Core, though demystifyfp/FsToolkit.ErrorHandling#373 (comment) highlights some missing test coverage that this PR shold/will eventually address

bartelink added a commit to bartelink/FsToolkit.ErrorHandling that referenced this pull request Oct 26, 2026
NOTE introduces extra noise in stacktrace relative to previous impl
See also: dotnet/fsharp#20868
bartelink added a commit to bartelink/FsToolkit.ErrorHandling that referenced this pull request Oct 26, 2026
NOTE introduces extra noise in stacktrace relative to previous impl
See also: dotnet/fsharp#20868
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]>

This branch has not been deployed

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

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant