From 53ef3bb272126385555c42c4d1ea2bc0db0ff24f Mon Sep 17 00:00:00 2001 From: Encryptoid Date: Sun, 26 Apr 2026 16:44:22 +0100 Subject: [PATCH] fix(dotnet): Add AOT-safe `SetForegroundSessionRequest` for `SetForegroundSessionIdAsync()` - Replace the anonymous `new { sessionId }` with `new SetForegroundSessionRequest(sessionId)` This fixes the runtime `System.Text.Json` metadata failure when `SetForegroundSessionIdAsync()` is used with source-generated serialization. --- dotnet/src/Client.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dotnet/src/Client.cs b/dotnet/src/Client.cs index 8e4d1eefb..c1fa14f81 100644 --- a/dotnet/src/Client.cs +++ b/dotnet/src/Client.cs @@ -942,7 +942,7 @@ public async Task SetForegroundSessionIdAsync(string sessionId, CancellationToke var connection = await EnsureConnectedAsync(cancellationToken); var response = await InvokeRpcAsync( - connection.Rpc, "session.setForeground", [new { sessionId }], cancellationToken); + connection.Rpc, "session.setForeground", [new SetForegroundSessionRequest(sessionId)], cancellationToken); if (!response.Success) { @@ -1753,6 +1753,9 @@ internal record GetSessionMetadataRequest( internal record GetSessionMetadataResponse( SessionMetadata? Session); + internal record SetForegroundSessionRequest( + string SessionId); + internal record UserInputRequestResponse( string Answer, bool WasFreeform); @@ -1871,6 +1874,7 @@ private static LogLevel MapLevel(TraceEventType eventType) [JsonSerializable(typeof(SessionCapabilities))] [JsonSerializable(typeof(SessionUiCapabilities))] [JsonSerializable(typeof(SessionMetadata))] + [JsonSerializable(typeof(SetForegroundSessionRequest))] [JsonSerializable(typeof(SystemMessageConfig))] [JsonSerializable(typeof(SystemMessageTransformRpcResponse))] [JsonSerializable(typeof(CommandWireDefinition))]