Add DebuggerDisplay attributes to Protocol types (#1068)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> Co-authored-by: Stephen Halter <halter73@gmail.com>
This commit is contained in:
parent
970207989e
commit
1b52ddacba
1 changed files with 175 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
|
||||
namespace ModelContextProtocol.Protocol;
|
||||
|
||||
/// <summary>
|
||||
/// Internal helper methods for DebuggerDisplay implementations.
|
||||
/// </summary>
|
||||
internal static class DebuggerDisplayHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the decoded length of base64 data for debugger display.
|
||||
/// </summary>
|
||||
internal static string GetBase64LengthDisplay(string base64Data)
|
||||
{
|
||||
#if NET
|
||||
if (System.Buffers.Text.Base64.IsValid(base64Data, out int decodedLength))
|
||||
{
|
||||
return $"{decodedLength} bytes";
|
||||
}
|
||||
#else
|
||||
try
|
||||
{
|
||||
return $"{Convert.FromBase64String(base64Data).Length} bytes";
|
||||
}
|
||||
catch { }
|
||||
#endif
|
||||
|
||||
return "invalid base64";
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue