Tag Archives: Visual Studio

Visual Studio 2010 – A bunch of code completion/navigation features I miss from Eclipse

For those of you who don’t know me, I’m a long-time Java developer (although I’ve spent plenty of time playing around with other languages and platforms). I’m also a big believer in developer tools – I create developer tools as part of my day job, and take advantage of tools as part of all the programming I do. Finally, I’m incredibly lazy and I’d spend all day playing video games if I could, so saving time is important to me  – every millisecond I save typing code is a millisecond more I can play World of Warcraft or Gran Turismo 5.

This weekend, I spent a bunch of time playing around with C#, ASP.NET MVC 3, and Visual Studio 2010. There are a lot of compelling things for me about this platform – C# is incredibly close to Java (even looking at IL code, I was surprised at how similar it was to Java bytecode) but has some features we Java developers can only dream about, there is a lot of progress within the whole .NET ecosystem, and the deployment mode of ASP.NET websites has potential to solve some problems I have deploying Java applications.

Overall, my experience making a few small ASP.NET websites this weekend was pretty good. For the purpose of this post, however, I’m going to concentrate on my experiences with Visual Studio’s code editor – specifically, some things I really miss from the JDT in Eclipse. It is important to keep in mind that this isn’t meant to be a comparison of the two tools and a declaration of  which one is better – the scope of my wishes are pretty narrow, and frankly, I don’t care which one is better since they rarely directly compete. It also isn’t meant to be a rant on how much Visual Studio sucks, as I think it is generally a good tool that, like any other tool, has  some things that I wish worked a little differently.

Also, I freely admit that some of my complaints/wishes may be invalid – maybe there is a way to do what I want, maybe what I want to do is stupid, or maybe there is a good reason I can’t do what I want. Feel free to correct me in the comments 🙂

With that rambling preamble out of the way, here are the things that I miss from Eclipse:

1. Open Type

It is really handy to be able to open a class by its name. Open Type.. is a considerably more efficient way to navigate to an arbitrary class than finding it in the project tree and it has saved me countless hours. Here is what it looks like in Eclipse:

A couple of things to note – 1) It can open any type in your workspace, whether it is a class you’ve written, one from a referenced library, or from the JDK. 2) It has pretty smart matching (ie, you can use * liberally or do something like NPE to have it find NullPointerException. 3) It is really fast.

I can’t tell you how much I use this every day. Visual Studio has similar capabilities, so let’s see what it looks like:

Not bad, but there are a few differences:

  • It doesn’t include referenced libraries. Actually, the scope of the navigation was a little tricky to figure out. It would occasionally return an external class, but only if I already had it open in another tab.
  • It also includes member variables and other items. I can see how this would sometimes be useful, but it can get noisy – it would be nice if there were an easy way to filter results.

2. Class Hierarchy

Another handy thing is to be able to quickly view the class hierarchy for any given type. It can be really useful to instantly know stuff like “What are this class’ super types?” or “What known implementations of this interface are there?”. Eclipse has a Type Hierarchy view that you can access by selecting any class name (it doesn’t have to be at the class declaration) and either right-clicking and selecting ‘Open Type Hierarchy’ or simply hitting F4. This opens a nice view of the type hierarchy that looks like this:

Visual Studio does have a type hierarchy viewer, but I couldn’t figure out how to get it to show any arbitrary type – you have to use the tree view to find the particular type you are looking for.

3. Code Complete

Code completion is a lazy developer’s best friend, and I’d heard great things about IntelliSense. My experience was that while it worked in more contexts than in Eclipse, the code complete in C# code felt really sub-optimal. First, let’s compare aut0-completing a method on the string class in both languages. Note: I’ve butchered these a little bit to get them to fit correctly in my blog. In both cases, they look a little better in the actual IDE.


A couple of things that I want to point out about what you see in the code-complete popup:

  • It shows the full method signature, as well as other info. You see the return type (immediately after the method signature) and which class that method actually comes from (to the right of the return type). If there are overloaded methods, you see all of them.
  • If there are any JavaDocs associated with that method, you’ll see them on the right.
  • The symbol on the far left tells you what kind of method this is – public, protected, or private.

Now, let’s take a look at what a similar situation looks like in Visual Studio:

We get a roughly similar view, but the information is harder to process. Parameter information and the return type is instead located on the right-popout that you only see if you hover your mouse over the auto-complete candidate for a second. Worse, it is poorly formatted and the information doesn’t jump out at you like it does in the Eclipse scenario. Finally, if there are overloaded methods, you can’t see their signatures in this view.

4. Code Complete, Part 2

So, what happens once we hit ‘enter’ on one of those items?


You’ll note that it not only inserts the rest of the method name, but stubs out the entire call for me with placeholders. As I type in real values for each of the placeholders, I can hit ‘tab’ to go to the next one. It also helpfully shows the parameter types in the tooltip above it. Really useful.

Visual Studio:

This is what it looks like in Visual Studio immediately after hitting ‘enter’. This is not very helpful. Hitting control + space at this point does nothing.

I have to think there is a way to get VS to do something more useful here (let me know if there is!), but really, it shouldn’t take another key combination or other action to get it to do something close to what Eclipse does.

5. Code Complete, Part 3

The scope of IntelliSense seemed really limited, too. For example, I was trying to use the DbContext class from System.Data.Entity. So, I typed DbC and then hit ctl+space, and wasn’t presented with anything useful. In Eclipse, if you were to do something similar, you’d see something like this:

Selecting one of those would cause Eclipse to automatically import the proper package.

Visual Studio clearly knows enough to do this – when I right-click on DbContext, it offers me the option of importing the correct namespace. Why couldn’t it do this as part of the IntelliSense functionality?

6. Sundry

There a ton of little things that annoyed me or felt sub-optimal, but didn’t warrant screenshots or their own section:

  • Eclipse has a feature where you can tell it to automatically put semi-colons and braces at the end of the line when you type them. This saves you having to cursor over or hit ‘end’ to do that (I told you I was lazy!).
  • Code Snippets are pretty cool – Eclipse has a similar feature. I have 2 problems with Visual Studio’s implementation: 1) They aren’t editable or createable through a simple interface in the IDE (that I can tell). 2) They show in the same IntelliSense popup as everything else, yet you hit ‘tab’ instead of ‘enter’ to activate them. Why?
  • It is kind of annoying to have to manually build the project to get certain things to happen. Why can’t it be continuously building like Eclipse Java projects? I realize this occasionally causes problems in Eclipse, but you can turn it off if you want.


Admittedly, when you use a tool for 8 or so hours per day for a number of years, you develop a ton of muscle memory, and using anything else feels really weird. I think, though, that some of the things I’ve pointed out above aren’t just ‘different’ in Eclipse, but are actually better, and it would be nice to see them in Visual Studio. I’m pretty open-minded, though, so if I’m somehow wrong, feel free to let me know via the comments!