Version Used:
Visual Studio 2017 RC
Steps to Reproduce:
static (int sum, int count) Tally(int[] values)
{
var r = (s: 0, c: 0);
foreach (var v in values)
{
r.s += v; r.c++;
}
return r;
}
Expected Behavior:
Should not have any errors.
Actual Behavior:
Get red squiggles on code:
(int sum, int count)
Get the following error:
Severity Code Description Project File Line Suppression State
Error CS8137 Cannot define a class or member that utilizes tuples because the compiler required type 'System.Runtime.CompilerServices.TupleElementNamesAttribute' cannot be found. Are you missing a reference?
I tried the same steps with a .NET Core Class project and WPF project and appears to work. Did I do something wrong or is this currently a limitation on .NET Core preview tooling?
Thx
Probably nuget System.ValueTuple should be referenced ?
"3. Add Nuget package System.ValueTuple"
I had the same issue, after closing and reopening the solution, the tuple works as expected
@leoniDEV It also appears to work after restarting VS on my side. Thanks for noticing this.
Likely related to https://github.com/dotnet/roslyn-project-system/issues/784
I tried this on RC.2 (VS "Version 15.0.26006.2 D15REL") and did not encounter the problem.
Smells like a project system issue as Sri hinted.
Assigned to Dave, since he already has the related issue..
@jcouv @davkean I also just tried my project with issue from stated above and appears to now work with VS15RC2. Thanks.
Most helpful comment
"3. Add Nuget package System.ValueTuple"