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

Notification

Icon
Error

Using generic ActionResult from aspnet core 3.0.0.0 results in build failure
debgz
#1 Posted : Friday, November 22, 2019 10:50:22 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/22/2019(UTC)
Posts: 4
Location: Germany

Was thanked: 1 time(s) in 1 post(s)
I am currently building an aspnet core 3.0 web api with a core 3.0 test project.
In my controller Method I use the generic version of ActionResult as return value.
If I now try to write a test containing this particular class, ncrunch tells me the following:

Code:

CSC (0, 0): Assembly "RecipeBuilderApplicationApi" mit Identität "RecipeBuilderApplicationApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" verwendet "Microsoft.AspNetCore.Mvc.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" mit einer höheren Version als die referenzierte Assembly "Microsoft.AspNetCore.Mvc.Core" mit Identität "Microsoft.AspNetCore.Mvc.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60".
Controller\ToolControllerTest.cs (34, 13): Typ "ActionResult" ist nicht generisch und kann daher nicht mit Typargumenten verwendet werden.
Controller\ToolControllerTest.cs (34, 64): Assembly "RecipeBuilderApplicationApi" mit Identität "RecipeBuilderApplicationApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" verwendet "Microsoft.AspNetCore.Mvc.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" mit einer höheren Version als die referenzierte Assembly "Microsoft.AspNetCore.Mvc.Core" mit Identität "Microsoft.AspNetCore.Mvc.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60".


Seems like ncrunch is using version 1.0.3.0 from Mvc.Core whilst I use version 3.0.0.0 therefore not finding the generic version of ActionResult.
Ncrunch however seems fine when building the webapi project. It just refuses to build the test project.

Controller:
Code:

public async Task<ActionResult<IList<ToolDto>>> GetRelevantTools() {


Test:
Code:

ActionResult<IList<ToolDto>> relevantTools = await toolController.GetRelevantTools();


What do I need to do to tell ncrunch to use version 3.0.0.0 in the test project?



Just created a small webApi/Nunit test project from default vs2019 templates and I am not able to get ncrunch to build the test project:

Code:

NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/documentation/troubleshooting_project-build-issues
UnitTest1.cs (2, 17): Der Typ- oder Namespacename "AspNetCore" ist im Namespace "Microsoft" nicht vorhanden. (Möglicherweise fehlt ein Assemblyverweis.)
UnitTest1.cs (3, 28): Der Typ- oder Namespacename "Logging" ist im Namespace "Microsoft.Extensions" nicht vorhanden. (Möglicherweise fehlt ein Assemblyverweis.)


It tells type or namespace AspNetCore and Logging is missing. Strange thing is that it runs just fine in Resharper testrunner.
Same applies for the main problem. It runs just fine within resharper.
michaelkroes
#2 Posted : Friday, November 22, 2019 1:16:07 PM(UTC)
Rank: NCrunch Developer

Groups: Registered
Joined: 9/22/2017(UTC)
Posts: 277
Location: Netherlands

Thanks: 122 times
Was thanked: 62 time(s) in 59 post(s)
Thanks for posting!

Could you please confirm which version of NCrunch you are using?
debgz
#3 Posted : Friday, November 22, 2019 4:22:54 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/22/2019(UTC)
Posts: 4
Location: Germany

Was thanked: 1 time(s) in 1 post(s)
I think its NCrunch 4.1 but will double check on monday.
Using it in VS2019 on Win10 (nearly latest).

But maybe I am just using 4.0 and this one gets me: "Fixed an issue that would cause an exception when trying to process a generic class containing an async
method under optimised mode."
Remco
#4 Posted : Friday, November 22, 2019 10:43:44 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 930 times
Was thanked: 1257 time(s) in 1170 post(s)
Thanks for sharing these extra details. We haven't knowingly fixed this issue in v4.1 (the generic class exception was something else).

Is there any chance you could ZIP up your sample project that reproduces the problem and send it through the NCrunch contact form? We can then take a look and try to figure this out.
debgz
#5 Posted : Monday, November 25, 2019 6:50:12 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/22/2019(UTC)
Posts: 4
Location: Germany

Was thanked: 1 time(s) in 1 post(s)
Just checked the version and yes, its 4.1.0.1 Send a sample project through the contact form.
The sample was generated using stock vs2019 webapi template and stock nunit test project template.
It does not matter which intrumentation mode I use nor if I set "Copy referenced ..." to true on the test project.

I get the following errors on the test project:

Code:

NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/documentation/troubleshooting_project-build-issues
UnitTest1.cs (2, 17): Der Typ- oder Namespacename "AspNetCore" ist im Namespace "Microsoft" nicht vorhanden. (Möglicherweise fehlt ein Assemblyverweis.)
UnitTest1.cs (3, 28): Der Typ- oder Namespacename "Logging" ist im Namespace "Microsoft.Extensions" nicht vorhanden. (Möglicherweise fehlt ein Assemblyverweis.)


The main project seems to build just fine.
Remco
#6 Posted : Tuesday, November 26, 2019 12:11:40 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 930 times
Was thanked: 1257 time(s) in 1170 post(s)
Thanks! We're looking at this now and will get back to you soon.
Remco
#7 Posted : Monday, December 2, 2019 7:33:05 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 930 times
Was thanked: 1257 time(s) in 1170 post(s)
debgz
#8 Posted : Monday, December 2, 2019 8:37:31 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/22/2019(UTC)
Posts: 4
Location: Germany

Was thanked: 1 time(s) in 1 post(s)
Ohhh yes. Fixed. Thank you!
1 user thanked debgz for this useful post.
Remco on 12/3/2019(UTC)
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.052 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download