Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Visual Studio Tips and Tricks

Visual Studio Tips and Tricks

Ratings: (0)|Views: 18|Likes:

More info:

Published by: Kiran Kumar Reddy Kambam on Sep 14, 2010
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





Visual Studio .NET Tips and Tricks
Provided by: Dan Haught, FMS Executive Vice President
Use Comments To Flag Bugs and Undone Items
You have probably seen the Task List toolwindow in Visual Studio .NET. This windowshows you a number of useful things including any known compile errors in yourcode. But did you know it will also show you all your bugs and undone items? Well, itdoesn’t actually do this automatically, but it gives you a truly useful mechanism fortracking these items.Whenever you are typing code and you know that you are about to leave somethingundone, simply type in a comment that starts with ‘undone’. When you do this,Visual Studio .NET can show all your undone items in the Task List toolwindow. Thereis one trick here: by default, the Task List is filtered to not show Comment items. Tofix this, simply right-click on the task list window, and select Show Tasks, and checkthe Comments box. Better yet, select all so you can always see all tasks.For example, of you put in the following comment:Your Task List now shows the Undone comment, along with the line and columnwhere it exists. Simply click on the item in the Task List and the code editorautomatically goes to that location.But you can do more than just flag undone items. Visual Studio .NET comes with fourdefault “tokens” you can use in your comments, including HACK, TODO, UNDONE
and BUG. And you can add your own items to the list. To access these tokens, selectTools, Options, Environment, Task List.The really truly useful part comes when you are done with a milestone on yourproject. You now need to review all the potential bugs and undone items. In thepast, you would have gone scrambling for your yellow pad, or a notepad file (if youhad the foresight to keep a list of items manually!). But with Visual Studio .NET, yousimply open your Task List and click through all the items.
Use Regions
A truly nifty feature of the Visual Studio .NET code editor is the concept of regions.You can create named regions directly in your source code. You can then expand andcollapse regions in the editor to hide or show code based on its type. For example,you could create a region called “Public Properties” and put all your property codethere. Additional regions could support your public methods, and privates. Usingregions is easy: simply type the #Region phrase followed by the name for yourregion, as in:You can now expand and collapse the region by clicking on the +/- icons on theright. You can also use the keyboard to expand and collapse regions. Try Ctrl-M, Mand Ctrl-M, L.
Use the Toolbox to Store Code Snippets
How about this? Highlight some code in the code editor. Drag the code on to thetoolbox. Lo and behold, you now have a snippet of code saved. You can drag thatsnippet from the toolbox back on to the code editor window in any place and youcode snippet is automatically inserted.To make this feature truly useful (and to avoid cluttering up your default toolboxtabs) consider creating one or more tabs just to hold snippets. To do this, right-clickon the toolbox and select Add Tab. Create a new tab and give it name to describethe type of snippet, and then drag snippets on that tab. I spent an hour or so
spelunking through my local disk trying to find where Visual Studio .NET stores theseitems, but to no avail. Perhaps they are in some mystery binary blob, or hidden deepin the registry encoded as GUIDs. Or perhaps, they are sent off as SOAP packets tothat mysterious internet “cloud” Bill Gates keeps talking about. Regardless, I wouldhardly use this feature as an industrial strength code repository. (What happenswhen you re-install Visual Studio .NET or move to another computer? Where do yoursnippets go?)Finally, remember that all code repositories are potential bug factories. If you pastein buggy code and re-use it, you are cloning bugs. And this inevitably leads tofascinating new strains and variants of defects which are likely to be un-fixable.
Control Minus Takes You Back
I was programming in Visual Studio .NET for over 6 months before I discovered thisone, and it is one of the most useful navigation keys there is. To “Go Back” (in otherwords, return to the previous position before you navigated away) simply press Ctrl-Minus. This works across windows, and the navigation buffer appears to be limitless,so this is a great replacement for the old VB Ctrl-Shift-F2.
Dock the Class View to the Left of Code
Call me slow, but after a class I’m writing reaches over 100 properties and methods,I can no longer get a quick handle on how it works. Although using Regions in codemakes code expandable and collapsible, that can only go so far. One neat trick I’vefound is to dock the Class View toolwindow directly to the left of my code window.The Class View then acts as a table of contents for me as I work on the code.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->