Skip to content

Enable EnablePreviewFeatures and runtime-async=on across the repo - #38442

Merged
AndriySvyryd merged 2 commits into
mainfrom
copilot/enable-preview-features-for-all-projects
Jun 17, 2026
Merged

AndriySvyryd merged 2 commits into
mainfrom
copilot/enable-preview-features-for-all-projects

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Turn on the .NET 11 runtime-async compiler feature (and the prerequisite EnablePreviewFeatures) for every project, letting the runtime emit await continuations directly instead of compiler-generated state machines.

Changes

  • Directory.Build.props — set both properties, scoped to $(DefaultNetCoreTargetFramework):

    <EnablePreviewFeatures Condition="'$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)'">true</EnablePreviewFeatures>
    <Features Condition="'$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)'">$(Features);runtime-async=on</Features>

    TFM scoping is required because the older-TFM legs of Microsoft.Data.Sqlite.Core, EFCore.Tasks, and ef (net10.0 / netstandard2.0) fail with CA2252 + SYSLIB5007 — EnablePreviewFeatures only suppresses those on IsNetCoreAppTargetingLatestTFM, and runtime-async lowers await to AsyncHelpers.Await, which is still preview on net10.0.

  • src/Directory.Build.props — prepend $(Features); so the inherited list is preserved instead of being overwritten:

    <Features>$(Features);nullablePublicOnly;strict</Features>

    Without this, every src/ project silently dropped runtime-async=on.

Findings

Full unit-test pass on the runtime solution (~12.5K tests). The 6 pre-existing EFCore.Design.Tests Linux/SQL failures are unchanged.

Shipping NuGet sizes, baseline vs modified (built from EFCore.Runtime.slnf):

Package Δ
EFCore −1.47%
EFCore.Relational −3.48%
EFCore.Cosmos −2.24%
EFCore.SqlServer −1.30%
EFCore.InMemory −0.45%
EFCore.Relational.Specification.Tests −27.48%
EFCore.Specification.Tests −15.44%
Total shipping nupkg −11.33% (−1.05 MB)

Abstractions/Analyzers are unchanged (non-latest TFM, no async). Design/Proxies/HierarchyId/NTS move by +0.02–0.08% — the [RequiresPreviewFeatures] assembly attribute outweighing minimal async savings in those projects.

IL-level view of Microsoft.EntityFrameworkCore.dll:

Metric Baseline Modified
Size 2,883,072 2,829,824 (−1.85%)
Types 1,997 1,943 (−54)
Async state-machine types 75 29 (−46)
[AsyncStateMachine] attributes 54 0

The 29 remaining state machines are async iterators and other forms not covered by runtime-async.

Benchmarks were not run — EF's BDN suite needs a live DB and a meaningful A/B takes hours; this should go through the standard benchmarking pipeline. Given zero compiler state machines remain for Task/ValueTask async methods, expect modest throughput gains and reduced GC pressure on async-heavy paths (SaveChangesAsync, async query enumeration, FirstAsync/SingleAsync).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 enables .NET preview compilation features needed to turn on the runtime-async=on compiler feature across the repository (scoped to the repo’s latest TFM), and ensures the Features property is composed rather than overwritten under src/.

Changes:

  • Enable EnablePreviewFeatures and append runtime-async=on to Features for $(DefaultNetCoreTargetFramework).
  • Preserve inherited $(Features) in src/Directory.Build.props when adding nullablePublicOnly;strict.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Directory.Build.props Conditionally enables preview features and runtime-async=on for the default/current TFM.
src/Directory.Build.props Preserves inherited Features while adding nullablePublicOnly;strict under src/.

Comment thread Directory.Build.props Resolved
Copilot AI requested a review from AndriySvyryd June 17, 2026 20:45
@AndriySvyryd
AndriySvyryd marked this pull request as ready for review June 17, 2026 21:23
@AndriySvyryd
AndriySvyryd requested a review from wtgodbe as a code owner June 17, 2026 21:23
Copilot AI review requested due to automatic review settings June 17, 2026 21:23
@AndriySvyryd
AndriySvyryd enabled auto-merge (squash) June 17, 2026 21:23
@AndriySvyryd
AndriySvyryd requested a review from SamMonoRT June 17, 2026 21:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@wtgodbe wtgodbe 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.

I think this is safe given everything ships as a package only

@AndriySvyryd
AndriySvyryd merged commit 8ae30ba into main Jun 17, 2026
14 checks passed
@AndriySvyryd
AndriySvyryd deleted the copilot/enable-preview-features-for-all-projects branch June 17, 2026 21:46
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants