Skip to content

Commit 691e45b

Browse files
authored
Add .NET 8.0 target (#3494)
1 parent 0c3c705 commit 691e45b

File tree

74 files changed

+277
-79
lines changed

Some content is hidden

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

74 files changed

+277
-79
lines changed

.config/dotnet-tools.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"csharpasyncgenerator.tool": {
6-
"version": "0.21.1",
6+
"version": "0.22.0",
77
"commands": [
88
"async-generator"
99
]

.github/workflows/GenerateAsyncCode.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup .NET
2222
uses: actions/setup-dotnet@v4
2323
with:
24-
dotnet-version: 6.0.x
24+
dotnet-version: 8.0.x
2525

2626
- name: Generate Async code
2727
run: |

.github/workflows/NetCoreTests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
- name: Setup .NET
5252
uses: actions/setup-dotnet@v4
5353
with:
54-
dotnet-version: 6.0.x
54+
dotnet-version: 8.0.x
5555

5656
- name: Build and Test
5757
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 net6.0
176-
dotnet test ./src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj -f net6.0
175+
dotnet test ./src/NHibernate.Test/NHibernate.Test.csproj -f net8.0
176+
dotnet test ./src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj -f net8.0
177177
mainMenu
178178
}
179179

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>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
</PropertyGroup>
66
</Project>

build-common/NHibernate.props

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,24 @@
66
<VersionPatch Condition="'$(VersionPatch)' == ''">0</VersionPatch>
77
<!-- Clear VersionSuffix for making release and set it to dev for making development builds -->
88
<VersionSuffix Condition="'$(VersionSuffix)' == ''">dev</VersionSuffix>
9-
<LangVersion Condition="'$(MSBuildProjectExtension)' != '.vbproj'">9.0</LangVersion>
9+
<LangVersion Condition="'$(MSBuildProjectExtension)' != '.vbproj'">12.0</LangVersion>
1010

1111
<VersionPrefix Condition="'$(VersionPrefix)' == ''">$(NhVersion).$(VersionPatch)</VersionPrefix>
1212
<VersionSuffix Condition="'$(VersionSuffix)' != '' AND '$(BuildNumber)' != ''">$(VersionSuffix).$(BuildNumber)</VersionSuffix>
1313
<AssemblyVersion>$(NhVersion).0.0</AssemblyVersion>
1414
<FileVersion Condition="'$(VersionSuffix)' != '' AND '$(BuildNumber)' != ''">$(VersionPrefix).$(BuildNumber)</FileVersion>
1515
<FileVersion Condition="'$(FileVersion)' == ''">$(VersionPrefix).0</FileVersion>
1616

17-
<NhAppTargetFrameworks Condition ="$(NhAppTargetFrameworks) == ''">net48;net6.0</NhAppTargetFrameworks>
18-
<NhLibTargetFrameworks Condition ="$(NhLibTargetFrameworks) == ''">net461;net48;netcoreapp2.0;netstandard2.0;netstandard2.1;net6.0</NhLibTargetFrameworks>
17+
<NhAppTargetFrameworks Condition ="$(NhAppTargetFrameworks) == ''">net48;net8.0</NhAppTargetFrameworks>
18+
<NhLibTargetFrameworks Condition ="$(NhLibTargetFrameworks) == ''">net461;net48;netcoreapp2.0;netstandard2.0;netstandard2.1;net6.0;net8.0</NhLibTargetFrameworks>
1919
<NhNetFx>false</NhNetFx>
2020
<NhNetFx Condition="$(TargetFramework.StartsWith('net4'))">true</NhNetFx>
2121
<!-- Visual Basic requires to use coma (,) as a separator, other project types - semicolon (;) -->
2222
<DefineConstants Condition="$(NhNetFx) AND '$(MSBuildProjectExtension)' != '.vbproj'">NETFX;$(DefineConstants)</DefineConstants>
2323
<DefineConstants Condition="$(NhNetFx) AND '$(MSBuildProjectExtension)' == '.vbproj'">NETFX,$(DefineConstants)</DefineConstants>
24+
<NoWarn>$(NoWarn);NU1903</NoWarn>
2425
<NoWarn Condition="'$(TargetFramework)' == 'net6.0'">$(NoWarn);SYSLIB0011</NoWarn>
26+
<NoWarn Condition="'$(TargetFramework)' == 'net8.0'">$(NoWarn);SYSLIB0011;SYSLIB0050;SYSLIB0051</NoWarn>
2527

2628
<Product>NHibernate</Product>
2729
<Company>NHibernate.info</Company>

global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "6.0.101",
3+
"version": "8.0.100",
44
"rollForward": "latestFeature"
55
}
66
}

psake.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Task Test -depends Build {
132132
'NHibernate.Test',
133133
'NHibernate.Test.VisualBasic'
134134
) | ForEach-Object {
135-
$assembly = [IO.Path]::Combine("src", $_, "bin", "Release", "net6.0", "$_.dll")
135+
$assembly = [IO.Path]::Combine("src", $_, "bin", "Release", "net8.0", "$_.dll")
136136
Exec {
137137
dotnet $assembly --labels=before --nocolor "--result=$_-TestResult.xml"
138138
}

src/AsyncGenerator.yml

+1-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: net6.0
190+
targetFramework: net8.0
191191
concurrentRun: true
192192
applyChanges: true
193193
suppressDiagnosticFailures:

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
<OptionExplicit>On</OptionExplicit>
99
<OptionStrict>On</OptionStrict>
1010
</PropertyGroup>
11-
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
11+
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
1212
<OutputType>Exe</OutputType>
1313
<GenerateProgramFile>false</GenerateProgramFile>
1414
</PropertyGroup>
1515
<ItemGroup>
1616
<None Remove="**\*.hbm.xml" />
1717
</ItemGroup>
18-
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
18+
<ItemGroup Condition="'$(TargetFramework)'=='net8.0'">
1919
<Compile Remove="**\Issues\NH3302\**" />
2020
</ItemGroup>
2121
<ItemGroup>
@@ -30,7 +30,7 @@
3030
<PackageReference Include="NUnit" Version="3.14.0" />
3131
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
3232
</ItemGroup>
33-
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
33+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
3434
<PackageReference Include="NUnitLite" Version="3.14.0" />
3535
</ItemGroup>
3636
<ItemGroup>

src/NHibernate.Test/Async/CacheTest/SerializationFixture.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
namespace NHibernate.Test.CacheTest
3131
{
3232
using System.Threading.Tasks;
33+
using System.Threading;
3334
[TestFixture]
3435
public class SerializationFixtureAsync
3536
{
@@ -312,11 +313,11 @@ private void CheckObjectTypeCacheEntry(AnyType.ObjectTypeCacheEntry original, An
312313
Assert.That(copy.EntityName, Is.EqualTo(original.EntityName));
313314
}
314315

315-
private static async Task<T> TestDataContractSerializerAsync<T>(T obj)
316+
private static async Task<T> TestDataContractSerializerAsync<T>(T obj, CancellationToken cancellationToken = default(CancellationToken))
316317
{
317-
var xml = await (DataContractSerializerToXmlAsync(obj));
318+
var xml = await (DataContractSerializerToXmlAsync(obj, cancellationToken));
318319
obj = DataContractSerializerFromXml<T>(xml);
319-
Assert.That(xml, Is.EqualTo(await (DataContractSerializerToXmlAsync(obj))));
320+
Assert.That(xml, Is.EqualTo(await (DataContractSerializerToXmlAsync(obj, cancellationToken))));
320321
return obj;
321322
}
322323

@@ -328,15 +329,15 @@ private static T TestBinaryFormatter<T>(T obj)
328329
return obj;
329330
}
330331

331-
private static async Task<string> DataContractSerializerToXmlAsync<T>(T obj)
332+
private static async Task<string> DataContractSerializerToXmlAsync<T>(T obj, CancellationToken cancellationToken = default(CancellationToken))
332333
{
333334
using (var memoryStream = new MemoryStream())
334335
using (var reader = new StreamReader(memoryStream))
335336
{
336337
var serializer = new DataContractSerializer(typeof(T), KnownTypes);
337338
serializer.WriteObject(memoryStream, obj);
338339
memoryStream.Position = 0;
339-
return await (reader.ReadToEndAsync());
340+
return await (reader.ReadToEndAsync(cancellationToken));
340341
}
341342
}
342343

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#if !NET8_0_OR_GREATER
2+
using System.IO;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
6+
namespace NHibernate.Test.CacheTest;
7+
8+
internal static class TextReaderExtensions
9+
{
10+
public static Task<string> ReadToEndAsync(this TextReader reader, CancellationToken cancellationToken) =>
11+
cancellationToken.IsCancellationRequested
12+
? Task.FromCanceled<string>(cancellationToken)
13+
: reader.ReadToEndAsync();
14+
}
15+
#endif

src/NHibernate.Test/NHibernate.Test.csproj

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
<Description>The Unit Tests for NHibernate.</Description>
55
<TargetFrameworks>$(NhAppTargetFrameworks)</TargetFrameworks>
66
<IsTestProject>true</IsTestProject>
7-
<NoWarn>$(NoWarn);3001;3002;3003;3005;SYSLIB0003;SYSLIB0012</NoWarn>
7+
<NoWarn>$(NoWarn);3001;3002;3003;3005;8981;SYSLIB0003;SYSLIB0012</NoWarn>
88
<ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles>
9+
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
910
</PropertyGroup>
10-
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
11+
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
1112
<OutputType>Exe</OutputType>
1213
<GenerateProgramFile>false</GenerateProgramFile>
1314
</PropertyGroup>
@@ -38,7 +39,7 @@
3839
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3940
</Content>
4041
</ItemGroup>
41-
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
42+
<ItemGroup Condition="'$(TargetFramework)'=='net8.0'">
4243
<Compile Remove="**\CfgTest\DefaultNsAssmFixture.cs" />
4344
<Compile Remove="**\CfgTest\HbmOrderingFixture.cs" />
4445
<Compile Remove="**\DynamicProxyTests\PeVerifyFixture.cs" />
@@ -63,7 +64,7 @@
6364
<ItemGroup>
6465
<PackageReference Include="log4net" Version="2.0.15" />
6566
<PackageReference Include="Microsoft.AspNetCore.OData" Version="7.7.0" />
66-
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.1.3" />
67+
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.1.5" />
6768
<PackageReference Include="NHibernate.Caches.CoreDistributedCache.Memory" Version="5.9.0" />
6869
<PackageReference Include="NHibernate.Caches.Util.JsonSerializer" Version="5.9.0" />
6970
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.117" />
@@ -86,10 +87,10 @@
8687
<PackageReference Include="Microsoft.SqlServer.Compact" Version="4.0.8876.1" />
8788
<PackageReference Include="Oracle.ManagedDataAccess" Version="21.10.0" />
8889
</ItemGroup>
89-
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
90-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.1" />
90+
<ItemGroup Condition="'$(TargetFramework)'=='net8.0'">
91+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.0" />
9192
<PackageReference Include="System.CodeDom" Version="4.7.0" />
92-
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
93+
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
9394
<PackageReference Include="System.Data.OracleClient" Version="1.0.8" />
9495
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.100" />
9596
<PackageReference Include="System.Data.Odbc" Version="4.7.0" />

src/NHibernate.TestDatabaseSetup/NHibernate.TestDatabaseSetup.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<IsTestProject>true</IsTestProject>
88
<NoWarn>$(NoWarn);3001;3002;3003;3005</NoWarn>
99
</PropertyGroup>
10-
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
10+
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
1111
<OutputType>Exe</OutputType>
1212
<GenerateProgramFile>false</GenerateProgramFile>
1313
</PropertyGroup>
@@ -18,7 +18,7 @@
1818
<PackageReference Include="NUnit" Version="3.14.0" />
1919
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
2020
</ItemGroup>
21-
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
21+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
2222
<PackageReference Include="NUnitLite" Version="3.14.0" />
2323
</ItemGroup>
2424
<ItemGroup>

src/NHibernate.sln

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1212
..\build-common\common.xml = ..\build-common\common.xml
1313
..\appveyor.yml = ..\appveyor.yml
1414
..\ReleaseProcedure.txt = ..\ReleaseProcedure.txt
15+
..\global.json = ..\global.json
1516
EndProjectSection
1617
EndProject
1718
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHibernate", "NHibernate\NHibernate.csproj", "{5909BFE7-93CF-4E5F-BE22-6293368AF01D}"

src/NHibernate/ADOException.cs

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class ADOException : HibernateException
2121
public ADOException()
2222
{
2323
}
24+
2425
/// <summary>
2526
/// Initializes a new instance of the <see cref="ADOException"/> class.
2627
/// </summary>
@@ -50,17 +51,23 @@ public ADOException(string message, Exception innerException, string sql)
5051
/// <param name="context">
5152
/// The <see cref="StreamingContext"/> that contains contextual information about the source or destination.
5253
/// </param>
54+
// Since v5.6
55+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
5356
protected ADOException(SerializationInfo info, StreamingContext context) : base(info, context)
5457
{
5558
this.sql = (string) info.GetValue("sql", typeof(string));
5659
}
5760

61+
#pragma warning disable CS0809
62+
// Since v5.6
63+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
5864
[SecurityCritical]
5965
public override void GetObjectData(SerializationInfo info, StreamingContext context)
6066
{
6167
base.GetObjectData(info, context);
6268
info.AddValue("sql", sql);
6369
}
70+
#pragma warning restore CS0809
6471

6572
public string SqlString
6673
{

src/NHibernate/AdoNet/TooManyRowsAffectedException.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,25 @@ public TooManyRowsAffectedException(String message, int expectedRowCount, int ac
1818
this.actualRowCount = actualRowCount;
1919
}
2020

21-
protected TooManyRowsAffectedException(SerializationInfo info, StreamingContext context)
22-
: base(info, context)
21+
// Since v5.6
22+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
23+
protected TooManyRowsAffectedException(SerializationInfo info, StreamingContext context) : base(info, context)
2324
{
2425
this.expectedRowCount = info.GetInt32("expectedRowCount");
2526
this.actualRowCount = info.GetInt32("actualRowCount");
2627
}
2728

29+
#pragma warning disable CS0809
30+
// Since v5.6
31+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
2832
[SecurityCritical]
2933
public override void GetObjectData(SerializationInfo info, StreamingContext context)
3034
{
3135
base.GetObjectData(info, context);
3236
info.AddValue("expectedRowCount", expectedRowCount);
3337
info.AddValue("actualRowCount", actualRowCount);
3438
}
39+
#pragma warning restore CS0809
3540

3641
public int ExpectedRowCount
3742
{

src/NHibernate/AssertionFailure.cs

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public AssertionFailure(string message, Exception innerException) : base(message
5252
/// <param name="context">
5353
/// The <see cref="StreamingContext"/> that contains contextual information about the source or destination.
5454
/// </param>
55+
// Since v5.6
56+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
5557
protected AssertionFailure(SerializationInfo info, StreamingContext context) : base(info, context)
5658
{
5759
}

src/NHibernate/Bytecode/HibernateByteCodeException.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public HibernateByteCodeException() {}
1010
public HibernateByteCodeException(string message) : base(message) {}
1111
public HibernateByteCodeException(string message, Exception inner) : base(message, inner) {}
1212

13+
// Since v5.6
14+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
1315
protected HibernateByteCodeException(SerializationInfo info, StreamingContext context) : base(info, context) {}
1416
}
15-
}
17+
}

src/NHibernate/Bytecode/HibernateObjectsFactoryException.cs

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public HibernateObjectsFactoryException() {}
1313
public HibernateObjectsFactoryException(string message) : base(message) {}
1414
public HibernateObjectsFactoryException(string message, Exception inner) : base(message, inner) {}
1515

16+
// Since v5.6
17+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
1618
protected HibernateObjectsFactoryException(SerializationInfo info, StreamingContext context) : base(info, context) {}
1719
}
1820
}

src/NHibernate/Bytecode/NotInstrumentedException.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public NotInstrumentedException(string message) : base(message)
2525
}
2626

2727
/// <inheritdoc />
28-
protected NotInstrumentedException(SerializationInfo info, StreamingContext context)
29-
: base(info, context) {}
28+
// Since v5.6
29+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
30+
protected NotInstrumentedException(SerializationInfo info, StreamingContext context) : base(info, context) {}
3031
}
3132
}

src/NHibernate/Bytecode/UnableToLoadProxyFactoryFactoryException.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ public UnableToLoadProxyFactoryFactoryException(string typeName, Exception inner
1313
TypeName = typeName;
1414
}
1515

16-
protected UnableToLoadProxyFactoryFactoryException(SerializationInfo info, StreamingContext context)
17-
: base(info, context)
16+
// Since v5.6
17+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
18+
protected UnableToLoadProxyFactoryFactoryException(SerializationInfo info, StreamingContext context) : base(info, context)
1819
{
1920
foreach (var entry in info)
2021
{
@@ -25,12 +26,16 @@ protected UnableToLoadProxyFactoryFactoryException(SerializationInfo info, Strea
2526
}
2627
}
2728

29+
#pragma warning disable CS0809
30+
// Since v5.6
31+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
2832
[SecurityCritical]
2933
public override void GetObjectData(SerializationInfo info, StreamingContext context)
3034
{
3135
base.GetObjectData(info, context);
3236
info.AddValue("TypeName", TypeName);
3337
}
38+
#pragma warning restore CS0809
3439

3540
public string TypeName { get; }
3641
public override string Message

src/NHibernate/Cache/CacheException.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ public CacheException(string message, Exception innerException) : base(message,
6060
/// <param name="context">
6161
/// The <see cref="StreamingContext"/> that contains contextual information about the source or destination.
6262
/// </param>
63+
// Since v5.6
64+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
6365
protected CacheException(SerializationInfo info, StreamingContext context) : base(info, context)
6466
{
6567
}
6668
}
67-
}
69+
}

0 commit comments

Comments
 (0)