WebAssembly in Action

Author of the book "WebAssembly in Action"
Save 40% with the code: ggallantbl
The book's original source code can be downloaded from the Manning website and GitHub. The GitHub repository includes an updated-code branch that has been adjusted to work with the latest version of Emscripten (currently version 3.1.44).

Friday, December 17, 2010

Visual Studio 2010 Tips and Tricks

Every once in a while I run across some Visual Studio tips and tricks that help me become a little more productive in my daily development tasks.

Today I will share with you three tips and tricks that I recently discovered that have already helped me improve my productivity.

IntelliSense Window Hiding Content

Ever find yourself trying to type something in and the IntelliSense window pops up? Or perhaps you're trying to fill in the parameters to a function call and the tooltip pops up?

These pop-up windows can be quite handy until they cover some data you need to reference.

For example maybe you're filling in the parameters for a function call and you don't remember what the variable is named but, in this case, the usually handy IntelliSense pop-up window is hiding the variable you need as in the following screenshot:

(click to view the image full size)

When this happens you can simply press and hold the Ctrl key which will cause the IntelliSense pop-up window to become semitransparent until you release the Ctrl key as shown in the following screenshot:

(click to view the image full size)

View Call Hierarchy

When dealing with bug fixes in a large application you don't always have the luxury of working with code you wrote and, even if you did write the code, it might have been so long ago that you no longer remember the details of which function calls what.

Quite often I've found that it's necessary to determine what functions call this particular function in order to make sure that the fix works in all conditions.

There are other scenarios that might cause you to want to know what functions call this one, or which functions does this function call.

Up until I discovered this technique, my method of determining which function calls a particular function was by doing a Find in Files (Ctrl + Shift + F) looking for the function.

I would have to repeat the find if I now wanted to know who calls one of the calling functions that was just located. In this case I would put the new find results in the other find result window so that I wouldn't lose my first search results.

The Find in Files technique worked for me but was more time consuming than I would have liked.

Fortunately, Visual Studio 2010 introduced a very nice feature called View Call Hierarchy.

If you right-click on a function (definition or call) there is a context menu item called 'View Call Hierarchy'. Clicking on the View Call Hierarchy context menu brings up the following window:

(click to view the image full size)

With the View Call Hierarchy window, you are shown the function that you right-clicked on and below it you see two tree items.

If we expand the first tree item, we'll see all calls to the function within your solution.

If you click on one of the items listed in the tree, in the right-hand pane it will show you how the function is called, which file makes the function call and even indicates which line in the file to find the function call.

(click to view the image full size)

Double-clicking an item in the left-hand pane will bring you to the function. Double-clicking on an item in the right-hand pane will bring you to the function call.

The other branch of the tree in the left-hand pane shows you all function calls made by the selected function.

With both branches, you can continue to expand the function calls and see who calls them or what calls they make.

The View Call Hierarchy window allows you quickly step through the hierarchy of calls to or from a function and view how the function is called without ever needing to leave the window.

If you did want to inspect a function closer, you can simply double-click on it in either pane.

Navigate Backwards

Sometimes when you're working on code you need to search for something in particular so you may do a Find in Files or use the View Call Hierarchy method described above and jump to another file or another point in the current file.

With all of this jumping from file to file or to different locations within the same file, it sometimes becomes difficult to remember where you were originally.

To step back one navigation jump at a time you can press Ctrl + -

You can also use Ctrl + Shift + - if you wish to step forward one navigation jump at a time.

There is no View Call Hierarchy in JavaScript files but if you were to do a Find in Files and navigated away from a function, the Ctrl + - shortcut works in JavaScript files too.

In Closing

I only touched on a few of the many Visual Studio 2010 tips and tricks that are available. Depending on your needs as a developer, some tips and tricks might be more useful than others.

One site that has quite a few Visual Studio tips and tricks is Zain Naboulsi's MSDN blog: http://blogs.msdn.com/b/zainnab/

No comments:

Post a Comment