In a blog post in November, I mentioned a feature called “Quick Search” - one of the code focused features of Visual Studio 2010. We have been lagging behind some in this area in the past and we wanted to focus on this as a key pillar for Visual Studio 2010. Today, I’d like to share some more details of our code focused development investments and features.
Highlight References is a simple but easy way to quickly understand a scoped piece of code and navigate to references. The feature is activated automatically after a short delay - all references to the symbol under the cursor are highlighted. Navigating to the next reference is easily done by pressing Ctrl + Shift + UpArrow (or DownArrow for the reverse direction.) In the example below, you can see this feature in action; you may also notice that it infers which overloads bind to the current selection rather than a pure text match.
Quick Search was the code focused feature I mentioned previously. It works for all C++, C#, and VB symbols and all file types. It’s a very lightweight way to do incremental searches, quickly filter the results and get powerful search heuristics like substring. Let's take a look at how I might use Quick Search.
If I was looking for an event handler and couldn't quite remember its name but knew that I used the typical naming convention, Quick Search can help. My first step is to find all method signatures that contain the word "Click" by typing “Click” into Quick Search.
At that point, I may remember that it also contains "Enter"; by added the letter “E”, I’m able to quickly filter to everything that contains both "Click" and "E", treating the space as a wildcard search. I’ve now reduced the results to a short list I can choose from.
Quick Search even supports camel-case matches. So, for example, if I type in capital, "SPF", Quick Search will filter the results to only those that are a camel-case or exact match!
Another scenario we're focusing on is reviewing dependencies. For example, if I make a change to a method, I might want to know all the instances where it’s being called. In VS 2010, we're improving the call browser experience in C++ and also bringing a new call hierarchy tool to C# and VB. These features let you easily navigate all callers and callees of a method (see below.)
The call hierarchy tools also allow you to see all overrides of a method and any implementers of interface methods. For instance, if I want to see who implements the MakeSound() interface method, I can invoke call hierarchy to see that there are two implementers, in Cat and in Dog.
Many features in Visual Studio, such as IntelliSense and Quick Info work best when an API that a user is consuming is already defined. We recognize, though, there are times you need to code against an API that has yet to be defined completely. For example, in test-driven development (TDD) we see the test-first pattern. So, in VS 2010, we’re making it easier to do consume-first development.
I had previously talked about the "generate from usage" feature which generates code stubs for types, methods, properties, and constructors inferred from a symbol’s usage in code. In the screenshot below, you can see “generate from usage” at work.
Generating the constructor will generate the following code:
However, we're also investing in a "consume-first" mode for IntelliSense that allows you to easily toggle the commit behavior for IntelliSense. In Visual Studio today, you may have had the experience of having the IDE auto-complete an identifier you didn't want because it didn't yet exist (think generic method return types.) In the case below, if you typed "Puzzle", IntelliSense preselects "PuzzleTest". Hitting “space” or Enter will insert "PuzzleTest".
Instead, you’ll be able to hit Ctrl+Alt+Space to toggle on the "Consume-first" mode. Now, when you type "Puzzle", "PuzzleTest" is still included in the list but is won't be actively selected; what you’ve just typed will be what’s inserted.
These are some examples of the kinds of things we are doing in Visual Studio 2010 to make your jobs easier and more productive.