Skip to content

refactor(serialization): unify default object activation - #11390

Merged
ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-runtime-path-simplification
Oct 2, 2026
Merged

ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-runtime-path-simplification

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Problem

#11369 introduced separate default object activation paths: an emitted constructor delegate on JIT runtimes and generic construction on NativeAOT. Both paths implement the same constructor-selection and exception contract.

Solution

Move creation into the common DefaultActivator<T> implementation. Cache whether T has a public parameterless constructor, invoke it using Activator.CreateInstance<T>(), and allocate an uninitialized object for constructor-bypass types. The existing reference/value activator types continue to provide the constrained registration surfaces.

Normalize the single runtime-generated TargetInvocationException wrapper using ExceptionDispatchInfo. Constructor failures retain their original identity, inner exception, and stack trace, including constructor-thrown TargetInvocationException values with or without an inner exception. Extend the existing managed tests and centralized native Activation smoke scenario to complete that exception matrix, and update the implementation documentation.

Rationale

CoreCLR's generic activation implementation in .NET 8 and .NET 10, and .NET 10 NativeAOT's generic construction intrinsic, wrap constructor failures once. This guarantee supports the same exception normalization across runtimes while each runtime supplies its constructor and allocator implementation.

The shared path favors implementation consistency over the emitted delegate's microoptimization. Public APIs, constructor-preservation annotations, and supported target frameworks remain unchanged. NativeAOT coverage targets .NET 10; managed compatibility retains .NET 8.

Microsoft Reviewers: Open in CodeFlow

Copilot AI balanced review requested due to automatic review settings October 2, 2026 18:40

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.

Copilot review overview

🟢 Approval recommended

The implementation preserves constructor-selection semantics and comprehensively tests exception identity across supported activation paths.

Review effort: Balanced
Findings: None

What changed in this PR

Unifies default serializer activation across JIT and NativeAOT runtimes.

Changes:

  • Centralizes constructor selection, activation, and exception unwrapping.
  • Expands managed and NativeAOT exception-preservation coverage.
  • Updates activation documentation.
File Description
src/​Orleans.Serialization/​Activators/​DefaultActivator.cs Implements unified activation.
test/​Orleans.Serialization.UnitTests/​DefaultActivatorTests.cs Expands managed tests.
test/​Orleans.NativeAotSmoke/​Activation.cs Expands NativeAOT smoke coverage.
docs/​site/​src/​content/​docs/​implementation/​serialization.md Documents unified behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI balanced review requested due to automatic review settings October 2, 2026 18:47

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.

Copilot review overview

🟢 Approval recommended

The implementation preserves existing activation semantics and comprehensively tests the expanded exception matrix.

Review effort: Balanced
Findings: None

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request
Lines 82.95% (115,587 / 139,350)
Branches 72.28% (33,594 / 46,477)

Report-only conclusion: current-main baseline stale.

The newest successful coverage run tested 6bf11ad, not current main 9bb744a.

Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities.

The comparison remains report-only while normal line and branch variance is calibrated.

Coverage details

@ReubenBond
ReubenBond merged commit a1a4676 into dotnet:main Oct 2, 2026
86 checks passed
@ReubenBond
ReubenBond deleted the rb-runtime-path-simplification branch October 2, 2026 21:48
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.

2 participants