4

I have a .NET core project and an Xunit project in a solution, where I've all of a sudden gotten huge problems with debugging. This seems to have coincided with installing update 2 yesterday.

When debugging and hitting a breakpoint, only a select few parameters show up in locals, autos, watch or are reachable from immediate window. I think, but haven't verified 100%, that the variables I can access are globals and ones passed as parameters to the function.

For instance, look at part of this test:

 public void UniTest4()
        {
            var s = @"{
                ""id"": ""0001"",

                ""type"": ""donut"",
                ""name"": ""Cake"",
                ""ppu"": 0.55,
                ""batters"":
                    {
                            ""batter"":
                            [
                                { ""id"": ""1001"", ""type"": ""Regular"" },
                                { ""id"": ""1002"", ""type"": ""Chocolate"" },
                                { ""id"": ""1003"", ""type"": ""Blueberry"" },
                                { ""id"": ""1004"", ""type"": ""Devil's Food"" }
                            ]
                    },
                ""topping"":
                    [
                        { ""id"": ""5001"", ""type"": ""None"" },
                        { ""id"": ""5002"", ""type"": ""Glazed"" },
                        { ""id"": ""5005"", ""type"": ""Sugar"" },
                        { ""id"": ""5007"", ""type"": ""Powdered Sugar"" },
                        { ""id"": ""5006"", ""type"": ""Chocolate with Sprinkles"" },
                        { ""id"": ""5003"", ""type"": ""Chocolate"" },
                        { ""id"": ""5004"", ""type"": ""Maple"" }
                    ]
            }";

            var token = yayson.MakeToken(s);

When I break on the last line, I can't to reach the variable "s". I have looked for others with similar problems, and have then seen suggestions that this may be due to building with certain compiler optimizations. But is that really the case for me? Shown below are the build settings for my Xunit project. My business project looks the same, excep for the top checkbox being checked (which it also was, working just fine, prior to the VS update).

Project settings

What can I do to find local variables again?

Christofer Ohlsson
  • 3,097
  • 4
  • 39
  • 56

1 Answers1

5

I finally found a solution from Andrew Arnott via this SO question: Visual Studio 2015 Debugging: Can't expand local variables?

Just ticking the "Use Managed Compatibility Mode" box solved my problem. Although I'd love to know why that helped.

Community
  • 1
  • 1
Christofer Ohlsson
  • 3,097
  • 4
  • 39
  • 56
  • 1
    Wow - how in the world do they regress over things like this??? Thanks for finding this. I seem to remember reporting a similar issue once and they recommended I checked the 'legacy expression evaluators'. But this one checkbox fixed it for me. – Simon_Weaver Apr 04 '16 at 11:17
  • 1
    Thanks a lot, this problem really annoyed me and a colleague quite a lot. The tip really saved my day :) – Søren Reinke Apr 05 '16 at 08:58