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

Notification

Icon
Error

2 Pages12>
NetCore2 projects don't get X on exception lines
daveleaver
#1 Posted : Monday, October 09, 2017 2:26:49 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/14/2012(UTC)
Posts: 8
Location: Hamilton, NZ

Thanks: 3 times
Was thanked: 1 time(s) in 1 post(s)
On a line that throws an exception, it gets the red circle instead of the red x.
This works correctly with a .net framework 4.6 project


Steps to reproduce:
Create a new console app (net core 2)
Reference xunit 2.3.0 from nuget
Add the test code.
Enable ncrunch.

It looks like ncrunch can't see the pdb or something maybe, as there is no line number for the test code in the ncrunch output.

The pdb is there, this is the contents of the bin/obj dirs in the workspace used for the test:
Quote:

dir .\bin\Debug\netcoreapp2.0\
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 9/10/2017 3:08 PM 3814 HackAppCore.deps.json
-a---- 9/10/2017 3:08 PM 5120 HackAppCore.dll
-a---- 9/10/2017 3:08 PM 15872 HackAppCore.pdb
-a---- 9/10/2017 3:08 PM 234 HackAppCore.runtimeconfig.dev.json
-a---- 9/10/2017 3:08 PM 154 HackAppCore.runtimeconfig.json
-a---- 4/09/2017 4:13 PM 142336 nCrunch.Common.DotNetCore.dll
-a---- 9/10/2017 3:08 PM 13980 nCrunch.TaskRunner.DotNetCore.20.x64.deps.json
-a---- 4/09/2017 4:13 PM 19456 nCrunch.TaskRunner.DotNetCore.20.x64.dll
-a---- 9/10/2017 3:08 PM 195 nCrunch.TaskRunner.DotNetCore.20.x64.runtimeconfig.dev.json
-a---- 9/10/2017 3:08 PM 154 nCrunch.TaskRunner.DotNetCore.20.x64.runtimeconfig.json
-a---- 4/09/2017 4:13 PM 170496 nCrunch.TestExecution.DotNetCore.dll
-a---- 4/09/2017 4:13 PM 16384 nCrunch.TestRuntime.DotNetCore.dll

dir .\obj\Debug\netcoreapp2.0\
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 9/10/2017 3:08 PM 1089 HackAppCore.AssemblyInfo.cs
-a---- 9/10/2017 3:08 PM 42 HackAppCore.AssemblyInfoInputs.cache
-a---- 9/10/2017 3:08 PM 42 HackAppCore.csproj.CoreCompileInputs.cache
-a---- 9/10/2017 3:08 PM 1060 HackAppCore.csproj.FileListAbsolute.txt
-a---- 9/10/2017 3:08 PM 4608 HackAppCore.dll
-a---- 9/10/2017 3:08 PM 11776 HackAppCore.pdb


NCrunch 3.11.0.9, VS 2017

Thanks :)
Remco
#2 Posted : Monday, October 09, 2017 2:47:00 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 664 times
Was thanked: 780 time(s) in 742 post(s)
Thanks for sharing this problem.

For some reason, this doesn't seem to appear for me. There must be something in your environment that is triggering this.

Code:

NCrunch: This test was executed on server '(local)'

Xunit.Sdk.TrueException: Assert.True() Failure
Expected: True
Actual:   False
   at Xunit.Assert.True(Nullable`1 condition, String userMessage) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\BooleanAsserts.cs:line 95
   at ConsoleApp1.TestClass.Test() in c:\temp\ConsoleApp1\ConsoleApp1\Program.cs:line 19


NCrunch always identifies the Xs by parsing the exception strings. I note that in your error message, there doesn't seem to be any line number associated with the error. Does the console application report the line number if you run it directly using the command line? Do you also see this with test projects?
daveleaver
#3 Posted : Monday, October 09, 2017 2:57:02 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/14/2012(UTC)
Posts: 8
Location: Hamilton, NZ

Thanks: 3 times
Was thanked: 1 time(s) in 1 post(s)
If I run it with 'dotnet run' it includes the line number.
If I put a try/catch around it and run it in the Visual Studio debugger, the line number is in the stack trace.

If I create a new project "xUnit Test Project (.NET Core)", and put the test in there, still no line number in ncrunch :(

Even this one doesn't get line numbers in ncrunch:
Code:

[Fact]
public void Test1()
{
    try
    {
        throw new Exception();
    }
    catch (Exception ex)
    {
        Console.WriteLine("Stack Trace: " + ex.StackTrace);
    }
    Assert.True(false);
}


Output:
Code:

Stack Trace: at XUnitTestProject1.UnitTest1.Test1()
Xunit.Sdk.TrueException: Assert.True() Failure
Expected: True
Actual: False
at Xunit.Assert.True(Nullable`1 condition, String userMessage)
at XUnitTestProject1.UnitTest1.Test1()


Anything else I could try to debug this?
Remco
#4 Posted : Monday, October 09, 2017 2:59:33 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 664 times
Was thanked: 780 time(s) in 742 post(s)
What happens if you turn off the 'Instrument output assembly' setting in NCrunch's project-level configuration? This should remove all the coverage markers, but I'm wondering if you get a line number in the error after you do this.
daveleaver
#5 Posted : Monday, October 09, 2017 3:20:50 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/14/2012(UTC)
Posts: 8
Location: Hamilton, NZ

Thanks: 3 times
Was thanked: 1 time(s) in 1 post(s)
No coverage, but no line numbers in the output either. Same output as in my last post.
Remco
#6 Posted : Monday, October 09, 2017 3:29:46 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 664 times
Was thanked: 780 time(s) in 742 post(s)
Ok, can you try the following?

1. Create a new .NET Core console application, add code under Program.Main to throw an exception
2. Enable NCrunch so the project is built by NCrunch
3. Right click on the project in the Tests Window, go to Advanced->Browse To Workspace
4. Find the console application dll/exe in the build output directory in the workspace
5. Run the application as it stands in the NCrunch workspace using dotnet.exe

Do you see the line number appear?

daveleaver
#7 Posted : Monday, October 09, 2017 3:40:19 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/14/2012(UTC)
Posts: 8
Location: Hamilton, NZ

Thanks: 3 times
Was thanked: 1 time(s) in 1 post(s)
It makes a .dll, not a .exe, but carrying on:

Code:

> dotnet HackCore2.dll

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'nCrunch.TestRuntime.DotNetCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=01d101bf6f3e0aea'. The system cannot find the file specified.
at HackCore2.Program.Main(String[] args)

(I tried copying the file from the ncrunch dir, but no luck)

If I disable 'Instrument output assembly', then it runs and does not include line numbers:
Code:

> dotnet HackCore2.dll

Unhandled Exception: System.Exception: Exception of type 'System.Exception' was thrown.
at HackCore2.Program.Main(String[] args)


Will use the contact form to submit the workspace folder with the built items.
Remco
#8 Posted : Monday, October 09, 2017 5:11:25 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 664 times
Was thanked: 780 time(s) in 742 post(s)
daveleaver;11337 wrote:

Will use the contact form to submit the workspace folder with the built items.


Thanks, this confirms that the problem happens at build time.

Could you try the following for me?

1. Go to your project file using a command prompt
2. Ensure all build artifacts under the project directory are clear (delete bin+obj)
3. Run MSBuild.exe against the project file to produce build outputs (you might need to find this under your VS install path, i.e. C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin)
4. Try running the newly built DLL
5. Do you get line numbers?
daveleaver
#9 Posted : Monday, October 09, 2017 8:00:10 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/14/2012(UTC)
Posts: 8
Location: Hamilton, NZ

Thanks: 3 times
Was thanked: 1 time(s) in 1 post(s)
This happens on both my Work and Home computers (Just tested at home with the ncrunch built exe). So possibly something I've done weirdly to both of them.

Following those instructions (Building with MSBuild), I get line numbers.
I had to run `dotnet restore` before I could run msbuild.

I've put logs up here:
https://gist.github.com/...c11b7907f29ee370b71f189f
alastairs
#10 Posted : Monday, October 09, 2017 2:14:40 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/13/2011(UTC)
Posts: 48
Location: Cambridge, UK

Thanks: 16 times
Was thanked: 3 time(s) in 3 post(s)
I see this on our projects too (looks like I get all the fun bugs 😃) I don't know if this is a common scenario, but we have a global.json file in our repo specifying the dotnet SDK version to use. It reads as follows:
Code:
{
  "sdk": {
    "version": "2.0.0"
  }
}


Ours is a hangover from the pre-SDK days (.NET Core 1.0). Might this be interacting with NCrunch in some way?
daveleaver
#11 Posted : Monday, October 09, 2017 9:04:34 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/14/2012(UTC)
Posts: 8
Location: Hamilton, NZ

Thanks: 3 times
Was thanked: 1 time(s) in 1 post(s)
I created a new Visual Studio VM on Azure and managed to reproduce the error there on a clean install.
I can give you access to it if you'd like, or you can create your own if you have a MSDN Sub.

Instructions:
Create an Azure VM using the image: Visual Studio Enterprise 2017 (latest release) on Windows 10 Enterprise N (x64)

Install dot net core sdk 2 x64 from:
https://download.microso...t-sdk-2.0.0-win-x64.exe

Install NCrunch_VS2017_3.11.0.9:
https://www.ncrunch.net/...ersion=3.11&vs=2017

Run VS 2017
Activate it
File, New, Project
.Net Core > Console App (.Net Core)
Right click dependencies, manage nuget dependencies, add xunit
Add Test code.
Build.
Enable NCrunch.

Exception is thrown without a line number.
Remco
#12 Posted : Tuesday, October 10, 2017 1:28:45 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 664 times
Was thanked: 780 time(s) in 742 post(s)
Thanks, I'll take a look and will let you know when I have more information.
1 user thanked Remco for this useful post.
daveleaver on 10/10/2017(UTC)
Remco
#13 Posted : Thursday, October 12, 2017 6:58:38 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 664 times
Was thanked: 780 time(s) in 742 post(s)
Ok, so this doesn't look like a simple problem to solve.

Some machines don't seem to have the ability to read windows/full PDB files under .NET Core. Strangely, on these same machines, they also won't try to build to the 'full' PDB type. They can only build portable PDBs under .NET Core.

It's a mystery as to why this is the case. Not all machines are affected by this. We've tried a range of different configurations including uninstalling/reinstalling older versions of .NET Core and Visual Studio, different versions of Windows, etc. We haven't been able to find any information about why this is the case, so it does feel a bit like something is missing in the install state or perhaps this is a bug in .NET Core.

The bigger issue here is that NCrunch is currently incapable of reading and writing portable PDB files, it can only work with the legacy windows PDB files. As a result, it forces your build system to build 'full' PDBs rather than portable ones, which then prevents .NET Core from reading the files downstream.

At the moment we're looking at making improvements to NCrunch so that it can work with portable PDB files. If anyone has any ideas about why some machines can't read windows PDBs under .NET Core, I'd love to hear them. This is not strictly just an 'NCrunch' problem.
1 user thanked Remco for this useful post.
daveleaver on 10/12/2017(UTC)
daveleaver
#14 Posted : Thursday, October 12, 2017 7:35:13 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/14/2012(UTC)
Posts: 8
Location: Hamilton, NZ

Thanks: 3 times
Was thanked: 1 time(s) in 1 post(s)
Wow... That a bit of a troublesome one!
Maybe try open an issue on one of the dotnet core repositories on github if you haven't already.
Thank you again for investigating this one! <3
1 user thanked daveleaver for this useful post.
michaelkroes on 10/13/2017(UTC)
piero
#15 Posted : Tuesday, October 24, 2017 2:13:43 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/10/2015(UTC)
Posts: 9
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
Hi,
I'm also experiencing this problem with .NET Core2 as I noticed I a missing the advertised inline exceptions, where I do not see the failing test reason, eg Expected<8>, Actual<2>
I only see the red dot saying that the line is covered by one failing test.
This example screenshot is in a new .net Core2 project, .net Framework shows the full error in the tooltip as expected.
It would be great to get this resolved as I'm surprised this has not been picked up sooner as this is a massive loss of functionality in NCrunch!!
I am using Windows 10 / Visual Studio 2017.

.net Core
Remco
#16 Posted : Tuesday, October 24, 2017 9:49:10 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 664 times
Was thanked: 780 time(s) in 742 post(s)
Hi piero,

Thanks for your input here. We're working hard to resolve this. The suddenness of this issue appears to be related to a significant change in the MS toolset that has made it impossible to build non-portable PDBs on many systems under .NET Core. As I'm not sure about the reason for this, I can't say whether I feel it's a bug or an intended direction. Regardless, it's a big job to upgrade NCrunch to handle the new portable PDBs. Hopefully we'll have something in the next release.
piero
#17 Posted : Wednesday, October 25, 2017 7:40:57 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/10/2015(UTC)
Posts: 9
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
Remco;11413 wrote:
Hi piero,

Thanks for your input here. We're working hard to resolve this. The suddenness of this issue appears to be related to a significant change in the MS toolset that has made it impossible to build non-portable PDBs on many systems under .NET Core. As I'm not sure about the reason for this, I can't say whether I feel it's a bug or an intended direction. Regardless, it's a big job to upgrade NCrunch to handle the new portable PDBs. Hopefully we'll have something in the next release.


Thanks for your quick reply...
The NCrunch Tests Window is able to display the full error message still, so is not just a case of updating the UI for the inline crosses & errors to appear? If you couldn't handle portable PDBs then surely I wouldn't be able to see any of these errors?

I appreciate if it's a big job to fix, but right now NCrunch in this state is only marginally better than VS Live Unit Testing, especially given how popular .NET Core is now becoming...

My apologies for the massive screenshots, the originals aren't this big :S

Test Window
Remco
#18 Posted : Wednesday, October 25, 2017 8:13:28 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 664 times
Was thanked: 780 time(s) in 742 post(s)
piero;11416 wrote:

The NCrunch Tests Window is able to display the full error message still, so is not just a case of updating the UI for the inline crosses & errors to appear? If you couldn't handle portable PDBs then surely I wouldn't be able to see any of these errors?


Exception traces can still work without PDBs, though they don't provide any line numbers. In this situation, it's the line numbers that are critically missing.

Behind the scenes here, NCrunch is forcing the build system to produce a non-portable PDB file, because this is the only format it's currently able to read. It's then able to read the PDB and reconstruct it through instrumentation. Unfortunately, the .NET Core runtime for some reason then cannot read the non-portable PDB, and we end up without line numbers.
GreenMoose
#19 Posted : Monday, November 20, 2017 8:54:13 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 326

Thanks: 55 times
Was thanked: 36 time(s) in 35 post(s)
FWIW, I also have this issue with missing line numbers in stack traces which is a real pain (I don't recall I had this issue before upgrading to netCore 2.0 :/).
If I run the test in Visual Studio Test Explorer, the line numbers are shown.

Is there something users can do to resolve this issue or is it just to wait for NCrunch to support portable PDB files?
Thanks.
Remco
#20 Posted : Monday, November 20, 2017 9:42:11 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 664 times
Was thanked: 780 time(s) in 742 post(s)
GreenMoose;11516 wrote:

Is there something users can do to resolve this issue or is it just to wait for NCrunch to support portable PDB files?


I'm raising this issue internally within MS to try and get more information about it. It seems strange the way it's suddenly appeared, and how it doesn't seem to affect all systems.

Introducing portable PDB support for NCrunch is proving to be a serious problem at the moment. Right now it looks like we'll be on this well up until Christmas, so finding a workaround is becoming a high priority. I had hoped to include the portable PDB work in the upcoming v3.12 release, but it looks like that won't be happening.

I'll update here as soon as I have more information.
1 user thanked Remco for this useful post.
GreenMoose on 11/20/2017(UTC)
Users browsing this topic
Guest (4)
2 Pages12>
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.105 seconds.