Skip to content

Commit ecfa478

Browse files
authored
Run tests on .NET 6 (#2951)
1 parent 6576a96 commit ecfa478

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+121
-1632
lines changed

.config/dotnet-tools.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"isRoot": true,
44
"tools": {
55
"csharpasyncgenerator.tool": {
6-
"version": "0.19.1",
6+
"version": "0.20.1",
77
"commands": [
88
"async-generator"
99
]
1010
}
1111
}
12-
}
12+
}

.github/workflows/NetCoreTests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ jobs:
5454
5555
- uses: actions/checkout@v2
5656
- name: Setup .NET
57-
uses: actions/setup-dotnet@v1.8.0
57+
uses: actions/setup-dotnet@v1
5858
with:
59-
dotnet-version: 2.1.x
59+
dotnet-version: 6.0.x
6060

6161
- name: Build and Test
6262
run: |

ShowBuildMenu.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ testSetupMenu() {
172172
}
173173

174174
testRun(){
175-
dotnet test ./src/NHibernate.Test/NHibernate.Test.csproj -f netcoreapp2.0
176-
dotnet test ./src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj -f netcoreapp2.0
175+
dotnet test ./src/NHibernate.Test/NHibernate.Test.csproj -f net6.0
176+
dotnet test ./src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj -f net6.0
177177
mainMenu
178178
}
179179

Tools/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ csharpasyncgenerator.commandline/
44
gitreleasemanager/
55
obj/
66
microsoft.*
7+
netstandard.*

Tools/BuildTool/BuildTool.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
</PropertyGroup>
66
</Project>

appveyor.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version: '{build}'
2-
image: Visual Studio 2017
2+
image: Visual Studio 2022
33
environment:
44
matrix:
55
- DB: SqlServer2008
@@ -8,7 +8,7 @@ environment:
88
CONNECTION_STRING: Host=localhost;Port=5432;Username=postgres;Password=Password12!;Database=nhibernate;Enlist=true;
99
- DB: Firebird
1010
- DB: MySQL
11-
CONNECTION_STRING: Server=127.0.0.1;Uid=root;Pwd=Password12!;Database=nhibernate;Old Guids=True;SslMode=none;
11+
CONNECTION_STRING: Server=127.0.0.1;Uid=root;Pwd=Password12!;Database=nhibernate;Old Guids=True;SslMode=none;CharSet=utf8;
1212
- DB: SQLite
1313
init:
1414
# Required for having windows endlines in sources zip
@@ -42,7 +42,7 @@ before_test:
4242
Start-Service 'MySQL57'
4343
# Create nhibernate database (not handled by NHibernate.TestDatabaseSetup.dll)
4444
$env:MYSQL_PWD = 'Password12!'
45-
& 'C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql' -e 'CREATE DATABASE nhibernate;' --user=root
45+
& 'C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql' -e 'CREATE DATABASE nhibernate CHARACTER SET utf8 COLLATE utf8_general_ci;' --user=root
4646
}
4747
'Odbc' { Start-Service 'MSSQL$SQL2017' }
4848
'PostgreSQL' {

build-common/NHibernate.props

+10-7
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,26 @@
1313
<FileVersion Condition="'$(VersionSuffix)' != '' AND '$(BuildNumber)' != ''">$(VersionPrefix).$(BuildNumber)</FileVersion>
1414
<FileVersion Condition="'$(FileVersion)' == ''">$(VersionPrefix).0</FileVersion>
1515

16-
<NhAppTargetFrameworks Condition ="$(NhAppTargetFrameworks) == ''">net461;netcoreapp2.0</NhAppTargetFrameworks>
16+
<NhAppTargetFrameworks Condition ="$(NhAppTargetFrameworks) == ''">net461;net6.0</NhAppTargetFrameworks>
1717
<NhLibTargetFrameworks Condition ="$(NhLibTargetFrameworks) == ''">net461;netcoreapp2.0;netstandard2.0</NhLibTargetFrameworks>
1818
<NhNetFx>false</NhNetFx>
1919
<NhNetFx Condition="$(TargetFramework.StartsWith('net4'))">true</NhNetFx>
20-
<DefineConstants Condition="$(NhNetFx) AND $(NhVbNet) == ''" >NETFX;$(DefineConstants)</DefineConstants>
20+
<!-- Visual Basic requires to use coma (,) as a separator, other project types - semicolon (;) -->
21+
<DefineConstants Condition="$(NhNetFx) AND '$(MSBuildProjectExtension)' != '.vbproj'">NETFX;$(DefineConstants)</DefineConstants>
22+
<DefineConstants Condition="$(NhNetFx) AND '$(MSBuildProjectExtension)' == '.vbproj'">NETFX,$(DefineConstants)</DefineConstants>
2123

2224
<Product>NHibernate</Product>
2325
<Company>NHibernate.info</Company>
2426
<Copyright>Licensed under LGPL.</Copyright>
2527
<Authors>NHibernate community, Hibernate community</Authors>
2628
<NeutralLanguage>en-US</NeutralLanguage>
2729

30+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
31+
<TreatSpecificWarningsAsErrors />
32+
33+
<DisableImplicitPackageTargetFallback>True</DisableImplicitPackageTargetFallback>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(IsPackable)' == 'True'">
2836
<PackageProjectUrl>https://nhibernate.info</PackageProjectUrl>
2937
<PackageIconUrl>https://raw.githubusercontent.com/nhibernate/nhibernate-core/master/logo/NHibernate-NuGet.png</PackageIconUrl>
3038
<PackageIcon>NHibernate-NuGet.png</PackageIcon>
@@ -35,11 +43,6 @@
3543
<PublishRepositoryUrl>true</PublishRepositoryUrl>
3644
<IncludeSymbols>true</IncludeSymbols>
3745
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
38-
39-
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
40-
<TreatSpecificWarningsAsErrors />
41-
42-
<DisableImplicitPackageTargetFallback>True</DisableImplicitPackageTargetFallback>
4346
</PropertyGroup>
4447
<ItemGroup>
4548
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />

global.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"version": "6.0.101",
4+
"rollForward": "latestFeature"
5+
}
6+
}

psake.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Task Test -depends Build {
113113
'NHibernate.Test',
114114
'NHibernate.Test.VisualBasic'
115115
) | ForEach-Object {
116-
$assembly = [IO.Path]::Combine("src", $_, "bin", "Release", "netcoreapp2.0", "$_.dll")
116+
$assembly = [IO.Path]::Combine("src", $_, "bin", "Release", "net6.0", "$_.dll")
117117
Exec {
118118
dotnet $assembly --labels=before --nocolor "--result=$_-TestResult.xml"
119119
}

src/AsyncGenerator.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
scanForMissingAsyncMembers:
188188
- all: true
189189
- filePath: NHibernate.Test/NHibernate.Test.csproj
190-
targetFramework: netcoreapp2.0
190+
targetFramework: net6.0
191191
concurrentRun: true
192192
applyChanges: true
193193
suppressDiagnosticFailures:
@@ -230,6 +230,15 @@
230230
- filePathEndsWith: Linq/MathTests.cs
231231
- filePathEndsWith: Linq/ExpressionSessionLeakTest.cs
232232
- filePathEndsWith: Linq/NorthwindDbCreator.cs
233+
ignoreSearchForAsyncCounterparts:
234+
- name: Wait
235+
containingTypeName: Task
236+
- name: Prepare
237+
containingTypeName: DbCommand
238+
- name: Close
239+
containingTypeName: DbConnection
240+
- name: Close
241+
containingTypeName: DbDataReader
233242
cancellationTokens:
234243
enabled: true
235244
scanMethodBody: true

src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<NhVbNet>true</NhVbNet>
4-
</PropertyGroup>
52
<Import Project="../../build-common/NHibernate.props" />
63
<PropertyGroup>
74
<Description>The Visual Basic Unit Tests for NHibernate.</Description>
@@ -11,18 +8,14 @@
118
<OptionExplicit>On</OptionExplicit>
129
<OptionStrict>On</OptionStrict>
1310
</PropertyGroup>
14-
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
15-
<DefineConstants>NETCOREAPP2_0,$(DefineConstants)</DefineConstants>
11+
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
1612
<OutputType>Exe</OutputType>
1713
<GenerateProgramFile>false</GenerateProgramFile>
1814
</PropertyGroup>
19-
<PropertyGroup Condition="$(NhNetFx)">
20-
<DefineConstants>NETFX,$(DefineConstants)</DefineConstants>
21-
</PropertyGroup>
2215
<ItemGroup>
2316
<None Remove="**\*.hbm.xml" />
2417
</ItemGroup>
25-
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp2.0'">
18+
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
2619
<Compile Remove="**\Issues\NH3302\**" />
2720
</ItemGroup>
2821
<ItemGroup>
@@ -32,12 +25,12 @@
3225
<None Include="..\NHibernate.Test\App.config" Link="App.config" />
3326
</ItemGroup>
3427
<ItemGroup>
35-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
28+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
3629
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
3730
<PackageReference Include="NUnit" Version="3.13.2" />
38-
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
31+
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
3932
</ItemGroup>
40-
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
33+
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
4134
<PackageReference Include="NUnitLite" Version="3.13.2" />
4235
</ItemGroup>
4336
<ItemGroup>

src/NHibernate.Test.VisualBasic/Program.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#If NETCOREAPP2_0
1+
#If NETCOREAPP2_0_OR_GREATER
22
Public Class Program
33
Public Shared Function Main(args As String()) As Integer
44
Return New NUnitLite.AutoRun(GetType(Program).Assembly).Execute(args)

src/NHibernate.Test/Async/Criteria/EntityJoinCriteriaTest.cs

+6
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public async Task EntityProjectionForEntityJoinAsync()
205205
[Test]
206206
public async Task MixOfJoinsForAssociatedAndNotAssociatedEntitiesAsync()
207207
{
208+
#pragma warning disable CS8073 //The result of the expression is always 'false'
208209
using (var sqlLog = new SqlLogSpy())
209210
using (var session = OpenSession())
210211
{
@@ -223,6 +224,7 @@ public async Task MixOfJoinsForAssociatedAndNotAssociatedEntitiesAsync()
223224
.Take(1)
224225
.SingleOrDefaultAsync<object>());
225226
}
227+
#pragma warning restore CS8073 //The result of the expression is always 'false'
226228
}
227229

228230
[Test]
@@ -248,6 +250,7 @@ public async Task EntityJoinForCompositeKeyAsync()
248250
[Test]
249251
public async Task NullLeftEntityJoinAsync()
250252
{
253+
#pragma warning disable CS8073 //The result of the expression is always 'false'
251254
using (var sqlLog = new SqlLogSpy())
252255
using (var session = OpenSession())
253256
{
@@ -263,11 +266,13 @@ public async Task NullLeftEntityJoinAsync()
263266
Assert.That(NHibernateUtil.IsInitialized(root), Is.True);
264267
Assert.That(sqlLog.Appender.GetEvents().Length, Is.EqualTo(1), "Only one SQL select is expected");
265268
}
269+
#pragma warning restore CS8073 //The result of the expression is always 'false'
266270
}
267271

268272
[Test]
269273
public async Task NullLeftEntityJoinWithEntityProjectionAsync()
270274
{
275+
#pragma warning disable CS8073 //The result of the expression is always 'false'
271276
using (var sqlLog = new SqlLogSpy())
272277
using (var session = OpenSession())
273278
{
@@ -287,6 +292,7 @@ public async Task NullLeftEntityJoinWithEntityProjectionAsync()
287292
Assert.That(ejLeftNull, Is.Null, "Entity join should be null");
288293
Assert.That(sqlLog.Appender.GetEvents().Length, Is.EqualTo(1), "Only one SQL select is expected");
289294
}
295+
#pragma warning restore CS8073 //The result of the expression is always 'false'
290296
}
291297

292298
[Test]

src/NHibernate.Test/Async/Criteria/EntityProjectionsTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ public async Task EntityProjectionWithLazyPropertiesSinglePropertyFetchAsync()
376376
[Test]
377377
public async Task NullEntityProjectionAsync()
378378
{
379+
#pragma warning disable CS8073 //The result of the expression is always 'false'
379380
using (var session = OpenSession())
380381
{
381382
EntitySimpleChild child1 = null;
@@ -388,6 +389,7 @@ public async Task NullEntityProjectionAsync()
388389

389390
Assert.That(child1, Is.Null);
390391
}
392+
#pragma warning restore CS8073 //The result of the expression is always 'false'
391393
}
392394

393395
[Test]

src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ public async Task NullableEntityProjectionAsync()
346346
var withNullManyToOneList = await (session.Query<NullableOwner>().Where(x => x.ManyToOne == null).ToListAsync());
347347
var withNullManyToOneJoinedList =
348348
await ((from x in session.Query<NullableOwner>()
349-
from x2 in session.Query<NullableOwner>()
350-
where x == x2 && x.ManyToOne == null && x.OneToOne.Name == null
351-
select x2).ToListAsync());
349+
from x2 in session.Query<NullableOwner>()
350+
where x == x2 && x.ManyToOne == null && x.OneToOne.Name == null
351+
select x2).ToListAsync());
352352
Assert.That(fullList.Count, Is.EqualTo(2));
353353
Assert.That(withValidManyToOneList.Count, Is.EqualTo(0));
354354
Assert.That(withValidManyToOneList2.Count, Is.EqualTo(0));

0 commit comments

Comments
 (0)