Tuple syntax in VS 2017

。_饼干妹妹 提交于 2019-12-04 09:58:51

问题


In VS2017 RC, when you tried to use new tuple syntax, you received the following error:

CS8179 Predefined type 'System.ValueTuple`X' is not defined or imported

In order to use tuple syntax, you had to manually import ValueTuple nuget package into the project. Not a big deal, as it was pre-release version and I thought it will be changed in RTM so it will be enabled by default. Unfortunately in the final release version it is still the case and you have to download nuget package for every single project to use tuple syntax.

Is there a way to have tuple syntax enabled for every project by default?


回答1:


According to https://github.com/dotnet/roslyn/issues/13177, the ITuple and ValueTuple types will be added to mscorlib in "the first version after" .NET Framework 4.7. According to the .NET Framework 4.7 release notes, it has been added. Adding it to 4.6.x would break semver. Hence they provided the types as a Nuget package so that projects based on older framework versions can use it.

This is akin to a .NET 2.0 project wanting to use LINQ which the extension methods lived in System.Core, not mscorlib.

One option you could do is create your own project templates in the interim that reference the NuGet package.



来源:https://stackoverflow.com/questions/42657839/tuple-syntax-in-vs-2017

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!