We have the following code that has been working fine in our UWP app until today after we updated Visual Studio 2017 to the latest 15.3.
private void Test()
{
var groups = new List<(Guid key, IList<(string, bool)> items)>();
var items = new List<(string, bool)>
{
("a", true),
("b", false),
("c", false)
};
var group = (Guid.NewGuid(), items);
groups.Add(group);
}
There is no error message but this in the output window
Tuple element name 'items' is inferred. Please use language version 7.1 or greater to access an element by its inferred name.
Any idea why and how to fix this?
Project->Properties->Build->Advanced->Language Version->C# latest Minor Version
Looks like this is a breaking change in C# 7.1. (as pointed out by @JulienCouvreur, this is actually a bug, but the workaround below should still work though).
Workaround
Try giving a name (e.g. use the same name items
from IList<(string, bool)> items
to be consistent) explicitly to items
(i.e. the list instance).
var group = (Guid.NewGuid(), items: items);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With