An new feature that is of interesting to us VB Revit add-in developers is the implicit line continuation that was added in Visual Basic 2010.
In prior versions of VB, all statements that continue beyond the end of the line have to be explicitly marked using an underscore '_' character. Since some of the Revit API method signatures force rather long lines, this can become a bit overwhelming. This is what it might look like in VB 2008:
''' <summary> ''' Hello World #2 - simplified without full namespace. ''' </summary> <Transaction(TransactionMode.Automatic)> _ Public Class HelloWorldSimple Implements IExternalCommand Public Function Execute( _ ByVal commandData As ExternalCommandData, _ ByRef message As String, _ ByVal elements As ElementSet) _ As Result _ Implements IExternalCommand.Execute TaskDialog.Show("My Dialog Title", "Hello World Simple!") Return Result.Succeeded End Function End Class
With the new implicit line continuation feature, many of the underscores can be omitted in VB 2010:
<Transaction(TransactionMode.Automatic)> Public Class HelloWorldSimple Implements IExternalCommand Public Function Execute( ByVal commandData As ExternalCommandData, ByRef message As String, ByVal elements As ElementSet) _ As Result _ Implements IExternalCommand.Execute TaskDialog.Show("My Dialog Title", "Hello World Simple!") Return Result.Succeeded End Function End Class
Note that two of the underscores still remain; the implicit line continuation is only available after certain syntax elements, such as after a comma or an opening parenthesis, or before a closing parenthesis.
Here is an interview with Doug Rothaus of the Visual Studio User Education team describing it:
Updated Visual Basic Add-in Wizard
Here is an updated VB version of the Visual Studio Revit 2012 add-in wizard making use of the implicit line continuation:
TemplateRevitArch2012AddinVbJt_3.zip – copy to
[My Documents]\Visual Studio 2010\Templates\ProjectTemplates\Visual Basic
The only change I made was to remove the line continuation underscores wherever possible.
For the C# version, please refer to the original post.
Visual Studio Line Length Guide Line
Another complementary Visual Studio feature of special interest to all of us who have to limit the line length of our source code due to one reason or another is the guide-line for Visual Studio pointed out yesterday by Augusto and Kean.
Since I have the same issue as Kean, having to limit my source code line length strictly to fit into the blog post format, I installed it as described and verified that it works well.