Who uses the immediate window in Visual Studio?
So I recently sat down with some colleagues, to show them an interesting bug (not blog-worthy, just an off-by-one that had been lying dormant in production since the dawn of time).
They were crowded around my desk, coffees in hands, with their eyes shining, full of eagerness to see the breakpoint get hit, and hear my explanation of the issue.*
The break point gets hit *gasp*
I highlight the offending line and paste it into the immediate window.
“Whaaaaaaaaaaat?” my colleagues scream in unison!
They were surprised that I used the immediate window and told me they literally never use it.
I explained how I use it:
- I set a break point and hit it
- I load up the immediate window now I have access to any variable that is in scope
- I might use intellisense to look around objects
This works particularly well with collections, as I can use the index notation 
- I might use it to execute a method that throws an exception
This is so handy, because if we stepped over this method in the debugger, the exception would get thrown and we’d have to start the process again. This wouldn’t be an issue if I this particular method was testable – I could just set it up to throw an exception, but I was working with legacy code. Hey, I inherited debt.
- I might use it to execute some code several times
I’m not sure how this could be a achieved using the GUI tools
- The other day I used it to throw an exception in the code. I wanted to see what would happen if an exception got thrown, so set a break point in the code I was interested in, then set an object that would soon to be called to null, causing a null reference exception.
Now I don’t know if my methods are certainly the best. I know that I do use watches, and other GUI tools to compliment the immediate window, but it turns out I use it more often than my colleagues, so that’s’ interesting if nothing else.
I think there might be an indication that the Immediate Window is not commonly used. I’ve noticed that LINQ and some other Net3.0+ features are not supported.
What do you think? How do you use the immediate window?