Skip to content

Commit 2e8bab9

Browse files
Fixes
1 parent 24b8b28 commit 2e8bab9

4 files changed

Lines changed: 41 additions & 0 deletions

File tree

dotnet/src/Client.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,7 @@ private static JsonSerializerOptions CreateSerializerOptions()
10801080
options.TypeInfoResolverChain.Add(TypesJsonContext.Default);
10811081
options.TypeInfoResolverChain.Add(CopilotSession.SessionJsonContext.Default);
10821082
options.TypeInfoResolverChain.Add(SessionEventsJsonContext.Default);
1083+
options.TypeInfoResolverChain.Add(SDK.Rpc.RpcJsonContext.Default);
10831084

10841085
options.MakeReadOnly();
10851086

dotnet/src/Generated/Rpc.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// AUTO-GENERATED FILE - DO NOT EDIT
66
// Generated from: api.schema.json
77

8+
using System.Text.Json;
89
using System.Text.Json.Serialization;
910
using StreamJsonRpc;
1011

@@ -338,3 +339,27 @@ public async Task<SessionModelSwitchToResult> SwitchToAsync(string modelId, Canc
338339
return await CopilotClient.InvokeRpcAsync<SessionModelSwitchToResult>(_rpc, "session.model.switchTo", [request], cancellationToken);
339340
}
340341
}
342+
343+
[JsonSourceGenerationOptions(
344+
JsonSerializerDefaults.Web,
345+
AllowOutOfOrderMetadataProperties = true,
346+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
347+
[JsonSerializable(typeof(AccountGetQuotaResult))]
348+
[JsonSerializable(typeof(AccountGetQuotaResultQuotaSnapshotsValue))]
349+
[JsonSerializable(typeof(GetCurrentRequest))]
350+
[JsonSerializable(typeof(ListRequest))]
351+
[JsonSerializable(typeof(Model))]
352+
[JsonSerializable(typeof(ModelBilling))]
353+
[JsonSerializable(typeof(ModelCapabilities))]
354+
[JsonSerializable(typeof(ModelCapabilitiesLimits))]
355+
[JsonSerializable(typeof(ModelCapabilitiesSupports))]
356+
[JsonSerializable(typeof(ModelPolicy))]
357+
[JsonSerializable(typeof(ModelsListResult))]
358+
[JsonSerializable(typeof(PingRequest))]
359+
[JsonSerializable(typeof(PingResult))]
360+
[JsonSerializable(typeof(SessionModelGetCurrentResult))]
361+
[JsonSerializable(typeof(SessionModelSwitchToResult))]
362+
[JsonSerializable(typeof(SwitchToRequest))]
363+
[JsonSerializable(typeof(Tool))]
364+
[JsonSerializable(typeof(ToolsListResult))]
365+
internal partial class RpcJsonContext : JsonSerializerContext;

dotnet/test/RpcTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class RpcTests(E2ETestFixture fixture, ITestOutputHelper output) : E2ETes
1313
[Fact]
1414
public async Task Should_Call_Rpc_Ping_With_Typed_Params_And_Result()
1515
{
16+
await Client.StartAsync();
1617
var result = await Client.Rpc.PingAsync(message: "typed rpc test");
1718
Assert.Equal("pong: typed rpc test", result.Message);
1819
Assert.True(result.Timestamp >= 0);
@@ -21,6 +22,7 @@ public async Task Should_Call_Rpc_Ping_With_Typed_Params_And_Result()
2122
[Fact]
2223
public async Task Should_Call_Rpc_Models_List_With_Typed_Result()
2324
{
25+
await Client.StartAsync();
2426
var authStatus = await Client.GetAuthStatusAsync();
2527
if (!authStatus.IsAuthenticated)
2628
{
@@ -36,6 +38,7 @@ public async Task Should_Call_Rpc_Models_List_With_Typed_Result()
3638
[Fact(Skip = "account.getQuota not yet implemented in CLI")]
3739
public async Task Should_Call_Rpc_Account_GetQuota_When_Authenticated()
3840
{
41+
await Client.StartAsync();
3942
var authStatus = await Client.GetAuthStatusAsync();
4043
if (!authStatus.IsAuthenticated)
4144
{

scripts/codegen/csharp.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ function generateRpcCode(schema: ApiSchema): string {
712712
// AUTO-GENERATED FILE - DO NOT EDIT
713713
// Generated from: api.schema.json
714714
715+
using System.Text.Json;
715716
using System.Text.Json.Serialization;
716717
using StreamJsonRpc;
717718
@@ -722,6 +723,17 @@ namespace GitHub.Copilot.SDK.Rpc;
722723
for (const part of serverRpcParts) lines.push(part, "");
723724
for (const part of sessionRpcParts) lines.push(part, "");
724725

726+
// Add JsonSerializerContext for AOT/trimming support
727+
const typeNames = [...emittedRpcClasses].sort();
728+
if (typeNames.length > 0) {
729+
lines.push(`[JsonSourceGenerationOptions(`);
730+
lines.push(` JsonSerializerDefaults.Web,`);
731+
lines.push(` AllowOutOfOrderMetadataProperties = true,`);
732+
lines.push(` DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]`);
733+
for (const t of typeNames) lines.push(`[JsonSerializable(typeof(${t}))]`);
734+
lines.push(`internal partial class RpcJsonContext : JsonSerializerContext;`);
735+
}
736+
725737
return lines.join("\n");
726738
}
727739

0 commit comments

Comments
 (0)