限制Visual Studio 2015中Visual Basic的新语言功能 [英] Restrict new language features of Visual Basic in Visual Studio 2015

查看:133
本文介绍了限制Visual Studio 2015中Visual Basic的新语言功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在与一组开发人员一起从事Visual Basic项目,其中一些开发人员将能够在发布Visual Studio 2015后立即迁移到Visual Studio 2015,还有一些开发人员将在Visual Studio 2013中停留几个个月.在使用RC进行测试时,我们发现Visual Studio可以毫无问题地打开2013年项目,但很高兴让用户使用VS 2013中不可用的新语言功能,例如字符串插值.如果2015年用户签入这段代码2013年的用户将获得编译错误.是否有任何项目,解决方案或Visual Studio设置会告诉编译器将功能限制为VB.net的早期版本中提供的功能?理想情况下,在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.

此功能在C#中的项目属性">生成">语言版本"下可用,但是我找不到VB.net的任何等效项,并且Google搜索使我失败了.

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.

我只想提到将.Net运行时版本设置为4.5并没有帮助,因为这些新的语言功能是编译器级别的功能,可以在较旧的框架上很好地工作.

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.

推荐答案

没有用于设置语言版本的UI功能,但是您可以卸载项目文件并将<LangVersion>11</LangVersion>添加到默认的Visual Basic中以2012/2013语言设置. C#项目将此属性添加到项目配置"属性组下,因此,为了保持一致,我在下面的示例中进行了同样的操作.

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.

除了C#使用一组不同的版本号之外,C#属性页执行相同的操作.

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

可以在此处找到所有语言版本的完整版本.

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:

结果是:

一个不错的构建失败:

这篇关于限制Visual Studio 2015中Visual Basic的新语言功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆