March 26th, 2010

Editing XML Literals Embedded Expressions in Visual Basic 2010 (Avner Aharoni)

The implicit line continuation feature in Visual Basic 2010 provided an opportunity to improve the code editing experience in XML literals embedded expressions. In Visual Studio 2008, pressing Enter inside an embedded expression would result in the cursor being positioned to the left of the end embedded expression tag. In Visual Studio 2010, pressing Enter inserts a newline for the cursor, and the end embedded expression tag moves to the line below. This minimizes the number of key strokes needed to nicely format an embedded expression.

Example 1: Pressing Enter in an empty embedded expression

1) Starting point:

clip_image002

2) Result after pressing Enter in Visual Studio 2008:

clip_image006

3) Result after pressing Enter in Visual Studio 2010:

clip_image004

Example 2: Pressing Enter at the end of a line in a LINQ query

1) Starting point:

clip_image008

2) Result after pressing Enter in Visual Studio 2008:

clip_image012

3) Result after pressing Enter in Visual Studio 2010:

clip_image010

This example also uses the new VB array literals feature in Visual Studio 2010 as the query source.

Author

0 comments