Skip to content

Ship FSharp.Core with a net10.0 target framework - #20229

Merged
T-Gro merged 38 commits into
mainfrom
t-gro-fsharpcore-net10-tfm-plan
Aug 17, 2026
Merged

Ship FSharp.Core with a net10.0 target framework#20229
T-Gro merged 38 commits into
mainfrom
t-gro-fsharpcore-net10-tfm-plan

Conversation

@T-Gro

@T-GroT-Gro commented Aug 7, 2026

Copy link
Copy Markdown
Member

Ships FSharp.Core with an additional net10.0 target framework alongside netstandard2.0 and netstandard2.1. External .NET consumers resolve the net10.0 asset through normal nearest-TFM resolution instead of falling back to netstandard2.1.

The net version is a pinned knob (FSharpCoreShippedNetTargetFramework, default net10.0) that deliberately lags the in-development product TFM: F# built on net11 still ships lib/net10.0, and the pin moves only as an explicit, reviewed step when the product advances. Proto stays a single netstandard2.0 bootstrap; the extra target is added to non-Proto builds only.

net10.0 is a package-only asset. In-repo .NET consumers stay pinned to the netstandard2.1 asset (a central Directory.Build.targets rule for direct references, plus one direct pin in FSharp.Compiler.Service.Tests whose reference is only transitive), so the in-box compiler, the tools, and their IL and surface-area baselines are unchanged by adding the target. Removing that pin makes the in-repo test harnesses compile against net10.0 FSharp.Core — whose split-BCL references don't resolve in those contexts — and churns every EmittedIL baseline, so the pin stays.

The point of a real net target is to let FSharp.Core grow net-specific API and behavior over time rather than stay pinned to the netstandard2.1 surface; today it is built from the same sources, and future net-only additions live behind the widened #if … || NET guards.

Not done here (cross-repo, must follow this PR): the shipped-in-SDK path flows dotnet/fsharp → dotnet/dotnet (VMR) → dotnet/sdk, and full source-build validation needs a real VMR leg (DotNetBuildFromVMR). Those cannot be exercised from this repo.

Draft: opening for CI signal and review of the pinned-TFM policy before finalizing.

T-Groand others added 12 commits August 6, 2026 14:57
…b (net10.0) + lag guard
The shipped FSharp.Core net TFM is a pinned-stable knob that lags the in-dev
product TFM (FSharpNetCoreProductTargetFramework=net11.0) and tracks the latest
stable released .NET. A build/pack-time guard scoped to the FSharp.Core project
fails if the pin is not strictly less than the product TFM.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add $(FSharpCoreShippedNetTargetFramework) (net10.0) to the non-Proto TFMs and
make FSharp.Core actually compile against the net10 BCL:
- prim-types.fs: move the #endif of the '#if !NET5_0_OR_GREATER' block so the
structural 'namespace Microsoft.FSharp.Core' + opens are unconditional (they
were trapped inside the pre-.NET5 polyfill guard and vanished on any net TFM,
causing ~100 'System type not defined' errors). ns2.x output is unchanged.
- prim-types.fsi: guard the System.Diagnostics.CodeAnalysis polyfill with the
matching '#if !NET5_0_OR_GREATER' so the signature drops it on net (the impl
already did), fixing the sig/impl mismatch (FS0193).
- prim-types.{fs,fsi}: floor the .NET8+ CollectionBuilder/ScopedRef polyfills
with '#if !NET8_0_OR_GREATER' (net BCL provides them).
- Widen collection-expression / IAsyncDisposable guards to '|| NET'
(set.{fs,fsi}, tasks.{fs,fsi}, prim-types.{fs,fsi} List builders).
- local.fs / Query.fs: disambiguate net10 BCL overloads
(String.Format ReadOnlySpan<obj>, ElementAt/Take Index/Range) by pinning the
original obj[]/int overloads. No public-surface change.
Builds clean on netstandard2.0, netstandard2.1 and net10.0 (no warnings).
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- FSharp.Core.nuspec: add a net10.0 dependency group and lib/net10.0 file
entries (dll, xml, satellite resources), all driven by a
$FSharpCoreShippedNetTargetFramework$ token so the package layout tracks the
single pinned knob rather than hardcoding the TFM in the manifest.
- FSharp.Core.fsproj: surface the knob to the nuspec via
<NuspecProperty Include="FSharpCoreShippedNetTargetFramework=..."> (non-Proto).
- Microsoft.FSharp.Compiler.fsproj: include the pinned TFM in the shipping-path
pack override so the shipped FSharp.Core is packed for net10.0 too, not just
netstandard2.0/2.1.
Verified via Arcade pack: nupkg contains lib/{netstandard2.0,netstandard2.1,net10.0}
with dll+xml+satellites and a <group targetFramework="net10.0" /> dependency group.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Modern .NET hosts (net11+) now bind lib/net10.0, so the SurfaceArea test
must verify against a net baseline (references System.Runtime, not
netstandard). Reorder platform detection to '#if NET' first, add
FSharp.Core.SurfaceArea.net.{debug,release}.bsl, and document that the
netstandard2.1 baselines are intentionally retained but no longer
exercised (ns2.1 coverage moves to the ApiCompat identity gate).
The net member surface is byte-identical to ns2.1 (only assembly-
reference lines differ), confirming the net10.0 == ns2.1 invariant.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
Add a dedicated FSharp.Core.ApiCompat project that runs the SDK's
Microsoft.DotNet.ApiCompat.Task.ValidateAssembliesTask (registered by
Sdk.targets, not Arcade, not package validation) comparing the freshly
built netstandard2.1 (contract) and net10.0 implementation assemblies in
strict/bidirectional mode with an empty suppression set. This enforces
the net10.0 == netstandard2.1 public-surface invariant.
Wire it as a required, blocking FSharpCore_ApiCompat job (no
continueOnError) in azure-pipelines-PR.yml.
Verified locally: passes clean on identically-built DLLs; strict mode
correctly FAILS on injected additions (ns2.0-vs-net10), non-strict
silently passes them (why strict is mandated).
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
Allow-list audit of every TFM-discriminating #if/#elif guard in
src/FSharp.Core/**/*.{fs,fsi}: each must be a reviewed <file>:<expr>
pair, so a bare '#if NETSTANDARD2_1' (excludes the net TFM) or bare
'#if !NET' (drops a BCL polyfill on every net TFM) or any un-reviewed
new TFM guard fails.
Implemented as a portable F# fsx (git ls-files + .NET regex, not
'git grep -P' which needs PCRE) and wired as a blocking step in the
required CheckCodeFormatting job, matching the repo's FSCompCheck.fsx /
TestSplit.fsx source-hygiene idiom.
Verified: self-test OK; passes on the shipped tree (10 allow-listed
guards); FAILS on an injected bare '#if NETSTANDARD2_1'.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
…rifier
Portable fsx that discovers the shipped net TFM lib folder from the produced
FSharp.Core nupkg (never a hard-coded literal) and asserts lib/{netstandard2.0,
netstandard2.1,<pin>} DLL+XML present and non-degenerate, satellites present,
a <group targetFramework> dependency group in the nuspec, and a UNIFORM
AssemblyVersion across all three lib assemblies.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
Isolated net-TFM consumer (targets $(FSharpCoreShippedNetTargetFramework)) that
source-maps FSharp.Core to the locally built package and STRUCTURALLY witnesses,
from obj/project.assets.json, that both compile and runtime bind to
lib/<pin>/FSharp.Core.dll and NOT to any netstandard asset. Driver pins the exact
built version, purges only the cached fsharp.core/<ver>, and runs a widened
IAsyncDisposable task member as the runtime smoke (roll-forward for the net run).
Verified locally: net10.0 -> lib/net10.0 (compile+runtime) + smoke green;
net8.0 control -> lib/netstandard2.1 (witness bites).
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
Multi-target the AheadOfTime Trimming (x3) and NativeAOT consumers on
net9.0;$(FSharpCoreShippedNetTargetFramework) so the shipped net-TFM lib is
exercised under PublishTrimmed/PublishAot. The gate is publish SUCCESS under
TreatWarningsAsErrors=true (IL2xxx/IL3050 => errors); trimmed sizes for the net
pin are report-only (-expected_len -1) since byte counts churn per preview. Both
check.ps1 scripts derive the pin from the knob (no literal net10.0 to drift).
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
…nto PR pipeline
- e2e-1 runs in EndToEndBuildTests right after the -pack step.
- e2e-2 runs in Build_And_Test_AOT_Windows after the AheadOfTime checks, with the
consumer's project.assets.json published as always()/continueOnError failure
evidence.
e2e-5 (trim/AOT net-TFM legs) needs no new wiring: the existing AheadOfTime
check.ps1 chain already runs the multi-targeted projects.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
@github-actions

github-actionsBot commented Aug 7, 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 pathRelease notes pathDescription
`src/FSharp.Core`docs/release-notes/.FSharp.Core/11.0.100.md
`src/Compiler`docs/release-notes/.FSharp.Compiler.Service/11.0.100.md

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
@T-Gro

T-Gro commented Aug 7, 2026

Copy link
Copy Markdown
MemberAuthor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@T-Gro

T-Gro commented Aug 7, 2026

Copy link
Copy Markdown
MemberAuthor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@T-Gro

T-Gro commented Aug 7, 2026

Copy link
Copy Markdown
MemberAuthor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

…chronouslyImmediate
The merge from main introduced the new public member
Async.RunSynchronouslyImmediate. The dedicated net SurfaceArea baselines
(created before that merge) did not include it; regenerate both the debug
and release net baselines. The netstandard2.1 baseline already carried the
member via the merge, and the ApiCompat net10-vs-netstandard2.1 identity
gate still passes, so the surfaces remain identical.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
@T-Gro

T-Gro commented Aug 7, 2026

Copy link
Copy Markdown
MemberAuthor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

CopilotAI added 4 commits August 7, 2026 11:14
…ding (NoBloat)
Remove step-by-step and design-justification narration from the new e2e
scripts, the ApiCompat project, the #ifdef audit, and the SurfaceArea
platform-selection comment; keep only the non-obvious 'why' (the
ApiCompat-vs-package-validation trap, the macOS git-grep portability note,
the net<->baseline mapping invariant). No functional change; all gates
still pass locally.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
Drop the fsproj header that duplicated the driver script's intent and a
redundant inline comment in the runtime smoke. The remaining comments are
non-obvious MSBuild 'why' (CPM/RollForward/implicit-ref opt-outs). No
functional change; e2e-2 still passes.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
Removes an agent-plan breadcrumb (files/plan.md 4e) from the ApiCompat
proj header comment and a (Milestone B) phase tag from a
VerifyNetResolution.fsx error string, per NoBloat. No behavior change.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
…1 baseline
- VerifyFSharpCorePackage.fsx: checkAsset helper collapses the duplicated
dll/xml exists+size-floor assertions.
- VerifyNetResolution.fsx: close a fail-open in the structural witness
(empty dllPaths without _._ now fails).
- AuditFSharpCoreTfmGuards.fsx: self-test now drives the real tfmGuardsIn
extractor (was bypassing the #if/#elif line parser) + #elif coverage.
- SurfaceArea.fs: drop the unreachable #elif NETCOREAPP netstandard21 branch
(a modern host defines NET); delete the now-orphaned netstandard21 baselines
(ns2.1 surface is covered by the FSharp.Core.ApiCompat gate).
- Program.fs / ApiCompat proj / PR yaml: comment accuracy + trims.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dd0ca93f-cf73-450a-8a5a-f9e59841802e
@T-Gro
T-Gro requested review from abonie and baronfelAugust 12, 2026 17:44
@github-project-automationgithub-project-automationBot moved this from New to In Progress in F# Compiler and ToolingAug 12, 2026
@github-actionsgithub-actionsBot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label Aug 12, 2026
@T-GroT-Gro mentioned this pull request Aug 13, 2026
10 tasks
Route closure generic arguments through guarded type generation to prevent FS0073, and cover the shipped net10 FSharp.Core API, package assets, and IL verification.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8f25b087-cec7-4d86-a31a-f1f6f00ccf1a
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8f25b087-cec7-4d86-a31a-f1f6f00ccf1a
@kerams

Copy link
Copy Markdown
Contributor

A dream come true.

@T-Gro

Copy link
Copy Markdown
MemberAuthor

@kerams :

I will revisit places that have been waiting for this and write a pointer to this PR ;; offering if-def-based solutions for FSharp.Core evolution.

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

Labels

AI-Tooling-Check-BypassedTooling check: non-fork PR, not diff-analyzed

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants

@T-Gro@vzarytovskii@baronfel@kerams@abonie