Build/Test Issues

NCrunch 4 - Instrumentation Mode - Optimized - "The name [x] does not exist in the current context"

Started by mattyboy on 3,312 views

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:

External image

Legacy mode:

External image

Matt

Edited

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.
We've got to the bottom of this issue. The build below contains a fix if you're willing to give it a try:

NCrunch_Console_4.2.0.2.msi
NCrunch_Console_4.2.0.2.zip
NCrunch_GridNodeServer_4.2.0.2.msi
NCrunch_GridNodeServer_4.2.0.2.zip
NCrunch_LicenseServer_4.2.0.2.zip
NCrunch_VS2008_4.2.0.2.msi
NCrunch_VS2010_4.2.0.2.msi
NCrunch_VS2010_4.2.0.2.zip
NCrunch_VS2012_4.2.0.2.msi
NCrunch_VS2012_4.2.0.2.zip
NCrunch_VS2013_4.2.0.2.msi
NCrunch_VS2013_4.2.0.2.zip
NCrunch_VS2015_4.2.0.2.msi
NCrunch_VS2015_4.2.0.2.msi.7z
NCrunch_VS2015_4.2.0.2.zip
NCrunch_VS2017_4.2.0.2.msi
NCrunch_VS2017_4.2.0.2.msi.7z
NCrunch_VS2017_4.2.0.2.zip
NCrunch_VS2019_4.2.0.2.msi
NCrunch_VS2019_4.2.0.2.msi.7z
NCrunch_VS2019_4.2.0.2.zip
Hi Remco

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

External image

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

Fortunately, Legacy mode still works fine.

Matt
Hi Matt,

Could you submit a bug report for me after this happens? Something must be failing internally.
Remco 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
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.

Edited

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
Thanks again for your help in identifying this issue Matt.

I've implemented a targeted fix for this in the build below. It would be great if you could confirm whether this solves the issue for you:

NCrunch_Console_4.2.0.5.msi
NCrunch_Console_4.2.0.5.zip
NCrunch_GridNodeServer_4.2.0.5.msi
NCrunch_GridNodeServer_4.2.0.5.zip
NCrunch_LicenseServer_4.2.0.5.zip
NCrunch_VS2008_4.2.0.5.msi
NCrunch_VS2010_4.2.0.5.msi
NCrunch_VS2010_4.2.0.5.zip
NCrunch_VS2012_4.2.0.5.msi
NCrunch_VS2012_4.2.0.5.zip
NCrunch_VS2013_4.2.0.5.msi
NCrunch_VS2013_4.2.0.5.zip
NCrunch_VS2015_4.2.0.5.msi
NCrunch_VS2015_4.2.0.5.msi.7z
NCrunch_VS2015_4.2.0.5.zip
NCrunch_VS2017_4.2.0.5.msi
NCrunch_VS2017_4.2.0.5.msi.7z
NCrunch_VS2017_4.2.0.5.zip
NCrunch_VS2019_4.2.0.5.msi
NCrunch_VS2019_4.2.0.5.msi.7z
NCrunch_VS2019_4.2.0.5.zip
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
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.

Post a reply

Log in to reply.