Skip to content

Commit 81847a8

Browse files
authored
Add DebuggerDisplay for DataContent (#5618)
1 parent 148e221 commit 81847a8

File tree

1 file changed

+13
-0
lines changed
  • src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents

1 file changed

+13
-0
lines changed

src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataContent.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace Microsoft.Extensions.AI;
2525
/// a <see cref="ReadOnlyMemory{T}"/>. In that case, a data URI will be constructed and returned.
2626
/// </para>
2727
/// </remarks>
28+
[DebuggerDisplay("{DebuggerDisplay,nq}")]
2829
public class DataContent : AIContent
2930
{
3031
// Design note:
@@ -193,4 +194,16 @@ public ReadOnlyMemory<byte>? Data
193194
return _data;
194195
}
195196
}
197+
198+
/// <summary>Gets a string representing this instance to display in the debugger.</summary>
199+
private string DebuggerDisplay
200+
{
201+
get
202+
{
203+
const int MaxLength = 80;
204+
205+
string uri = Uri;
206+
return uri.Length <= MaxLength ? uri : $"{uri.Substring(0, MaxLength)}...";
207+
}
208+
}
196209
}

0 commit comments

Comments
 (0)