Repository navigation
Support message types from referenced assemblies as nested fields and union members (F1) - #8534
Merged
Aaronontheweb merged 1 commit intoSep 11, 2026
Conversation
This was referenced Sep 9, 2026
Aaronontheweb
added this pull request to stack #8531
September 9, 2026 13:28
Aaronontheweb
force-pushed
the
feature/serialization-v2-metadata-schemas
branch
from
September 9, 2026 13:32
03b9da8 to
d20f28f
Compare
This was referenced Sep 9, 2026
Aaronontheweb
force-pushed
the
feature/serialization-v2-metadata-schemas
branch
from
September 9, 2026 17:15
d20f28f to
ecfce84
Compare
Aaronontheweb
force-pushed
the
feature/serialization-v2-metadata-schemas
branch
from
September 9, 2026 18:08
ecfce84 to
2b4ab8e
Compare
Aaronontheweb
force-pushed
the
feature/serialization-v2-metadata-schemas
branch
from
September 9, 2026 22:52
2b4ab8e to
74ca4c2
Compare
Aaronontheweb
force-pushed
the
feature/serialization-v2-metadata-schemas
branch
from
September 10, 2026 23:44
74ca4c2 to
7ecd49f
Compare
… (Decision 16) Adds a per-compilation metadata-schema stage (ComputeMetadataSchemas) that reads a nested field's or a union member's schema from a referenced assembly's compiled metadata, through the same ExtractMessageCore routine a local type uses. Fills the gap CrossAssemblyBaselineSpec pinned for those two cases; a closed generic's own definition already worked this way. Local declarations keep priority over a metadata schema on any key collision. Adds AKKASG039 for a referenced type that is [AkkaSerializable] but not accessible from the local compilation (or one of its own [AkkaField] properties, or a type it itself nests), reported at the local reference site with both the directly-named type and the actual failing type/member. Flips CrossAssemblyBaselineSpec's nested-field and union-member cases from a pinned failure to a pinned success and adds three AKKASG039 cases (a non-public property, an internal union member, and a failure one level down). Adds cross-assembly golden-output coverage proving the emitted helpers are byte-identical to the same declarations made locally, and two incremental-caching scenarios proving a metadata schema does not defeat caching for an edit it does not care about. Updates the user guide with a new Cross-Assembly Types section and records the implementation choices not covered by the design text as an addendum under Decision 16.
Aaronontheweb
force-pushed
the
feature/serialization-v2-metadata-schemas
branch
from
September 11, 2026 15:05
7ecd49f to
7848e9b
Compare
This was referenced Oct 2, 2026
Aaronontheweb
added a commit
that referenced
this pull request
Oct 2, 2026
…sted message types (#8721) Docs no longer say an object collection element is unsupported (#8528). AKKASG007 and AKKASG015 cross-assembly text no longer says the generator cannot read a schema from a referenced assembly (#8534, #8537). New AKKASG045 reports an [AkkaSerializable] type that is private or protected, or nested in one, instead of CS0122 in generated code. Closes #8717
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
A serializer can now use message types declared in a referenced assembly as nested field types and as union members. Before, both cases failed, and with the wrong diagnostic id. The design record is Decisions 16 to 21 in
openspec/changes/messagepack-sourcegen-validation/design.md.MetadataSchemas, finds the referenced types the local messages and serializers name, reads each one's[AkkaSerializable]and[AkkaField]attributes from metadata, and builds its schema with the same code local types use. The schema is identical to what the other assembly's own generator saw. It follows nested references breadth-first. Its output is a table of plain values keyed byTypeKey, and it feeds the resolve step directly.InternalsVisibleTo, or a property with a restricted getter. One limit is in the design record: Roslyn's metadata reader hides a member this compilation cannot see at all, so a wholly inaccessible property drops out of the schema silently. A restricted getter on a visible property is caught.Baseline cases
CrossAssemblyBaselineSpecpins six cross-assembly behaviors with diagrams. Cases 1 (nested field type) and 2 (union member) flip to success, and their diagrams are rewritten. The plan listed case 5 as a third flip; that was a numbering slip, since the generic-definition case already worked. Cases 3 to 6 stay for F2 and F3.Cost
Base is the S6 tip. The corpus has no referenced-assembly types, so every row should be flat, and it is. A first cut allocated up to 18 percent more on some rows because the reference walk was an iterator method, which allocates its state machine even when it yields nothing. It now writes into a reused set.
How it was checked
334 tests pass (327 plus 2 golden, 3 for AKKASG039, 2 caching scenarios). Generator and
Akka.Remotebuild with warnings as errors. No public API change. cspell passes on the guide.