HTML Visualizer for StringBuilder Type in Visual Studio 2010

Visual Studio 2010 removed the ability to “Visualize” a StringBuilder type unless you append the .ToString() method to the StringBuilder object you are debugging.

Seth Richards posted an article on this topic and, in addition, wrote a custom Visualizer (download Seth’s VS2010 solution here) to compensate for Visual Studio 2010’s lack of support for the StringBuilder visualization. Thanks, Seth!

Seth’s solution works fine and good in the sense that it does display a string visualizer for a StringBuilder type without the need to manually specifying the .ToString() method. However, it doesn’t support an HTML Visualizer – i.e. if the content of the StringBuilder contains HTML text, Seth’s StringBuilder Visualizer will display the raw HTML instead of rendering the HTML.

I’ve taken the liberty of updating Seth’s custom StringBuilder Visualizer to render HTML that may exist in the StringBuilder object. Working off of Seth’s code, I added a new Windows Form which contains a Web Browser control. Then I set the Web Browser control’s DocumentText property with the content of the StringBuilder object that is gettin’ debugged. Download the StringBuilder HTML Visualizer Solution here (this solution was originated by Seth Richards, then updated by me).

Here’s a screenshot of the StringBuilder HTML Visualizer in action:

Note: Due to restrictions by my host, you will need to rename the .xls extension to .zip.

Build/Deploy Instructions

  1. Download the solution
  2. Rename the extension “.xls” to “.zip”
  3. Unzip the file
  4. Build the solution
  5. Copy the compiled dll to your VS2010 Visualizer directory – i.e. ..\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers
  6. Improve the solution and share

One thought on “HTML Visualizer for StringBuilder Type in Visual Studio 2010

  1. Pingback: Visualizing a StringBuilder

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s