Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Debugging Async Tests - variable "does not exist in the current context"
jmackay
#1 Posted : Tuesday, April 22, 2014 4:56:27 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/30/2012(UTC)
Posts: 4
Location: United States of America

Whenever I try to view variable information in my tests whenever I try to use watches / immediate window / hover over objects I get "The name 'myVar' does not exist in the current context" when using the ncrunch runner, but works fine if I use MSTest directly.

The tests pass / fail correctly when they run, I'm just not able to debug them when run through ncrunch.

Is there some setting I need to change, or is this a bug?
Remco
#2 Posted : Tuesday, April 22, 2014 11:25:20 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 960 times
Was thanked: 1290 time(s) in 1196 post(s)
Unfortunately, this is a bug.

Even more unfortunately, a solution to it has not yet been found.

The problem is caused by NCrunch's instrumentation/relocation conflicting with the 'magic' the Visual Studio debugger uses to look through compiler generated types, such as enumerators and await blocks. The physical structure of the code underlying these constructs is different to the code you are viewing in the debugger, and this causes VS's run-time resolution of the variables to fail.

I'm currently holding a hope that this can be resolved as part of a longer term plan, but currently no fix is available. Until a solution can be found, I recommend separating complexity from methods that use yield/await so that it's still possible to debug this code without NCrunch's build moving it away from the debugger.
jbattermann
#3 Posted : Sunday, October 12, 2014 7:02:28 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/16/2014(UTC)
Posts: 10
Location: Germany

Was thanked: 1 time(s) in 1 post(s)
Hey there,

I am having the same problem over and over again, too and switch back and forth inbetween the regular MS Test runner and NCrunch and to be quite honest, this is frustrating. Has there been any progress in this area or do I have to get used to to this?

Thanks,
-Jörg
jbattermann
#4 Posted : Sunday, October 12, 2014 7:03:33 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/16/2014(UTC)
Posts: 10
Location: Germany

Was thanked: 1 time(s) in 1 post(s)
(as a sidenote - it does work in other runners, e.g. R#'s test runner, too)
Remco
#5 Posted : Sunday, October 12, 2014 9:50:30 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 960 times
Was thanked: 1290 time(s) in 1196 post(s)
Sorry. No solution has yet been found for this problem.
ProgrammerAl
#6 Posted : Wednesday, April 15, 2015 2:34:17 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/15/2015(UTC)
Posts: 3
Location: United States of America

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Looks like no one has asked about this recently. Anyone know if this bug has been fixed within the past 6 months? I'm having the same problem now in VS 2013.
Remco
#7 Posted : Wednesday, April 15, 2015 10:44:28 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 960 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi,

A solution to this problem was released in NCrunch v2.11 earlier this year.
Grendil
#8 Posted : Saturday, March 18, 2017 3:31:00 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 3/18/2017(UTC)
Posts: 54
Location: United States of America

Thanks: 22 times
Was thanked: 11 time(s) in 10 post(s)
It seems I'm having this issue now, with VS 2015 and NCrunch 3.5.0.1. I have a yield method in the SUT, and it gets called and ToList()'d in the test, and the test asserts that the resulting List<> contains items (and the test passes during debug). Yet the debugger can't see the List<> variable, same error as OP two years ago.

Ah! Apologies, I missed that the OP was talking about async. I'm not doing any async here, just a yield method. But that seemed to be flagged as a cause in the first reply, so this thread caught my eye.

I do have resharper's test runner enabled, not sure if that causes problems under the hood. (That runner handles debugging the value of my variable fine btw.)
Remco
#9 Posted : Saturday, March 18, 2017 5:31:22 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 960 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, this could be a problem with the debug metadata.

Are you able to reproduce this in a code sample you can share with me?
Grendil
#10 Posted : Sunday, March 19, 2017 6:53:50 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 3/18/2017(UTC)
Posts: 54
Location: United States of America

Thanks: 22 times
Was thanked: 11 time(s) in 10 post(s)
Remco;10007 wrote:
Hi, this could be a problem with the debug metadata.

Are you able to reproduce this in a code sample you can share with me?


Hi, thanks for following up with me. The project where I encountered the bug is a large solution with many interdependencies. I created a new project and tried to reproduce the bug there but so far I haven't been able to. I must be leaving out a critical element in my simplified repro project, as it does happen consistently in the orginial place where I encountered it. I'll keep working on that but it will be a few days before I have more time. Is there an NCrunch log file generated that could be of help?
Remco
#11 Posted : Sunday, March 19, 2017 10:58:56 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 960 times
Was thanked: 1290 time(s) in 1196 post(s)
Grendil;10030 wrote:

Hi, thanks for following up with me. The project where I encountered the bug is a large solution with many interdependencies. I created a new project and tried to reproduce the bug there but so far I haven't been able to. I must be leaving out a critical element in my simplified repro project, as it does happen consistently in the orginial place where I encountered it. I'll keep working on that but it will be a few days before I have more time. Is there an NCrunch log file generated that could be of help?


Because the log files don't contain any of your code, unfortunately they won't tell us much here. My expectation is that the problem is triggered by the code structure of the method you are trying to debug, so I would hope that you wouldn't need to arrange many project dependencies for this. Variable names are also of significant importance in debug metadata.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.091 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download