Monday, April 04, 2011

Going from Fugly to Fabulous by giving your objects their own debugging visualizer

Clarity Consulting Blogs - Write Your Own Debugging Visualizer

“Have you ever been stepping through a program and tried to inspect an object only to find it has an internal structure that make it very difficult to really see what is going on in there? I recently ran into a third party object that was causing me that problem over and over so I decided to do something about it. I wrote my own debugging visualizer to take the object and put it into a format that is easy to read. I was surprised how easy it is to do, so lets create one.

The Setup

The object I was struggling with was storing collections of name/value pairs internally in 2 different collections. So I’d have to find the key I’m interested in, note the index and find the corresponding index in the values collection. It was actually worse than this since the collections were also hierarchical. Ouch. So I put together a simple class that demonstrates this called WeirdCollection. It looks like this:




Been a while since I’ve seen a good article on writing your own Debugging Visualizer…


Related Past Post XRef:
One gets you Ten. One DLL, Ten free WCF Debugger Visualizers
A Couple Custom Debugger Visualizers (For VS2005, but with source...)

No comments: