From d2f292171417d466b3baf0575ca4001f6327b3dc Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Mon, 14 Oct 2024 23:43:55 +0200 Subject: [PATCH] Run tests and examples against .NET 9 --- .config/dotnet-tools.json | 2 +- .github/workflows/build.yml | 18 ++++++++++++++++++ .github/workflows/codeql.yml | 6 ++++++ Directory.Build.props | 6 ++++++ NuGet.config | 8 ++++++++ package-versions.props | 16 ++++++++++++++++ .../DapperExample/DapperExample.csproj | 11 ++++++++--- src/Examples/DapperExample/Program.cs | 9 +++++++-- .../DatabasePerTenantExample.csproj | 4 ++-- .../GettingStarted/GettingStarted.csproj | 2 +- .../JsonApiDotNetCoreExample.csproj | 4 ++-- .../MultiDbContextExample.csproj | 2 +- .../NoEntityFrameworkExample.csproj | 2 +- .../ReportsExample/ReportsExample.csproj | 2 +- test/AnnotationTests/AnnotationTests.csproj | 2 +- test/DapperTests/DapperTests.csproj | 2 +- test/DiscoveryTests/DiscoveryTests.csproj | 2 +- .../JsonApiDotNetCoreTests.csproj | 2 +- .../MultiDbContextTests.csproj | 2 +- .../NoEntityFrameworkTests.csproj | 2 +- .../SourceGeneratorTests.csproj | 7 ++++++- .../CapturingLoggerProvider.cs | 4 ++++ .../TestBuildingBlocks.csproj | 4 ++-- test/UnitTests/UnitTests.csproj | 2 +- 24 files changed, 97 insertions(+), 24 deletions(-) create mode 100644 NuGet.config diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 9014d5b033..867219b3ae 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "jetbrains.resharper.globaltools": { - "version": "2024.2.7", + "version": "2024.3.0-eap05", "commands": [ "jb" ], diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da0993c185..574bf9a83e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,6 +48,12 @@ jobs: dotnet-version: | 6.0.x 8.0.x + - name: Setup .NET 9 (unstable) + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 9.0.x + dotnet-quality: 'preview' - name: Show installed versions shell: pwsh run: | @@ -166,6 +172,12 @@ jobs: dotnet-version: | 6.0.x 8.0.x + - name: Setup .NET 9 (unstable) + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 9.0.x + dotnet-quality: 'preview' - name: Git checkout uses: actions/checkout@v4 - name: Restore tools @@ -221,6 +233,12 @@ jobs: dotnet-version: | 6.0.x 8.0.x + - name: Setup .NET 9 (unstable) + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 9.0.x + dotnet-quality: 'preview' - name: Git checkout uses: actions/checkout@v4 with: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index eb0375769e..2f8ebe747d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,6 +29,12 @@ jobs: dotnet-version: | 6.0.x 8.0.x + - name: Setup .NET 9 (unstable) + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 9.0.x + dotnet-quality: 'preview' - name: Git checkout uses: actions/checkout@v4 - name: Initialize CodeQL diff --git a/Directory.Build.props b/Directory.Build.props index 6c68a15073..26741df6cb 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -24,6 +24,12 @@ $(NoWarn);$(UseCollectionExpressionRules) + + + direct + $(NoWarn);NU1608;NETSDK1215 + + $(NoWarn);AV2210 diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 0000000000..53343a29c6 --- /dev/null +++ b/NuGet.config @@ -0,0 +1,8 @@ + + + + + + + diff --git a/package-versions.props b/package-versions.props index ed9b06b1aa..920bee7288 100644 --- a/package-versions.props +++ b/package-versions.props @@ -20,6 +20,18 @@ 2.8.* + + + N/A + + + 9.0.* + 9.0.* + 9.0.0-rc.2 + 9.0.0-* + $(AspNetCoreVersion) + + 8.0.0 @@ -27,6 +39,8 @@ 8.0.* 8.0.* + $(EntityFrameworkCoreVersion) + $(EntityFrameworkCoreVersion) $(AspNetCoreVersion) @@ -38,6 +52,8 @@ 6.0.* 2.1.* 7.0.* + $(EntityFrameworkCoreVersion) + $(EntityFrameworkCoreVersion) 8.0.* diff --git a/src/Examples/DapperExample/DapperExample.csproj b/src/Examples/DapperExample/DapperExample.csproj index f49c3e4b40..d958551bef 100644 --- a/src/Examples/DapperExample/DapperExample.csproj +++ b/src/Examples/DapperExample/DapperExample.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 @@ -15,7 +15,12 @@ - - + + + + + + + diff --git a/src/Examples/DapperExample/Program.cs b/src/Examples/DapperExample/Program.cs index f7bf198af9..31e5814e5b 100644 --- a/src/Examples/DapperExample/Program.cs +++ b/src/Examples/DapperExample/Program.cs @@ -31,8 +31,13 @@ } case DatabaseProvider.MySql: { - builder.Services.AddMySql(connectionString, ServerVersion.AutoDetect(connectionString), - optionsAction: options => SetDbContextDebugOptions(options)); +#if NET9_0_OR_GREATER + ServerVersion serverVersion = await ServerVersion.AutoDetectAsync(connectionString); +#else + ServerVersion serverVersion = ServerVersion.AutoDetect(connectionString); +#endif + + builder.Services.AddMySql(connectionString, serverVersion, optionsAction: options => SetDbContextDebugOptions(options)); break; } diff --git a/src/Examples/DatabasePerTenantExample/DatabasePerTenantExample.csproj b/src/Examples/DatabasePerTenantExample/DatabasePerTenantExample.csproj index 0ccb4bbc5f..f6f17920ac 100644 --- a/src/Examples/DatabasePerTenantExample/DatabasePerTenantExample.csproj +++ b/src/Examples/DatabasePerTenantExample/DatabasePerTenantExample.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 @@ -13,6 +13,6 @@ - + diff --git a/src/Examples/GettingStarted/GettingStarted.csproj b/src/Examples/GettingStarted/GettingStarted.csproj index 1f4645f323..22fc0529b1 100644 --- a/src/Examples/GettingStarted/GettingStarted.csproj +++ b/src/Examples/GettingStarted/GettingStarted.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 diff --git a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj index 0ccb4bbc5f..f6f17920ac 100644 --- a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj +++ b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 @@ -13,6 +13,6 @@ - + diff --git a/src/Examples/MultiDbContextExample/MultiDbContextExample.csproj b/src/Examples/MultiDbContextExample/MultiDbContextExample.csproj index 1f4645f323..22fc0529b1 100644 --- a/src/Examples/MultiDbContextExample/MultiDbContextExample.csproj +++ b/src/Examples/MultiDbContextExample/MultiDbContextExample.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 diff --git a/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj b/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj index c5b18320f0..c45552dc2d 100644 --- a/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj +++ b/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 diff --git a/src/Examples/ReportsExample/ReportsExample.csproj b/src/Examples/ReportsExample/ReportsExample.csproj index bff4909317..3f2c288b23 100644 --- a/src/Examples/ReportsExample/ReportsExample.csproj +++ b/src/Examples/ReportsExample/ReportsExample.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 diff --git a/test/AnnotationTests/AnnotationTests.csproj b/test/AnnotationTests/AnnotationTests.csproj index 081046adb0..7c5e5f3ae0 100644 --- a/test/AnnotationTests/AnnotationTests.csproj +++ b/test/AnnotationTests/AnnotationTests.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0;netstandard2.0 + net9.0;net8.0;net6.0;netstandard2.0 diff --git a/test/DapperTests/DapperTests.csproj b/test/DapperTests/DapperTests.csproj index 45d9c6a88d..1420e0dd60 100644 --- a/test/DapperTests/DapperTests.csproj +++ b/test/DapperTests/DapperTests.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 diff --git a/test/DiscoveryTests/DiscoveryTests.csproj b/test/DiscoveryTests/DiscoveryTests.csproj index a64d3be689..295d5340fa 100644 --- a/test/DiscoveryTests/DiscoveryTests.csproj +++ b/test/DiscoveryTests/DiscoveryTests.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 diff --git a/test/JsonApiDotNetCoreTests/JsonApiDotNetCoreTests.csproj b/test/JsonApiDotNetCoreTests/JsonApiDotNetCoreTests.csproj index 38d665aa5b..95a623d0f9 100644 --- a/test/JsonApiDotNetCoreTests/JsonApiDotNetCoreTests.csproj +++ b/test/JsonApiDotNetCoreTests/JsonApiDotNetCoreTests.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 diff --git a/test/MultiDbContextTests/MultiDbContextTests.csproj b/test/MultiDbContextTests/MultiDbContextTests.csproj index 54497bfada..6466d8d75f 100644 --- a/test/MultiDbContextTests/MultiDbContextTests.csproj +++ b/test/MultiDbContextTests/MultiDbContextTests.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 diff --git a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj index 080666d491..968d798be3 100644 --- a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj +++ b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 diff --git a/test/SourceGeneratorTests/SourceGeneratorTests.csproj b/test/SourceGeneratorTests/SourceGeneratorTests.csproj index e28bdc20d1..bd78c6e1cd 100644 --- a/test/SourceGeneratorTests/SourceGeneratorTests.csproj +++ b/test/SourceGeneratorTests/SourceGeneratorTests.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 @@ -17,4 +17,9 @@ + + + + + diff --git a/test/TestBuildingBlocks/CapturingLoggerProvider.cs b/test/TestBuildingBlocks/CapturingLoggerProvider.cs index 3996b1c9e2..38ec60ed3a 100644 --- a/test/TestBuildingBlocks/CapturingLoggerProvider.cs +++ b/test/TestBuildingBlocks/CapturingLoggerProvider.cs @@ -10,7 +10,11 @@ public sealed class CapturingLoggerProvider : ILoggerProvider private static readonly Func DefaultFilter = (_, _) => true; private readonly Func _filter; +#if NET9_0_OR_GREATER + private readonly Lock _lockObject = new(); +#else private readonly object _lockObject = new(); +#endif private readonly List _messages = []; public CapturingLoggerProvider() diff --git a/test/TestBuildingBlocks/TestBuildingBlocks.csproj b/test/TestBuildingBlocks/TestBuildingBlocks.csproj index 40e10eb297..7a983627a5 100644 --- a/test/TestBuildingBlocks/TestBuildingBlocks.csproj +++ b/test/TestBuildingBlocks/TestBuildingBlocks.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0 @@ -17,7 +17,7 @@ - + diff --git a/test/UnitTests/UnitTests.csproj b/test/UnitTests/UnitTests.csproj index 99fc7ce781..e977ac0c8c 100644 --- a/test/UnitTests/UnitTests.csproj +++ b/test/UnitTests/UnitTests.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net9.0;net8.0;net6.0