Skip to content

feat: use overridden ToString for object variable display#227

Open
GustavEikaas wants to merge 1 commit into
Samsung:masterfrom
GustavEikaas:feat/to-string-pretty-print
Open

feat: use overridden ToString for object variable display#227
GustavEikaas wants to merge 1 commit into
Samsung:masterfrom
GustavEikaas:feat/to-string-pretty-print

Conversation

@GustavEikaas
Copy link
Copy Markdown

@GustavEikaas GustavEikaas commented May 28, 2026

As part of my effort to resolve #226 I have identified multiple smaller features needed.

This is the smallest one and a good addition to netcoredbg. In this page https://learn.microsoft.com/en-us/visualstudio/debugger/using-the-debuggerdisplay-attribute?view=visualstudio there is a section quoting

If a class has an overridden ToString() method, the debugger uses the overridden method instead of the default {<typeName>}.
In this case you don't have to use DebuggerDisplay.
If you use both, the DebuggerDisplay attribute takes precedence over the overridden ToString() method.
The DebuggerDisplay attribute also takes precedence over the overridden ToString() method in a subclass.

I see that there is an existing function called PrintValue which I left as-is intentionally. This means that if PrintValue modifies the display of any value the overridden ToString will not be respected which IMO is okay. I dont think it would provide any meaningful improvement in display

After this I will continue with DebuggerDisplay and then the more complex DebuggerBrowsable and DebuggerTypeProxy

Tested and confirmed locally in sandbox project

System.Guid is a good BCL type for testing with as it is completely unreadable without this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support DebuggerDisplay

1 participant