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

Add .NET 8.0 target #3494

Merged
merged 10 commits into from
Mar 11, 2024
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 .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"csharpasyncgenerator.tool": {
"version": "0.21.1",
"version": "0.22.0",
"commands": [
"async-generator"
]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/GenerateAsyncCode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

- name: Generate Async code
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/NetCoreTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

- name: Build and Test
run: |
Expand Down
4 changes: 2 additions & 2 deletions ShowBuildMenu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ testSetupMenu() {
}

testRun(){
dotnet test ./src/NHibernate.Test/NHibernate.Test.csproj -f net6.0
dotnet test ./src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj -f net6.0
dotnet test ./src/NHibernate.Test/NHibernate.Test.csproj -f net8.0
dotnet test ./src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj -f net8.0
mainMenu
}

Expand Down
2 changes: 1 addition & 1 deletion Tools/BuildTool/BuildTool.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
</Project>
8 changes: 5 additions & 3 deletions build-common/NHibernate.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@
<VersionPatch Condition="'$(VersionPatch)' == ''">0</VersionPatch>
<!-- Clear VersionSuffix for making release and set it to dev for making development builds -->
<VersionSuffix Condition="'$(VersionSuffix)' == ''">dev</VersionSuffix>
<LangVersion Condition="'$(MSBuildProjectExtension)' != '.vbproj'">9.0</LangVersion>
<LangVersion Condition="'$(MSBuildProjectExtension)' != '.vbproj'">12.0</LangVersion>

<VersionPrefix Condition="'$(VersionPrefix)' == ''">$(NhVersion).$(VersionPatch)</VersionPrefix>
<VersionSuffix Condition="'$(VersionSuffix)' != '' AND '$(BuildNumber)' != ''">$(VersionSuffix).$(BuildNumber)</VersionSuffix>
<AssemblyVersion>$(NhVersion).0.0</AssemblyVersion>
<FileVersion Condition="'$(VersionSuffix)' != '' AND '$(BuildNumber)' != ''">$(VersionPrefix).$(BuildNumber)</FileVersion>
<FileVersion Condition="'$(FileVersion)' == ''">$(VersionPrefix).0</FileVersion>

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

<Product>NHibernate</Product>
<Company>NHibernate.info</Company>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.101",
"version": "8.0.100",
"rollForward": "latestFeature"
}
}
2 changes: 1 addition & 1 deletion psake.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Task Test -depends Build {
'NHibernate.Test',
'NHibernate.Test.VisualBasic'
) | ForEach-Object {
$assembly = [IO.Path]::Combine("src", $_, "bin", "Release", "net6.0", "$_.dll")
$assembly = [IO.Path]::Combine("src", $_, "bin", "Release", "net8.0", "$_.dll")
Exec {
dotnet $assembly --labels=before --nocolor "--result=$_-TestResult.xml"
}
Expand Down
2 changes: 1 addition & 1 deletion src/AsyncGenerator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
scanForMissingAsyncMembers:
- all: true
- filePath: NHibernate.Test/NHibernate.Test.csproj
targetFramework: net6.0
targetFramework: net8.0
concurrentRun: true
applyChanges: true
suppressDiagnosticFailures:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<OptionExplicit>On</OptionExplicit>
<OptionStrict>On</OptionStrict>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<OutputType>Exe</OutputType>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>
<ItemGroup>
<None Remove="**\*.hbm.xml" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<ItemGroup Condition="'$(TargetFramework)'=='net8.0'">
<Compile Remove="**\Issues\NH3302\**" />
</ItemGroup>
<ItemGroup>
Expand All @@ -30,7 +30,7 @@
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="NUnitLite" Version="3.14.0" />
</ItemGroup>
<ItemGroup>
Expand Down
11 changes: 6 additions & 5 deletions src/NHibernate.Test/Async/CacheTest/SerializationFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
namespace NHibernate.Test.CacheTest
{
using System.Threading.Tasks;
using System.Threading;
[TestFixture]
public class SerializationFixtureAsync
{
Expand Down Expand Up @@ -312,11 +313,11 @@ private void CheckObjectTypeCacheEntry(AnyType.ObjectTypeCacheEntry original, An
Assert.That(copy.EntityName, Is.EqualTo(original.EntityName));
}

private static async Task<T> TestDataContractSerializerAsync<T>(T obj)
private static async Task<T> TestDataContractSerializerAsync<T>(T obj, CancellationToken cancellationToken = default(CancellationToken))
{
var xml = await (DataContractSerializerToXmlAsync(obj));
var xml = await (DataContractSerializerToXmlAsync(obj, cancellationToken));
obj = DataContractSerializerFromXml<T>(xml);
Assert.That(xml, Is.EqualTo(await (DataContractSerializerToXmlAsync(obj))));
Assert.That(xml, Is.EqualTo(await (DataContractSerializerToXmlAsync(obj, cancellationToken))));
return obj;
}

Expand All @@ -328,15 +329,15 @@ private static T TestBinaryFormatter<T>(T obj)
return obj;
}

private static async Task<string> DataContractSerializerToXmlAsync<T>(T obj)
private static async Task<string> DataContractSerializerToXmlAsync<T>(T obj, CancellationToken cancellationToken = default(CancellationToken))
{
using (var memoryStream = new MemoryStream())
using (var reader = new StreamReader(memoryStream))
{
var serializer = new DataContractSerializer(typeof(T), KnownTypes);
serializer.WriteObject(memoryStream, obj);
memoryStream.Position = 0;
return await (reader.ReadToEndAsync());
return await (reader.ReadToEndAsync(cancellationToken));
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/NHibernate.Test/CacheTest/TextReaderExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#if !NET8_0_OR_GREATER
using System.IO;
using System.Threading;
using System.Threading.Tasks;

namespace NHibernate.Test.CacheTest;

internal static class TextReaderExtensions
{
public static Task<string> ReadToEndAsync(this TextReader reader, CancellationToken cancellationToken) =>
cancellationToken.IsCancellationRequested
? Task.FromCanceled<string>(cancellationToken)
: reader.ReadToEndAsync();
}
#endif
15 changes: 8 additions & 7 deletions src/NHibernate.Test/NHibernate.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
<Description>The Unit Tests for NHibernate.</Description>
<TargetFrameworks>$(NhAppTargetFrameworks)</TargetFrameworks>
<IsTestProject>true</IsTestProject>
<NoWarn>$(NoWarn);3001;3002;3003;3005;SYSLIB0003;SYSLIB0012</NoWarn>
<NoWarn>$(NoWarn);3001;3002;3003;3005;8981;SYSLIB0003;SYSLIB0012</NoWarn>
<ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles>
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<OutputType>Exe</OutputType>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>
Expand Down Expand Up @@ -38,7 +39,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<ItemGroup Condition="'$(TargetFramework)'=='net8.0'">
<Compile Remove="**\CfgTest\DefaultNsAssmFixture.cs" />
<Compile Remove="**\CfgTest\HbmOrderingFixture.cs" />
<Compile Remove="**\DynamicProxyTests\PeVerifyFixture.cs" />
Expand All @@ -63,7 +64,7 @@
<ItemGroup>
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="7.7.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.1.3" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.1.5" />
<PackageReference Include="NHibernate.Caches.CoreDistributedCache.Memory" Version="5.9.0" />
<PackageReference Include="NHibernate.Caches.Util.JsonSerializer" Version="5.9.0" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.117" />
Expand All @@ -86,10 +87,10 @@
<PackageReference Include="Microsoft.SqlServer.Compact" Version="4.0.8876.1" />
<PackageReference Include="Oracle.ManagedDataAccess" Version="21.10.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.1" />
<ItemGroup Condition="'$(TargetFramework)'=='net8.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.0" />
<PackageReference Include="System.CodeDom" Version="4.7.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="System.Data.OracleClient" Version="1.0.8" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.100" />
<PackageReference Include="System.Data.Odbc" Version="4.7.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<IsTestProject>true</IsTestProject>
<NoWarn>$(NoWarn);3001;3002;3003;3005</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<OutputType>Exe</OutputType>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>
Expand All @@ -18,7 +18,7 @@
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="NUnitLite" Version="3.14.0" />
</ItemGroup>
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/NHibernate.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\build-common\common.xml = ..\build-common\common.xml
..\appveyor.yml = ..\appveyor.yml
..\ReleaseProcedure.txt = ..\ReleaseProcedure.txt
..\global.json = ..\global.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHibernate", "NHibernate\NHibernate.csproj", "{5909BFE7-93CF-4E5F-BE22-6293368AF01D}"
Expand Down
7 changes: 7 additions & 0 deletions src/NHibernate/ADOException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class ADOException : HibernateException
public ADOException()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ADOException"/> class.
/// </summary>
Expand Down Expand Up @@ -50,17 +51,23 @@ public ADOException(string message, Exception innerException, string sql)
/// <param name="context">
/// The <see cref="StreamingContext"/> that contains contextual information about the source or destination.
/// </param>
// Since v5.6
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
protected ADOException(SerializationInfo info, StreamingContext context) : base(info, context)
{
this.sql = (string) info.GetValue("sql", typeof(string));
}

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

public string SqlString
{
Expand Down
9 changes: 7 additions & 2 deletions src/NHibernate/AdoNet/TooManyRowsAffectedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,25 @@ public TooManyRowsAffectedException(String message, int expectedRowCount, int ac
this.actualRowCount = actualRowCount;
}

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

#pragma warning disable CS0809
// Since v5.6
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
[SecurityCritical]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("expectedRowCount", expectedRowCount);
info.AddValue("actualRowCount", actualRowCount);
}
#pragma warning restore CS0809

public int ExpectedRowCount
{
Expand Down
2 changes: 2 additions & 0 deletions src/NHibernate/AssertionFailure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public AssertionFailure(string message, Exception innerException) : base(message
/// <param name="context">
/// The <see cref="StreamingContext"/> that contains contextual information about the source or destination.
/// </param>
// Since v5.6
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
protected AssertionFailure(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
Expand Down
4 changes: 3 additions & 1 deletion src/NHibernate/Bytecode/HibernateByteCodeException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public HibernateByteCodeException() {}
public HibernateByteCodeException(string message) : base(message) {}
public HibernateByteCodeException(string message, Exception inner) : base(message, inner) {}

// Since v5.6
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
protected HibernateByteCodeException(SerializationInfo info, StreamingContext context) : base(info, context) {}
}
}
}
2 changes: 2 additions & 0 deletions src/NHibernate/Bytecode/HibernateObjectsFactoryException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public HibernateObjectsFactoryException() {}
public HibernateObjectsFactoryException(string message) : base(message) {}
public HibernateObjectsFactoryException(string message, Exception inner) : base(message, inner) {}

// Since v5.6
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
protected HibernateObjectsFactoryException(SerializationInfo info, StreamingContext context) : base(info, context) {}
}
}
5 changes: 3 additions & 2 deletions src/NHibernate/Bytecode/NotInstrumentedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public NotInstrumentedException(string message) : base(message)
}

/// <inheritdoc />
protected NotInstrumentedException(SerializationInfo info, StreamingContext context)
: base(info, context) {}
// Since v5.6
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
protected NotInstrumentedException(SerializationInfo info, StreamingContext context) : base(info, context) {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ public UnableToLoadProxyFactoryFactoryException(string typeName, Exception inner
TypeName = typeName;
}

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

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

public string TypeName { get; }
public override string Message
Expand Down
4 changes: 3 additions & 1 deletion src/NHibernate/Cache/CacheException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ public CacheException(string message, Exception innerException) : base(message,
/// <param name="context">
/// The <see cref="StreamingContext"/> that contains contextual information about the source or destination.
/// </param>
// Since v5.6
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
protected CacheException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
}
Loading
Loading