Add DebuggerDisplay attributes to Protocol types#1068
Merged
stephentoub merged 9 commits intomainfrom Dec 5, 2025
Merged
Conversation
…ypes Co-authored-by: stephentoub <[email protected]>
Co-authored-by: stephentoub <[email protected]>
Copilot
AI
changed the title
[WIP] Add DebuggerDisplay and ToString for common types
Add DebuggerDisplay attributes to Protocol types
Dec 5, 2025
stephentoub
reviewed
Dec 5, 2025
stephentoub
reviewed
Dec 5, 2025
- Show MimeType and byte length instead of base64 data for binary content - Use string literals in DebuggerDisplay attribute where possible - Make ToolResultContentBlock display more dynamic (show result or error) - Show actual text content in PromptMessage when available Co-authored-by: stephentoub <[email protected]>
Show actual text when Content contains a single TextContentBlock, similar to PromptMessage Co-authored-by: stephentoub <[email protected]>
stephentoub
approved these changes
Dec 5, 2025
- Use proper base64 decoding with Base64.IsValid on NET or Convert.FromBase64String - Add helper method GetBase64LengthDisplay for consistent base64 length display - Use string literals in DebuggerDisplay attributes where possible - Put URIs in quotes for better readability - Use Text ?? "" and Uri ?? "" for null safety in ToString and DebuggerDisplay Co-authored-by: stephentoub <[email protected]>
stephentoub
approved these changes
Dec 5, 2025
- Move try/catch inside #else block for Base64 validation - Create DebuggerDisplayHelper internal class for shared base64 decoding logic - Simplify DebuggerDisplay attribute escaping (use \" instead of \\\") - Use DebuggerDisplayHelper in both ContentBlock types and BlobResourceContents Co-authored-by: stephentoub <[email protected]>
stephentoub
reviewed
Dec 5, 2025
src/ModelContextProtocol.Core/Protocol/DebuggerDisplayHelper.cs
Outdated
Show resolved
Hide resolved
Move the "invalid base64" return statement outside the #if/#else blocks to avoid duplication Co-authored-by: stephentoub <[email protected]>
halter73
reviewed
Dec 5, 2025
src/ModelContextProtocol.Core/Protocol/DebuggerDisplayHelper.cs
Outdated
Show resolved
Hide resolved
halter73
approved these changes
Dec 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plan: Add DebuggerDisplay Attributes to Protocol Types
[DebuggerDisplay]toContentBlockbase class and derived types:TextContentBlock- display text content preview (with null safety)ImageContentBlock- display mime type and proper decoded byte lengthAudioContentBlock- display mime type and proper decoded byte lengthEmbeddedResourceBlock- display resource URI in quotesResourceLinkBlock- display URI and name with URI in quotesToolUseContentBlock- display tool name and ID (using string literal)ToolResultContentBlock- dynamic display: show result content or error[DebuggerDisplay]toResourceContentsbase class and derived types:TextResourceContents- display URI and text (with proper quotes and null safety)BlobResourceContents- display URI, mime type, and proper decoded byte length[DebuggerDisplay]to other commonly used Protocol types:Tool- display name and descriptionPrompt- display name and descriptionResource- display name and URI (using string literal)PromptMessage- display role and text content when availableSamplingMessage- display role and text content when availableIcon- display source and mime type with source in quotesToString()override forTextContentBlock(represents text data, with null safety)ToString()override forTextResourceContents(represents text data, with null safety)DebuggerDisplayHelperinternal class for shared utilitiesOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.