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

Notification

Icon
Error

Missing exception info when crunching in optimized mode
dataslask
#1 Posted : Wednesday, December 11, 2019 10:29:41 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/10/2019(UTC)
Posts: 2
Location: Norway

Thanks: 1 times
Hello

I have a problem with missing exception info when crunching in optimized mode. The coverage markers where the exception occurs and propagates does not indicate exception (no X) and the NCrunch Trace Output is missing line numbers (and hyperlink) in the stack trace. In order to find out where the exception occurs I have to start debugging and rely on VS to catch the exception dialog. This is cumbersome ;)

This behavior is consistent for me on VS2017 v15.9.4 with NCrunch 4.2.05 and XUnit 2.4.0 when I create a .NET Core project and manually switch to target framework net471 in the csproj file. (Projects with target framework netcoreapp2.1 are working as expected. Also running the same under VS2019 is working fine, but this is not an option for me).

Switching to legazy mode solves the problem, but is a bummer.

Code:

<Project Sdk="Microsoft.NET.Sdk>
<PropertyGroup><TargetFramework>net471</TargetFramework></PropertyGroup>
<ItemGroup><PackageReference Include="xunit" Version="2.4.0"/></ItemGroup>
</Project>

public class Test
{
[Fact]
public void NoExceptionInfo() {throw new Exception("No NCrunch exception info here!")}
}



Has anyone else experienced this and/or have any clues on how to solve this?

Kind regards
Dataslask
Remco
#2 Posted : Wednesday, December 11, 2019 11:19: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)
Hi, thanks for sharing this issue.

This problem is caused by the inability of the .NET 4.7.1 runtime to interpret portable PDB files. You'll find that if you compile this test project to a console application and try to run it, you'll have the same result.

You're not seeing this in the VS runner because the VS runner seems to defer to using higher versions of .NET when running tests (on my system, it seems to be using .NET 4.8 instead of 4.7.1, even though the library is clearly targeting net471).

NCrunch legacy mode doesn't support portable PDBs, so it implicitly forces the build system to instead output a non-portable PDB, which doesn't have this problem under net471.

You have two options here:
1. Switch to using a non-portable ('full') PDB instead. This is done by adding <DebugType>full</DebugType> inside the main PropertyGroup of your project file
2. Switch to a high version of .NET. 4.7.2 should work fine with portable PDBs
1 user thanked Remco for this useful post.
dataslask on 12/11/2019(UTC)
dataslask
#3 Posted : Wednesday, December 11, 2019 11:35:48 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/10/2019(UTC)
Posts: 2
Location: Norway

Thanks: 1 times
Hei Remco. Thanks for your quick reply!

Both suggestions are working perfectly. I'm not sure if switching to net472 will be an option on my project (even if I can't see why not), but full PDB should be.

Thanks again
Dataslask

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.033 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download