views:

398

answers:

2

I use Visual Studio (C# Express 2008) occasionally to work with some vendor supplied C# code. I am looking to make my experience with it more like my experience with Eclipse. I have gotten accustomed to the way Eclipse handles underlining errors (in java source). When there is a error in my code in eclipse, it will usually be underlined right away, and if I fix it, the underline will disappear almost immediately, or at worst, when I save the file. In Visual Studio however, the underline remains until I next build the project.

Is there a setting somewhere I can change so that VS will build everytime I save, or even as I am typing? Or is this hard to do with C# because it is more complex in some way than Java? Or do I need to find someone to buy me the full (non express) version? Also, what is the squiggly underline feature called? I fear this question may have been asked before but I don't know what the magic word to search for is.

+9  A: 

Do you have Visual C# 2008 Express Edition with SP1? SP1 added exactly this feature to Visual Studio 2008 Professional and Visual C# 2008 Express Edition.

From the release notes:

This service pack adds a new Visual C# IDE feature that provides a richer set of error information about your code. Specifically, this feature presents the expression-level errors that occur in open files to you according to your code. These expression-level errors were previously reported only after a build operation.

From Scott Guthrie's release notes:

The C# code editor now identifies and displays red squiggle errors for many semantic code issues that previously required an explicit compilation to identify. For example, if you try to declare and use an unknown type in the C# code-editor today you won't see a compile error until you do a build. Now with SP1 you'll see live red squiggle errors immediately (no explicit compile required):

alt text

Jason
And, wow, it's handy.
Joel Etherton
excellent. It looks like the release notes don't even have a fancy name for the squiggles. Instead they call it "the feature".
Peter Recore
Magic compiler elves.
Jason
finally had a chance to install the new version, and it is everything i had dreamed of.
Peter Recore
+8  A: 

Jason's answer is fine, but a couple additional points:

is this hard to do with C# because it is more complex in some way than Java?

Yes, but that's not relevant. Yes, it is a hard problem to do on-the-fly analysis of any language in the 100 milliseconds between keystrokes. Doing it for C# is probably harder than Java, being that it supports so many more language features than Java.

But our IDE team is a bunch of buff coders who are awesome, so they can handle doing it for C#.

The real issue was that the compiler architecture of C# was not originally designed to do this sort of analysis in realtime; the VB compiler was. And therefore it took rather longer to fix up the semantic analysis engine of the C# compiler to make this feature feasible.

We're continuing to do research into how to rearchitect the compiler to expose more and more of these on-the-fly analysis services in a rich, extensible and compelling way, but this will take some time. It's a big compiler.

what is the squiggly underline feature called?

On the compiler team we call it "the squiggly red underline feature", or "squiggles" for short.

I don't know if marketing has a name for it or not. If they do, it's probably something like "Microsoft SquiggleSense .NET For The Microsoft Visual Studio Suite System 2008"; they seem to like these long names that have "Microsoft" in them twice.

Eric Lippert
+1 for "Microsoft SquiggleSense .NET" :)
Thomas Levesque
+1 for the inside scoop on "squiggles".
Peter Recore