Prevent cutting or copying blank lines in Visual Studio

(Note: This blog post was originally published under my old domain(codesmiles.com), here. Web Archive link. I hope you know that we are not required to select a line to cut or copy it in Visual Studio, you can just keep the caret in a line and press Ctrl + C or Ctrl + X and the text in the line will be copied to your clipboard and you can insert this line anywhere in your code by pressing Ctrl + V. It will also copy a blank line, but people use Ctrl + X command to delete blank lines and some may find this as an issue as they didn’t intend to copy the blank line and also it will clear the previously copied item in the clipboard. It is surprising as usual to find that Visual Studio team has thought out this and provided a setting which prevents the copying of blank lines, and Cut command will just delete the blank lines. I found this when I recently bumped into the setting in Visual Studio, in Text Editor > All Languages called “Apply Cut or Copy commands to blank lines when there is no selection“.

Visual Studio 2010 Extension for collapsing solution explorer items

(Note: This blog post was originally published under my old domain(codesmiles.com), here. Web Archive link. I have recently realised how folks get significantly uncomfortable and could also loose little amount of productivity speed when navigating Solution Explorer which is in a state of mess due to randomly expanded and collapsed Solution Explorer items, it surely causes at least a tiny amount of lack of clarity. The basic TreeView control or Tree control is a common windows control found in many places in Windows OS, including Windows Explorer. The same is found in Visual Studio’s Solution Explorer, for those who are not aware; this control supports some keyboard shortcuts, I mean whether you are in Windows Explorer or Visual Studio Solution Explorer you can select a node’s parent and use these shortcuts. + (plus) –> Expand – (minus) –> Collapse * (asterick) –> If you would like to expand recursively a particular item’s child items But there is no shortcut to collapse recursively. Collapse Selection in Solution Explorer extension is available for Visual Studio 2010 that adds an icon to the Solution Explorer(shown below), clicking which recursively collapses the child items. You can press Ctrl + Alt + Num(-) – numeric

The (not much utilized) Debug->Exceptions… window technique

(Note: This blog post was originally published under my old domain(codesmiles.com), here. Web Archive link. The Debug-Exceptions… window is a useful tool that at times saves lot of time when debugging. Even though this exists (i think)from Visual Studio 2003, I Still find people struggle a bit with the situation I am going to explain next.[more] As you know Visual Studio highlights the exception code line when it is not handled. Sometimes we purposely don’t handle exceptions in a method and let the exception thrown to calling functions.   Usually we have a multi-project solution that typically has layers like Business logic, Data access layer, UI, etc. Imagine that you make a call from the UI to a local function and it calls another function in BLL and the call goes deep into layers of your project architecture. Now, when it is not sure if each of the methods getting called handles exceptions in it or doesn’t throw identifiable exceptions. For instance.. private void Function_A() {     try     {         BLLFunction();//this calls few other functions..     }     catch (Exception ex)     {         //handle exception     } } Function_A() calls BLLFunction() and it again calls few other functions,