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
5 changes: 5 additions & 0 deletions dotnet/src/Generated/SessionEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// AUTO-GENERATED FILE - DO NOT EDIT
// Generated from: session-events.schema.json

using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Serialization;

Expand All @@ -13,6 +14,7 @@ namespace GitHub.Copilot.SDK;
/// <summary>
/// Provides the base class from which all session events derive.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
[JsonPolymorphic(
TypeDiscriminatorPropertyName = "type",
UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FailSerialization)]
Expand Down Expand Up @@ -107,6 +109,9 @@ public static SessionEvent FromJson(string json) =>
/// <summary>Serializes this event to a JSON string.</summary>
public string ToJson() =>
JsonSerializer.Serialize(this, SessionEventsJsonContext.Default.SessionEvent);

[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplay => ToJson();
}

/// <summary>Represents the <c>session.start</c> event.</summary>
Expand Down
6 changes: 5 additions & 1 deletion scripts/codegen/csharp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ function generateSessionEventsCode(schema: JSONSchema7): string {
// AUTO-GENERATED FILE - DO NOT EDIT
// Generated from: session-events.schema.json
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Serialization;
Expand All @@ -519,6 +520,7 @@ namespace GitHub.Copilot.SDK;
lines.push(`/// <summary>`);
lines.push(`/// Provides the base class from which all session events derive.`);
lines.push(`/// </summary>`);
lines.push(`[DebuggerDisplay("{DebuggerDisplay,nq}")]`);
lines.push(`[JsonPolymorphic(`, ` TypeDiscriminatorPropertyName = "type",`, ` UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FailSerialization)]`);
for (const variant of [...variants].sort((a, b) => a.typeName.localeCompare(b.typeName))) {
lines.push(`[JsonDerivedType(typeof(${variant.className}), "${variant.typeName}")]`);
Expand All @@ -537,7 +539,9 @@ namespace GitHub.Copilot.SDK;
lines.push(` /// <summary>Deserializes a JSON string into a <see cref="SessionEvent"/>.</summary>`);
lines.push(` public static SessionEvent FromJson(string json) =>`, ` JsonSerializer.Deserialize(json, SessionEventsJsonContext.Default.SessionEvent)!;`, "");
lines.push(` /// <summary>Serializes this event to a JSON string.</summary>`);
lines.push(` public string ToJson() =>`, ` JsonSerializer.Serialize(this, SessionEventsJsonContext.Default.SessionEvent);`, `}`, "");
lines.push(` public string ToJson() =>`, ` JsonSerializer.Serialize(this, SessionEventsJsonContext.Default.SessionEvent);`, "");
lines.push(` [DebuggerBrowsable(DebuggerBrowsableState.Never)]`, ` private string DebuggerDisplay => ToJson();`);
lines.push(`}`, "");

// Event classes with XML docs
for (const variant of variants) {
Expand Down
Loading