Search code examples
c#visual-studio-2017valuetuplec#-7.3

Why does the Visual Studio watch window show wrong values for ValueTuples in a collection?


I'm finding that ValueTuples evaluate differently when I access their properties from a collection.

    public static List<Tuple<string, bool>> MyTupleList = new List<Tuple<string, bool>>
    {
        new Tuple<string, bool>("test", true)
    };

    public static List<(string b, bool c)> MyList = new List<(string b, bool c)>
    {
        ("test", true)
    };

Why do these two highlighted lines evaluate differently and how can I change "MyList[0].c" to get the value correctly?

enter image description here


Solution

  • This seems to be a bug in Visual Studio 2017.

    There are a few related bugs mentioned on Roslyn's github issue tracker, e.g.:

    Since the issue tracker of Visual Studio is not public, we can only wait and hope that these bugs get fixed.