Reputation: 16853
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:
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.
Upvotes: 3
Views: 1485
Reputation: 16853
I think I've worked out the source of the problem.
The project imports:
<Import Project="$(MSBuildToolsPath)\Workflow.Targets" />
Which is the source of the errors in the build output. If I import this into a trivial console project with the above code, I can reproduce the error.
Upvotes: 2