Friday, April 16, 2010

Bye, bye underscores!

Though I code in VB.NET everyday, and have even named this blog after some VB-ish syntax, I code in C# for my personal projects and I maintain a mental "Top 10 things I hate about VB" list.  Near the top of that list is that VB code cannot span multiple lines unless you use an underscore as a line-continuation character.  It's syntax dating back to the earliest days of VB, and it's evil.  It makes the programmer jump through hoops to tell the compiler something that it should be smart enough to figure out anyway.  It was mostly annoying when using class/property <attribute> syntax, but with the addition of Linq syntax in .NET 3.5, the problem grew out of control.

Well, no more!  Today my company has upgraded to Visual Studio 2010, which is somewhat amazing since it was only just released this week.  And one of the great new features is the removal of the need for the underscore in many cases.  The compiler will now do what it should have done all along.

One of the first things I did today after completing the upgrade was to run a find and replace in my project, and I removed 918 underscores from the attributes decorators on classes, most of them for Linq-to-SQL markup.  Here's the regex find-and-replace dialog so that you can do the same!

Just one more goodie in the long awaited VS 2010!  I love being a .NET developer.