-
Notifications
You must be signed in to change notification settings - Fork 934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support tests in VS 2022 #3035
Support tests in VS 2022 #3035
Conversation
fc533ea
to
276feb4
Compare
build-common/NHibernate.props
Outdated
@@ -13,7 +13,7 @@ | |||
<FileVersion Condition="'$(VersionSuffix)' != '' AND '$(BuildNumber)' != ''">$(VersionPrefix).$(BuildNumber)</FileVersion> | |||
<FileVersion Condition="'$(FileVersion)' == ''">$(VersionPrefix).0</FileVersion> | |||
|
|||
<NhAppTargetFrameworks Condition ="$(NhAppTargetFrameworks) == ''">net461;netcoreapp2.0</NhAppTargetFrameworks> | |||
<NhAppTargetFrameworks Condition ="$(NhAppTargetFrameworks) == ''">net461;netcoreapp2.1</NhAppTargetFrameworks> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to run tests in VS 2022, the NUnit test adapter has to be updated to its fourth version at least. But this version does no more support the netcoreapp2.0 target, and requires at least netcoreapp2.1.
May we have better to directly target net6.0 for our tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 2.1 should be enough.
src/AsyncGenerator.yml
Outdated
@@ -183,7 +183,7 @@ | |||
scanForMissingAsyncMembers: | |||
- all: true | |||
- filePath: NHibernate.Test/NHibernate.Test.csproj | |||
targetFramework: netcoreapp2.0 | |||
targetFramework: netcoreapp2.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have upgraded only the test project. Unfortunately, it seems the async generator does not support generating a project for core 2.1 which depends on core 2.0 libs : it tries to compile the 2.0 libs as 2.1 libs.
@maca88
A workaround would be to add a core 2.1 target to the NHibernate libs too, but just for being able able to runs tests in VS2022, it sounds overkill to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it seems the async generator does not support generating a project for core 2.1 which depends on core 2.0 libs : it tries to compile the 2.0 libs as 2.1 libs.
I do apologize as I didn't saw this earlier. Unfortunately, I didn't found a workaround yet that would not require to add netcoreapp2.1
to other projects.
A workaround would be to add a core 2.1 target to the NHibernate libs too
Another workaround would be to use netcoreapp3.1
for the test project which works fine as opposed to netcoreapp2.1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No apologies are required! We are all contributors on our free time, no one is supposed to have any "SLA" with short response time, ...
Thanks for your investigation. So, you say it work well to generate async code for a project targeting 3.1 and referencing a project targeting 2.0?
That would be better than my current workaround, targeting both 2.0 and 2.1 in the test project and generating async for 2.0. @hazzik, are you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you say it work well to generate async code for a project targeting 3.1 and referencing project targeting 2.0?
That is correct, here you can find the changes that I used to test 3.1
.
@@ -1,7 +1,7 @@ | |||
using System; | |||
using System.Collections; | |||
using System.Collections.Generic; | |||
#if NETCOREAPP2_0 | |||
#if NETCOREAPP2_0 || NETCOREAPP2_1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is directly included as source in the test project too. So here we need to handle core 2.0 and 2.1 compilation.
3b6ac4c
to
8176ac8
Compare
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'"> | ||
<PackageReference Include="NUnitLite" Version="3.12.0" /> | ||
<ItemGroup Condition="$(NhNetFx)"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and 2 following groups are confusing, I'm not sure I understand the intention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
netcoreapp2.0 cannot compile with a reference to NUnit3TestAdapter. So it has to be referenced only for netFx and 2.1.
Maybe I should not mix $(NhNetCoreApp) references (for both 2.0 and 2.1) and explicit 2.1 references, for easing understanding what is done.
Or even maybe I could just drop the NUniteLite reference for 2.0 too, I have not checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot remove NUniteLite reference for netcoreap2.0, or else I would have to use a NETCOREAPP2_1
only condition in test program files, instead of using the NETCOREAPP2_0_OR_GREATER
condition already in master.
So I have changed for using explicit target framework references for netcore, which duplicates quite a few references for the main test project.
Tests fail to run in VS 2022, which is unpractical.