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

Notification

Icon
Error

NCrunch 4 - Instrumentation Mode - Optimized - "The name [x] does not exist in the current context"
mattyboy
#1 Posted : Monday, November 11, 2019 1:24:38 AM(UTC)
Rank: Member

Groups: Registered
Joined: 7/2/2015(UTC)
Posts: 17
Location: United Kingdom

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Hi

When debugging my .NET Core 2.2 project (XUnit 2.4.1), if I have an exception in my test code, I can't hover over other variables in the method and see their values.
If I try Quickwatch, it says "The name [blah] does not exist in the current context".

Optimised mode:



Legacy mode:



Matt
Remco
#2 Posted : Monday, November 11, 2019 3:27:29 AM(UTC)
Rank: NCrunch Developer

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

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

Thanks for sharing this problem.

I'm fairly certain this is caused by something funky in the debug information that exists because of the async method block.

Are you working with a portable PDB, or a Win32 one? Does switching between them make any difference?

Are you able to produce this problem with a small sample project that you can share with me? You can submit ZIPed code through the NCrunch contact form.
Remco
#3 Posted : Tuesday, November 26, 2019 1:48:43 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
mattyboy
#4 Posted : Thursday, November 28, 2019 12:49:49 AM(UTC)
Rank: Member

Groups: Registered
Joined: 7/2/2015(UTC)
Posts: 17
Location: United Kingdom

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Hi Remco

I've downloaded the VS2019 version of NCrunch to try it out. However, my solution fails to build with Optimised mode enabled:



Annoyingly, I can't see why it's failing to build.

Fortunately, Legacy mode still works fine.

Matt
Remco
#5 Posted : Thursday, November 28, 2019 1:30:39 AM(UTC)
Rank: NCrunch Developer

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

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

Could you submit a bug report for me after this happens? Something must be failing internally.
mattyboy
#6 Posted : Thursday, November 28, 2019 3:19:32 AM(UTC)
Rank: Member

Groups: Registered
Joined: 7/2/2015(UTC)
Posts: 17
Location: United Kingdom

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Remco;14155 wrote:
Hi Matt,

Could you submit a bug report for me after this happens? Something must be failing internally.


Sure. I just submitted one.

Matt
Remco
#7 Posted : Thursday, November 28, 2019 4:26:48 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks Matt.

It looks like you're experiencing this problem: https://forum.ncrunch.net/yaf_postst2864_IndexOutOfRangeException-with-new-instrumentation-mode.aspx.

Presently, I don't know how to reproduce this issue. The interactions here are complex enough that it will be hard (maybe impossible) to narrow it down through Q&A and guesswork. Something is different about the structure of this assembly.

Is there any chance you can reproduce this in a sample project that you can share with me? Note that you can submit code in ZIP form through the NCrunch contact form.
mattyboy
#8 Posted : Friday, November 29, 2019 2:40:32 AM(UTC)
Rank: Member

Groups: Registered
Joined: 7/2/2015(UTC)
Posts: 17
Location: United Kingdom

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Hi Remco.

Hmm. I just spent about half an hour stripping out most of the functionality from my solution, so I was just left with one controller and a few test classes, so that I could upload it to you.

Switched to Optimised mode = it now builds and runs.

So then I switched back to my develop branch (i.e. with functionality restored, and around 300 tests), and hey presto, Optimised mode still builds and runs.

Let's see what happens if I close and open VS... yep, Optimised mode can still build. Cool.

OK, let's see if my original bug is now fixed...

Nope. I still get "The name 'service' does not exist in the current context".

Let's see if when I switch back to my "stripped down controller and only a few test classes for Remco" branch, if the same thing still happens... yes, it does. I will upload a solution for you.

Matt
Remco
#9 Posted : Tuesday, December 10, 2019 1:28:04 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
1 user thanked Remco for this useful post.
mattyboy on 12/10/2019(UTC)
mattyboy
#10 Posted : Tuesday, December 10, 2019 3:42:07 AM(UTC)
Rank: Member

Groups: Registered
Joined: 7/2/2015(UTC)
Posts: 17
Location: United Kingdom

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Thanks for the fix Remco - I can confirm it's working with my solution :-)

What was the underlying cause? Was it something funky in my solution?

Matt
Remco
#11 Posted : Tuesday, December 10, 2019 11:59:49 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks for confirming! We were corrupting some of the metadata inside the PDB. It was affecting all projects building a non-portable PDB and only affecting yield/async methods as far as I can tell.
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.114 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download