Prevent direction-aware JSON generation from inflating large SDKs
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 92
- Forks
- 8
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 4
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing --direction-aware-json-generation-mode through the generated OpenAPI source tree and its context registrations. Add the large request/response graph fixture, then run clean Release and fully trimmed consumer comparisons with the option enabled and disabled. Done means size does not materially regress, request serialization and response deserialization smokes pass, and a regression threshold is recorded.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, openapi
- Domain
- performance, testing, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100