Rick de Water
Rick de Water

Reputation: 2642

How to show the text visualizer for custom classes

I have builder class that generates a string. The output string is available through the ToString() method. I want to show this output in visual studio's debugger.

When I take a look at the raw string I get the following result:

string

When I look at the builder however it is missing the newlines as well as the "View" button:

MethodScriptBuilder

Adding [DebuggerDisplay("{ToString()}")] to the at least shows the newlines, but still doesn't have the "View" button.

MethodScriptBuilder

How can I make my class automatically display itself exactly like the string, including the "View" button?

Upvotes: 8

Views: 465

Answers (1)

FinneVirta
FinneVirta

Reputation: 442

Seems like you need to add a DebuggerTypeProxyAttribute to your builder class. It's not very pretty but it sounds like that is what you need.

Here is another SO-question to look at.

Upvotes: 1

Related Questions