-
Notifications
You must be signed in to change notification settings - Fork 701
Make the .NET library NativeAOT compatible #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Updates the .NET SDK to be NativeAOT-friendly by removing reflection/anonymous-type usage in JSON paths and introducing System.Text.Json source generation for RPC + model types.
Changes:
- Switch RPC + model serialization to STJ source-generated contexts and remove anonymous request objects.
- Regenerate session event types with file-scoped namespace + source-gen
JsonSerializerContext. - Update tests to disable STJ reflection and add test-only serializer contexts; bump StreamJsonRpc.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| nodejs/scripts/generate-csharp-session-types.ts | Updates the C# session-types generator to emit file-scoped namespace output and a source-gen JsonSerializerContext. |
| dotnet/test/ToolsTests.cs | Passes explicit serializer options for tool invocation and adds a test JsonSerializerContext. |
| dotnet/test/Harness/CapiProxy.cs | Replaces anonymous request payloads and switches HttpClient JSON calls to source-gen type info. |
| dotnet/test/GitHub.Copilot.SDK.Test.csproj | Disables reflection-based STJ serialization to validate NativeAOT compatibility in tests. |
| dotnet/src/Types.cs | Adds a TypesJsonContext with [JsonSerializable] entries for core SDK types (incl. Ping types). |
| dotnet/src/Session.cs | Removes anonymous RPC payloads and adds SessionJsonContext for request/response types. |
| dotnet/src/GitHub.Copilot.SDK.csproj | Marks the library as AOT compatible and updates StreamJsonRpc. |
| dotnet/src/Generated/SessionEvents.cs | Regenerated session events with file-scoped namespace and a source-gen context. |
| dotnet/src/Client.cs | Updates JsonRpc formatter setup for NativeAOT, removes attribute-based RPC target wiring, and adds trace forwarding to ILogger. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Enabled AOT analyzers - Disabled STJ reflection in the test project (to help vet NAOT correctness) - Use source generation for all types that may be serialized - Remove all use of anonymous types - Removed <autogenerated/> from the source generated code, as it was suppressing the analyzers - Added support for propagating StreamJsonRpc's tracing to the CopilotClient's ILogger. I used this for debugging and decided to leave it - Updated StreamJsonRpc to a newly published version on nuget to pick up NativeAOT fixes - Cleaned up some formatting in the session types generator, in particular using a file-scoped namespace and removing the top-level indentation
924ed04 to
bf6da25
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks great!
<autogenerated/>from the source generated code, as it was suppressing the analyzers