I have a C# library in Visual Studio 2017, and I'm trying to use a tuple in an interface:
IEnumerable<(Guid Id, string name)> GetFoo ();
I have added a reference (via NuGet) to System.ValueTuple
.
Visual Studio and ReSharper both do not detect problems with this line, but when I build I get errors:
------ Build started ------
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5):
error : Type expected
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5):
error : Invalid token '(' in class, struct, or interface member
declaration
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5):
error : Identifier expected; 'string' is a keyword
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5):
error : ; expected
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5):
error : Method must have a return type
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This suggests that it is not being compiled using C# 7.
I am targetting .NET Framework 4.6.2.
Things I've tried:
- Installing the latest updates to Visual Studio
- Making the project compile using C# 7 explicitly, via Properties > Build > Advanced > Language Version
- Adding a reference to
Microsoft.Net.Compilers
None has had an effect.
Edit: Not a duplicate of C# 7 .NET / CLR / Visual Studio version requirements, as solution there (NuGet package) did not solve issue.