Bradley Uffner
Bradley Uffner

Reputation: 17001

Restrict new language features of Visual Basic in Visual Studio 2015

I'm currently working on a Visual Basic project with a team of developers, some of which will be able to move to Visual Studio 2015 as soon as it is released, and some who will be stuck on Visual Studio 2013 for several months. In testing with the RC we have found that Visual Studio will open 2013 projects without a problem, but will happily let users use new language features, such as string interpolation, that are not available for users in VS 2013. If a 2015 user checks in this code the 2013 users will get compile errors. Is there any project, solution, or Visual Studio setting that will tell the compiler to restrict features to what is available in the previous version of VB.net? Ideally the compiler should return a compile error when trying to use these features in 2015.

This features is available in C# under Project Properties > Build > Language Version, but I can't find any equivalent for VB.net, and the google searches are failing me.

I just wanted to mention that setting the .Net runtime version to 4.5 doesn't help, as these new language features are compiler level features that work perfectly fine on older frameworks.

Upvotes: 8

Views: 1710

Answers (1)

jessehouwing
jessehouwing

Reputation: 114927

There is no UI feature to set the Language version, but you can unload the project file and add <LangVersion>11</LangVersion> to default Visual Basic to the 2012/2013 language settings. The C# project adds this property under the Project Configuration property groups, so for consistency's sake I've done the same in the sample below.

The C# property pages do the same thing, except that C# uses a different set of version numbers.

A full set of all the language versions can be found here.

2002 (VB 7.0)
2003 (VB 7.1)
2005 (VB 8.0)
2008 (VB 9.0)
2010 (VB 10.0)
2012 (VB 11.0)
2015 (VB 14)

Just tested and this works for me, but I did have to change the casing to:

enter image description here

This results in:

enter image description here

And a nice build failure:

enter image description here

Upvotes: 10

Related Questions