Getting "Tuple element name is inferred. Please use language version 7.1 or greater to access an element by its inferred name."

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


This a confirmed bug, introduced in 15.3. The fix will ship as part of a servicing release (15.3.2).

The issue is tracked at https://github.com/dotnet/roslyn/issues/21518


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);