Skip to content

Support tests in VS 2022 #3035

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tools/packages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CSharpAsyncGenerator.CommandLine" Version="0.18.3" />
<PackageReference Include="CSharpAsyncGenerator.CommandLine" Version="0.18.4" />
<PackageReference Include="vswhere" Version="2.1.4" />
<PackageReference Include="NUnit.Console" Version="3.10.0" />
<PackageReference Include="GitReleaseManager" Version="0.11.0" />
Expand Down
5 changes: 4 additions & 1 deletion build-common/NHibernate.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
<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.0;netcoreapp2.1</NhAppTargetFrameworks>
<NhLibTargetFrameworks Condition ="$(NhLibTargetFrameworks) == ''">net461;netcoreapp2.0;netstandard2.0</NhLibTargetFrameworks>
<NhNetFx>false</NhNetFx>
<NhNetFx Condition="$(TargetFramework.StartsWith('net4'))">true</NhNetFx>
<DefineConstants Condition="$(NhNetFx) AND $(NhVbNet) == ''" >NETFX;$(DefineConstants)</DefineConstants>
<NhNetCoreApp>false</NhNetCoreApp>
<NhNetCoreApp Condition="$(TargetFramework.StartsWith('netcoreapp'))">true</NhNetCoreApp>
<DefineConstants Condition="$(NhNetCoreApp) AND $(NhVbNet) == ''" >NETCOREAPP2_0_OR_GREATER;$(DefineConstants)</DefineConstants>

<Product>NHibernate</Product>
<Company>NHibernate.info</Company>
Expand Down
2 changes: 1 addition & 1 deletion psake.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Task Test -depends Build {
'NHibernate.Test',
'NHibernate.Test.VisualBasic'
) | ForEach-Object {
$assembly = [IO.Path]::Combine("src", $_, "bin", "Release", "netcoreapp2.0", "$_.dll")
$assembly = [IO.Path]::Combine("src", $_, "bin", "Release", "netcoreapp2.1", "$_.dll")
Exec {
dotnet $assembly --labels=before --nocolor "--result=$_-TestResult.xml"
}
Expand Down
18 changes: 12 additions & 6 deletions src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<OptionExplicit>On</OptionExplicit>
<OptionStrict>On</OptionStrict>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<DefineConstants>NETCOREAPP2_0,$(DefineConstants)</DefineConstants>
<PropertyGroup Condition="$(NhNetCoreApp)">
<DefineConstants>NETCOREAPP2_0_OR_GREATER,$(DefineConstants)</DefineConstants>
<OutputType>Exe</OutputType>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>
Expand All @@ -22,7 +22,7 @@
<ItemGroup>
<None Remove="**\*.hbm.xml" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp2.0'">
<ItemGroup Condition="$(NhNetCoreApp)">
<Compile Remove="**\Issues\NH3302\**" />
</ItemGroup>
<ItemGroup>
Expand All @@ -34,11 +34,17 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" />
<PackageReference Include="Microsoft.VisualBasic" Version="10.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
</ItemGroup>
<ItemGroup Condition="$(NhNetFx)">
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PackageReference Include="NUnitLite" Version="3.12.0" />
<PackageReference Include="NUnitLite" Version="3.13.2" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="NUnitLite" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NHibernate\NHibernate.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions src/NHibernate.Test.VisualBasic/Program.vb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#If NETCOREAPP2_0
#If NETCOREAPP2_0_OR_GREATER
Public Class Program
Public Shared Function Main(args As String()) As Integer
Return New NUnitLite.AutoRun(GetType(Program).Assembly).Execute(args)
End Function
End Class
#End If
#End If
2 changes: 1 addition & 1 deletion src/NHibernate.Test/Async/Linq/WhereTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public void StringComparisonParamEmitsWarningAsync()
await (AssertStringComparisonWarningAsync(x => x.CustomerId.EndsWith("ANATR", StringComparison.Ordinal), 1));
await (AssertStringComparisonWarningAsync(x => x.CustomerId.IndexOf("ANATR", StringComparison.Ordinal) == 0, 1));
await (AssertStringComparisonWarningAsync(x => x.CustomerId.IndexOf("ANATR", 0, StringComparison.Ordinal) == 0, 1));
#if NETCOREAPP2_0
#if NETCOREAPP2_0_OR_GREATER
await (AssertStringComparisonWarningAsync(x => x.CustomerId.Replace("AN", "XX", StringComparison.Ordinal) == "XXATR", 1));
#endif
});
Expand Down
2 changes: 1 addition & 1 deletion src/NHibernate.Test/Linq/MathFTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP2_0
#if NETCOREAPP2_0_OR_GREATER
using System;
using System.Linq;
using System.Linq.Expressions;
Expand Down
2 changes: 1 addition & 1 deletion src/NHibernate.Test/Linq/WhereTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public void StringComparisonParamEmitsWarning()
AssertStringComparisonWarning(x => x.CustomerId.EndsWith("ANATR", StringComparison.Ordinal), 1);
AssertStringComparisonWarning(x => x.CustomerId.IndexOf("ANATR", StringComparison.Ordinal) == 0, 1);
AssertStringComparisonWarning(x => x.CustomerId.IndexOf("ANATR", 0, StringComparison.Ordinal) == 0, 1);
#if NETCOREAPP2_0
#if NETCOREAPP2_0_OR_GREATER
AssertStringComparisonWarning(x => x.CustomerId.Replace("AN", "XX", StringComparison.Ordinal) == "XXATR", 1);
#endif
});
Expand Down
20 changes: 15 additions & 5 deletions src/NHibernate.Test/NHibernate.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NoWarn>$(NoWarn);3001;3002;3003;3005</NoWarn>
<ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PropertyGroup Condition="$(NhNetCoreApp)">
<OutputType>Exe</OutputType>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>
Expand Down Expand Up @@ -35,7 +35,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp2.0'">
<ItemGroup Condition="$(NhNetCoreApp)">
<Compile Remove="**\CfgTest\DefaultNsAssmFixture.cs" />
<Compile Remove="**\CfgTest\HbmOrderingFixture.cs" />
<Compile Remove="**\DynamicProxyTests\PeVerifyFixture.cs" />
Expand All @@ -60,8 +60,7 @@
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.109.2" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.8.11" />
<PackageReference Include="NSubstitute" Version="3.1.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" />
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="6.6.0" />
<PackageReference Include="Npgsql" Version="5.0.11" />
Expand All @@ -72,6 +71,7 @@
<Reference Include="System.Transactions" />
<Reference Include="System.Threading.Tasks" />
<Reference Include="System.Data.OracleClient" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
<PackageReference Include="Microsoft.SqlServer.Compact" Version="4.0.8876.1" />
<PackageReference Include="Oracle.ManagedDataAccess" Version="12.1.2400" />
<PackageReference Include="MySql.Data" Version="6.9.11" />
Expand All @@ -82,8 +82,18 @@
<PackageReference Include="System.Data.OracleClient" Version="1.0.8" />
<PackageReference Include="System.Data.Odbc" Version="4.5.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="NUnitLite" Version="3.12.0" />
<PackageReference Include="MySql.Data" Version="6.10.6" />
<PackageReference Include="NUnitLite" Version="3.13.2" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp2.1'">
<PackageReference Include="System.CodeDom" Version="4.4.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.4.2" />
<PackageReference Include="System.Data.OracleClient" Version="1.0.8" />
<PackageReference Include="System.Data.Odbc" Version="4.5.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="MySql.Data" Version="6.10.6" />
<PackageReference Include="NUnitLite" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
</ItemGroup>
<ItemGroup Condition=" '$(NuGetPackageRoot)' != '' ">
<NativeBinaries Include="$(NuGetPackageRoot)microsoft.sqlserver.compact\4.0.8876.1\NativeBinaries\**\*.*" />
Expand Down
4 changes: 2 additions & 2 deletions src/NHibernate.Test/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP2_0
#if NETCOREAPP2_0_OR_GREATER
namespace NHibernate.Test
{
public class Program
Expand All @@ -9,4 +9,4 @@ public static int Main(string[] args)
}
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@
<IsTestProject>true</IsTestProject>
<NoWarn>$(NoWarn);3001;3002;3003;3005</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PropertyGroup Condition="$(NhNetCoreApp)">
<OutputType>Exe</OutputType>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\NHibernate.Test\NHibernate.Test.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
</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.

<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp2.0'">
<PackageReference Include="NUnitLite" Version="3.13.2" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp2.1'">
<PackageReference Include="NUnitLite" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
Expand Down
4 changes: 2 additions & 2 deletions src/NHibernate.TestDatabaseSetup/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP2_0
#if NETCOREAPP2_0_OR_GREATER
namespace NHibernate.TestDatabaseSetup
{
public class Program
Expand All @@ -9,4 +9,4 @@ public static int Main(string[] args)
}
}
}
#endif
#endif
4 changes: 2 additions & 2 deletions src/NHibernate/Collection/Generic/SetHelpers/SetSnapShot.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
#if NETCOREAPP2_0
#if NETCOREAPP2_0_OR_GREATER
using System.Runtime.Serialization;
using System.Threading;
#endif
Expand Down Expand Up @@ -132,7 +132,7 @@ void ICollection.CopyTo(Array array, int index)
}
#endif

#if NETCOREAPP2_0
#if NETCOREAPP2_0_OR_GREATER
[Serializable]
internal class SetSnapShot<T> : HashSet<T>, ICollection
{
Expand Down