Skip to content

Serialization.V2: object elements inside collections are envelope-payload boundaries (stacked on #8521) - #8523

Closed
Aaronontheweb wants to merge 1 commit into
akkadotnet:feature/serialization-v2-generator-harnessfrom
Aaronontheweb:feature/serialization-v2-object-elements
Closed

Aaronontheweb wants to merge 1 commit into
akkadotnet:feature/serialization-v2-generator-harnessfrom
Aaronontheweb:feature/serialization-v2-object-elements

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Member

Summary

Part of #8384. Extends Decision 20 (OpenSpec design record) to collection elements: a supported collection whose element type is object or object? treats each element as an envelope-payload boundary, the same frame a property typed object gets since #8518. Closes the limitation that #8520 documented in the guide.

Stacked on #8521 (S1); the diff is one commit. It is independent of #8522 (S2) and rebases onto whichever lands first.

What changes

  • Extraction. An element typed object maps to the envelope-payload kind, nullable-aware, for every collection shape the generator supports: arrays, lists, read-only lists and collections, sets, immutable collections, and dictionary values. All of them funnel through one element-mapping routine, so there is no per-shape special case.
  • Emission. The three element emitters gain an envelope case that calls the same runtime helpers the property-level case calls, with the same nil framing for a nullable element and the same UnknownSize propagation for size. Every other element kind is byte-for-byte untouched.
  • Dictionary keys typed object stay rejected with AKKASG003, and the reason is in a code comment: a null key crashes a dictionary at run time, and an envelope payload is a fresh instance on read, so a round-tripped key has no stable identity for lookup.

Tests and snapshots

  • ObjectElementSpec, eight facts: round trips for List<object>, object[], Dictionary<string, object>, and ImmutableList<object> holding a message from the same serializer, a string, and an int; a nullable element holding null; SizeHint reporting UnknownSize when an element's serializer cannot size it; the nesting-depth guard reached through a collection element; and the AKKASG003 fact for Dictionary<object, string>.
  • Golden output gains one message with a List<object> field. The diff against the verified file is purely additive; every pre-existing line is unchanged. The model snapshot from S1 gains the same message.
  • A new wire snapshot, envelope-list-element-string-and-message, pins the bytes for a list holding a string and a message.
  • dotnet test src/core/Akka.Serialization.V2.Tests -c Release: 287 passed. Generator builds with warnings as errors. Akka.Remote builds.

OpenSpec

Scenario "Object elements inside a collection are boundaries" added under the envelope-boundary requirement in the source-generator spec; task 5.17 added.

Follow-up

The guide's supported-types table and limitations section list this as unsupported since #8520. A one-line docs change lands after this merges.

…load boundaries

Extends Decision 20 (an object-typed property is always the envelope-payload
boundary) to collection elements: a List<object>, object[], or any other
natively-supported collection whose element type is object (or object?) now
treats each element as its own envelope-payload boundary, using the same
WriteEnvelopePayload/ReadEnvelopePayload/SizeOfEnvelopePayload runtime helpers
and nil framing a field already uses. Dictionary values typed object are
supported the same way; a dictionary KEY typed object is rejected with
AKKASG003 instead, since a round-tripped envelope payload has no stable
identity for hash/equality lookups and a nullable object? key would crash
Dictionary<TKey,TValue> at runtime.
@Aaronontheweb Aaronontheweb added serialization akka.net v1.6 Akka.NET v1.6-related issues labels Sep 9, 2026
@Aaronontheweb

Copy link
Copy Markdown
Member Author

Closing: this change is being reopened as part of a native GitHub stack with all branches in akkadotnet/akka.net (stacks cannot span a fork). Same commits, same content; the new PR will link back here.

@Aaronontheweb
Aaronontheweb deleted the feature/serialization-v2-object-elements branch September 9, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

akka.net v1.6 Akka.NET v1.6-related issues serialization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant