Wednesday, March 11, 2009

Debugging tips from the MSDN Roadshow

Yesterday I attended the VT leg of the MSDN Roadshow. While I was unable to stay for all the presentations I picked up some good tips during Jim O'Neil's overview of debugging with Visual Studio 2008 (with a preview of VS2010 debugging). As is my habit, I'm putting my notes from the session here so I don't lose them and so others might benefit from them.

But if you write bug free code you can stop reading here.

One thing that used to bother me was that if I had a line of code that chained or nested several method calls I would have to step into/out of all the methods until I got into the one I wanted. Apparently Visual Studio supports the ability to step into a specific function. I saw Jim do it yesterday, I can see the web sites describe it, but I can't find it in my environment. So it's something to research.

There is another thing I saw and can read about but can't find in my environment. Apparently there is a setting under Tools | Options | Debugging which allows you to step over property and operator calls by default. Again, something to research.

One thing I do see in my environment, and which I believe I can find use for, is the HitCount property of breakpoints. The breakpoint window displays this property for each breakpoint and should prove useful when trying to identify which iteration within a loop is causing a problem (for example).

Finally, Jim reminded me of the DebuggerDisplay attribute that we can use to decorate our classes to make them more user friendly in the debugger. Here's one overview of that attribute and another from Scott Hanselman.

Love the free training...