Skip to content
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

Merged

Conversation

fredericDelaporte
Copy link
Member

@fredericDelaporte fredericDelaporte commented Mar 13, 2022

Tests fail to run in VS 2022, which is unpractical.

@fredericDelaporte fredericDelaporte added this to the 5.3.12 milestone Mar 13, 2022
fredericDelaporte added a commit to fredericDelaporte/nhibernate-core that referenced this pull request Mar 13, 2022
@@ -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>
Copy link
Member Author

@fredericDelaporte fredericDelaporte Mar 13, 2022

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?

Copy link
Member

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.

@@ -183,7 +183,7 @@
scanForMissingAsyncMembers:
- all: true
- filePath: NHibernate.Test/NHibernate.Test.csproj
targetFramework: netcoreapp2.0
targetFramework: netcoreapp2.1
Copy link
Member Author

@fredericDelaporte fredericDelaporte Mar 13, 2022

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.

Copy link
Contributor

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.

Copy link
Member Author

@fredericDelaporte fredericDelaporte Mar 27, 2022

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?

Copy link
Contributor

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
Copy link
Member Author

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.

@fredericDelaporte fredericDelaporte changed the title WIP - Supports tests in VS 2022 Supports tests in VS 2022 Mar 26, 2022
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ItemGroup Condition="$(NhNetFx)">
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

@fredericDelaporte fredericDelaporte Apr 3, 2022

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.

@fredericDelaporte fredericDelaporte merged commit b116a3f into nhibernate:5.3.x Apr 8, 2022
@fredericDelaporte fredericDelaporte deleted the support-vs2022 branch April 8, 2022 21:51
@fredericDelaporte fredericDelaporte changed the title Supports tests in VS 2022 Support tests in VS 2022 Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants