Skip to content

Commit e41dece

Browse files
Copilotstephentoub
andcommitted
Add DebuggerDisplay to SamplingMessage and Icon types
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
1 parent e0e0f0e commit e41dece

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/ModelContextProtocol.Core/Protocol/Icon.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Diagnostics;
12
using System.Text.Json.Serialization;
23

34
namespace ModelContextProtocol.Protocol;
@@ -28,6 +29,7 @@ namespace ModelContextProtocol.Protocol;
2829
/// See the <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">schema</see> for details.
2930
/// </para>
3031
/// </remarks>
32+
[DebuggerDisplay("{DebuggerDisplay,nq}")]
3133
public sealed class Icon
3234
{
3335
/// <summary>
@@ -82,4 +84,14 @@ public sealed class Icon
8284
/// </remarks>
8385
[JsonPropertyName("theme")]
8486
public string? Theme { get; set; }
87+
88+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
89+
private string DebuggerDisplay
90+
{
91+
get
92+
{
93+
string mimeInfo = MimeType is not null ? $", MimeType = {MimeType}" : "";
94+
return $"Source = {Source}{mimeInfo}";
95+
}
96+
}
8597
}

src/ModelContextProtocol.Core/Protocol/SamplingMessage.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Diagnostics;
12
using System.Text.Json.Nodes;
23
using System.Text.Json.Serialization;
34

@@ -26,6 +27,7 @@ namespace ModelContextProtocol.Protocol;
2627
/// See the <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">schema</see> for details.
2728
/// </para>
2829
/// </remarks>
30+
[DebuggerDisplay("{DebuggerDisplay,nq}")]
2931
public sealed class SamplingMessage
3032
{
3133
/// <summary>
@@ -49,4 +51,16 @@ public sealed class SamplingMessage
4951
/// </remarks>
5052
[JsonPropertyName("_meta")]
5153
public JsonObject? Meta { get; set; }
54+
55+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
56+
private string DebuggerDisplay
57+
{
58+
get
59+
{
60+
string contentTypes = Content.Count == 1
61+
? Content[0].Type
62+
: $"{Content.Count} items";
63+
return $"Role = {Role}, Content = {contentTypes}";
64+
}
65+
}
5266
}

0 commit comments

Comments
 (0)