Skip to content

Prevent direction-aware JSON generation from inflating large SDKs #389

Description

@HavenDV

Summary

--direction-aware-json-generation-mode substantially increases both the Release assembly and the fully trimmed publish size for Apple's large App Store Connect specification, even though the option is intended to emit the narrowest safe source-generation mode for each reachable type.

Reproduction

Environment:

  • AutoSDK CLI 0.32.0+7ef4ef90a870ea4c953794f8a83e6ecff4ce87a3
  • .NET 10
  • Apple App Store Connect OpenAPI 4.4.1
  • 966 paths / 1,263 operations / 1,393 schemas
  • same generated SDK flags in both runs except for --direction-aware-json-generation-mode

Common flags include bearer security override, generated HTTP exception hierarchy, retry defaults, pageable helpers, and status-polling detection.

Clean Release build and minimal trimmed consumer results:

Configuration Release SDK DLL Trimmed SDK DLL retained by one BuildsClient operation Self-contained osx-arm64 publish
without direction-aware mode 159 MB 121 MB 201 MB
with direction-aware mode 176 MB 137 MB 216 MB

The comparison was repeated after dotnet clean to rule out stale System.Text.Json source-generator output. The generated OpenAPI source tree is otherwise the same size; the direction-aware context adds explicit GenerationMode = JsonSourceGenerationMode.Metadata registrations broadly across the context.

The overall inability to tree-shake unrelated context shards is tracked separately in #386. This issue is specifically the additional ~15-17 MB regression caused by direction-aware mode.

Expected behavior

Direction-aware mode should reduce or at least not materially increase generated serializer metadata when it drops unused fast-path serialization for response-only types.

Acceptance criteria

  • Add a large request/response graph fixture with response-only, request-only, and bidirectional types.
  • Compare clean Release assembly size and a fully trimmed consumer with the option on and off.
  • Avoid broad explicit metadata registrations that cost more than the default source-generation mode.
  • Preserve request serialization and response deserialization runtime smokes for every selected direction.
  • Add a size/regression threshold so a future generator change cannot silently reintroduce the expansion.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions