Skip to content

AOT: route JsonUnicodeBodyConverter (SqlServiceBroker) through GetTypeInfo #515

Closed

Description

@Greven145

Goal

Give Chatter.MessageBrokers.SqlServiceBroker's JsonUnicodeBodyConverter a metadata-aware serialization path, following the pattern #509 establishes for the Chatter.MessageBrokers Body Converters.

Current state on master (verified at 7408c31)

src/Chatter.MessageBrokers.SqlServiceBroker/src/Chatter.MessageBrokers.SqlServiceBroker/JsonUnicodeBodyConverter.cs is 25 lines. Its serialization calls are:

  • line 10 — Convert<TBody>(byte[] body) returns ChatterJson.Deserialize<TBody>(Stringify(body)).
  • line 20 — Stringify(object body) returns ChatterJson.Serialize(body).

It has no constructor, takes no options, and has a parameterless default. It handles a UTF-16 payload (ContentType is "application/json; charset=utf-16"), with Encoding.Unicode for the byte conversions.

Corrections to earlier notes

Design constraint

Adding a public JsonSerializerOptions constructor parameter would make the serializer configuration a caller-facing surface, which src/Chatter.MessageBrokers/CONTEXT.md's Wire Serialization term explicitly warns against, and it would not even give this package access to Chatter's own options across the package boundary. The likely correct shape is to extend the published capability with a metadata-aware entry point that JsonUnicodeBodyConverter and RabbitMqBodyConverter both call, rather than to publish options on each converter. Resolve that question in #509 and apply the answer here.

Scope

Depends on #509 and, transitively, on #279 and #276.

Part of #275.

Activity

  1. Greven145 commented on Oct 1, 2026

    @Greven145
    Author

    Correction, same pattern as #510's correction. This body measures against brenpike/Chatter's master (7408c31), where none of this initiative has landed. On aotIntegration, the real branch:

    The "design constraint" section does not apply. Proceeding against aotIntegration's real state: mirror RabbitMqBodyConverter's already-merged shape directly.

  2. Greven145 commented on Oct 1, 2026

    @Greven145
    Author

    PR #21: Greven145#21

    Mirrored RabbitMqBodyConverter's already-merged shape exactly: GetTypeInfo + JsonTypeInfo overloads, RuntimeFeature.IsDynamicCodeSupported-conditional DI registration.

    Found and fixed a real bug beyond the converter itself: SqlServiceBrokerReceiver's envelope-converter fallback (new JsonUnicodeBodyConverter()) was a bare, eager construction that would throw under real Native AOT before the receiver's own try block runs, regardless of whether IBodyConverterFactory would have resolved correctly — the same "parameter added but never threaded through the real path" mistake the #510 review caught. Fixed via an optional JsonSerializerOptions on the receiver's constructor.

    Verified: 214/214 tests both TFMs (3 new). Real clean rebuild of all 9 modules: trim baseline 36 → 32, exactly 4 fixed, 0 new.

    Out of scope, stated in the PR: no AOT smoke-test coverage added (Chatter.Aot.Smoke.Tests doesn't reference this module at all — that's #429's job). SemVer on the two API additions flagged, not decided.

    CI running on the PR.

  3. Greven145 commented on Oct 1, 2026

    @Greven145
    Author

    Done. PR #21. Adversarial review found the headline bug was still live (OutboundBrokeredMessage missing from ChatterMessageBrokerJsonContext, silently corrupting envelope decode instead of throwing) — reproduced and fixed. Eager-throw-at-construction tension deliberately left as-is and documented; it's #516's exact scope.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions