microsoft / microsoft/agent-host-protocol

.NET client: support trimming and Native AOT

Open
#410 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
344
Forks
122
Avg merge
14h 12m
Merged PRs (30d)
22

Description

Summary

Make the first-party .NET client introduced in #206 trimming-safe and compatible with Native AOT.

Current limitation

The current JSON path relies on runtime reflection:

  • SystemTextJsonAhpSerializer uses reflection-based System.Text.Json serialization.
  • UnionConverter<T> resolves and deserializes runtime variant types.
  • WireEnumConverter<T> reflects over enum fields and WireValueAttribute metadata.
  • Public serializer APIs are marked with RequiresUnreferencedCode and RequiresDynamicCode.
  • The packages intentionally do not claim IsTrimmable or IsAotCompatible.

Proposed work

  • Generate or maintain a JsonSerializerContext covering the complete generated protocol surface and hand-written envelope types.
  • Update SystemTextJsonAhpSerializer to use generated JsonTypeInfo metadata.
  • Replace reflection-based union and wire-enum lookup with generated/static metadata.
  • Preserve unknown discriminants and wire values exactly as required by the protocol.
  • Remove RequiresUnreferencedCode / RequiresDynamicCode from supported public paths.
  • Set appropriate package compatibility properties (IsTrimmable / IsAotCompatible) once validated.
  • Add CI coverage that publishes and runs a representative client with trimming and Native AOT enabled.

Acceptance criteria

  • dotnet publish succeeds for a representative client with PublishAot=true and no AHP-originated trim/AOT warnings.
  • Existing reducer and round-trip fixtures remain green.
  • Unknown union discriminants continue to round-trip verbatim.
  • Both netstandard2.0 and net8.0 package targets continue to build.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with SystemTextJsonAhpSerializer, UnionConverter, and WireEnumConverter; trace the generated protocol and hand-written envelope types they cover. Run the existing reducer and round-trip fixtures, then publish a representative client with PublishAot=true for the netstandard2.0 and net8.0 targets. Done means no AHP-originated trim/AOT warnings, unknown values round-trip, and both targets build.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, build-system, ci-cd
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.