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?
According to https://github.com/dotnet/roslyn/issues/13177, the 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.ITuple
and ValueTuple
types will be added to mscorlib in "the first version after" .NET Framework 4.7.
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