Any time my hands are not on my keyboard my productivity is being harmed. Visual Studio + ReSharper has some really nice keyboard shortcuts which means I don’t need to use my mouse. However, one shortcut which just feels to me plain forgotten is being able to close a file using the keyboard. I can open, switch between but cannot close! Thankfully you can bind your own shortcuts, as such I bound to Ctrl+Q. Having this simply makes everything a little bit easier. But please, Visual Studio or ReSharper – auto-bind this command.
Note: Visual Studio 2010 Beta 2 is a bit buggy when it comes to keyboard shortcut. I had to un-assign anything bound to the key and restart the app before it took effect.
While writing my previous post on how to debug live writer plugins, I mentioned using System.Diagnostics.Debugger.Break(); However, I found a problem with this. If you have a debugger attached, for example Visual Studio, then the program will hit the line of code and the debugger will step in. Great!
However, if no debugger is attached, the following error occurs:
I instantly thought this was strange, so built it as a Release version. Same thing happened. I know that with Debug.Write() the calls are removed in Release mode to save time, space and so no strange errors like this occurs.
First thing I did was boot up Reflector. The debug class uses the ConditionalAttribute which provides a way to include/exclude methods depending on the preprocessor symbol. So, if the Conditional compilation symbol is set to DEBUG then the method is included in the build, otherwise all the calls are removed.
However, if we look at Debugger.Break(), it doesn’t use a ConditionalAttribute which means we cannot take advantage of this compiler feature. The result of this is that you need to manually remove all the lines of code which calls Debugger.Break() before shipping the code to the client, or when not running it with a debugger attached (like running unit tests). Not great at all!!
Strange how this got missed, unless it was done for a reason??