Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions dotnet/src/Generated/Rpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public class ModelCapabilitiesLimits
public class ModelCapabilities
{
[JsonPropertyName("supports")]
public ModelCapabilitiesSupports Supports { get; set; } = new();
public ModelCapabilitiesSupports Supports { get => field ??= new(); set; }

[JsonPropertyName("limits")]
public ModelCapabilitiesLimits Limits { get; set; } = new();
public ModelCapabilitiesLimits Limits { get => field ??= new(); set; }
}

/// <summary>Policy state (if applicable)</summary>
Expand Down Expand Up @@ -96,7 +96,7 @@ public class Model

/// <summary>Model capabilities and limits</summary>
[JsonPropertyName("capabilities")]
public ModelCapabilities Capabilities { get; set; } = new();
public ModelCapabilities Capabilities { get => field ??= new(); set; }

/// <summary>Policy state (if applicable)</summary>
[JsonPropertyName("policy")]
Expand All @@ -119,7 +119,7 @@ public class ModelsListResult
{
/// <summary>List of available models with full metadata</summary>
[JsonPropertyName("models")]
public List<Model> Models { get; set; } = [];
public List<Model> Models { get => field ??= []; set; }
}

public class Tool
Expand Down Expand Up @@ -149,7 +149,7 @@ public class ToolsListResult
{
/// <summary>List of available built-in tools with metadata</summary>
[JsonPropertyName("tools")]
public List<Tool> Tools { get; set; } = [];
public List<Tool> Tools { get => field ??= []; set; }
}

internal class ToolsListRequest
Expand Down Expand Up @@ -189,7 +189,7 @@ public class AccountGetQuotaResult
{
/// <summary>Quota snapshots keyed by type (e.g., chat, completions, premium_interactions)</summary>
[JsonPropertyName("quotaSnapshots")]
public Dictionary<string, AccountGetQuotaResultQuotaSnapshotsValue> QuotaSnapshots { get; set; } = [];
public Dictionary<string, AccountGetQuotaResultQuotaSnapshotsValue> QuotaSnapshots { get => field ??= []; set; }
}

public class SessionLogResult
Expand Down Expand Up @@ -321,7 +321,7 @@ public class SessionWorkspaceListFilesResult
{
/// <summary>Relative file paths in the workspace files directory</summary>
[JsonPropertyName("files")]
public List<string> Files { get; set; } = [];
public List<string> Files { get => field ??= []; set; }
}

internal class SessionWorkspaceListFilesRequest
Expand Down Expand Up @@ -397,7 +397,7 @@ public class SessionAgentListResult
{
/// <summary>Available custom agents</summary>
[JsonPropertyName("agents")]
public List<Agent> Agents { get; set; } = [];
public List<Agent> Agents { get => field ??= []; set; }
}

internal class SessionAgentListRequest
Expand Down Expand Up @@ -454,7 +454,7 @@ public class SessionAgentSelectResult
{
/// <summary>The newly selected custom agent</summary>
[JsonPropertyName("agent")]
public SessionAgentSelectResultAgent Agent { get; set; } = new();
public SessionAgentSelectResultAgent Agent { get => field ??= new(); set; }
}

internal class SessionAgentSelectRequest
Expand Down
10 changes: 7 additions & 3 deletions scripts/codegen/csharp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,13 +565,17 @@ function emitRpcClass(className: string, schema: JSONSchema7, visibility: "publi
lines.push(` [JsonPropertyName("${propName}")]`);

let defaultVal = "";
let propAccessors = "{ get; set; }";
if (isReq && !csharpType.endsWith("?")) {
if (csharpType === "string") defaultVal = " = string.Empty;";
else if (csharpType === "object") defaultVal = " = null!;";
else if (csharpType.startsWith("List<") || csharpType.startsWith("Dictionary<")) defaultVal = " = [];";
else if (emittedRpcClasses.has(csharpType)) defaultVal = " = new();";
else if (csharpType.startsWith("List<") || csharpType.startsWith("Dictionary<")) {
propAccessors = "{ get => field ??= []; set; }";
} else if (emittedRpcClasses.has(csharpType)) {
propAccessors = "{ get => field ??= new(); set; }";
}
}
lines.push(` public ${csharpType} ${csharpName} { get; set; }${defaultVal}`);
lines.push(` public ${csharpType} ${csharpName} ${propAccessors}${defaultVal}`);
if (i < props.length - 1) lines.push("");
}
lines.push(`}`);
Expand Down
Loading