From 22c40983c823eb61677b64e539fdd99861612ca4 Mon Sep 17 00:00:00 2001 From: plskbc <243992348+plskbc@users.noreply.github.com> Date: Wed, 15 Jul 2026 11:57:39 +0200 Subject: [PATCH] Add .NET 10 support and security dependency floors for v0 --- .github/workflows/pull-requests-v0.yml | 6 +- .github/workflows/release-v0.yml | 9 +- RELEASE_NOTES.md | 52 ++++++- Source/Common.props | 8 + .../EventFlow.AspNetCore.Tests.csproj | 11 +- .../EventFlowJsonOptionsMvcConfiguration.cs | 4 +- .../EventFlow.AspNetCore.csproj | 10 +- .../Extensions/AspNetCoreEventFlowOptions.cs | 2 +- ...EventFlow.DependencyInjection.Tests.csproj | 11 +- .../EventFlow.DependencyInjection.csproj | 10 +- .../EventFlow.EventStores.EventStore.csproj | 2 + .../EventFlow.Hangfire.Tests.csproj | 2 +- .../EventFlow.Hangfire.csproj | 6 +- .../EventFlow.MongoDB.csproj | 2 + .../EventFlow.MsSql.Tests.csproj | 10 +- .../MsSqlDatabaseMigratorTests.cs | 74 +++++++++ .../Connections/MsSqlConnectionFactory.cs | 2 +- Source/EventFlow.MsSql/EventFlow.MsSql.csproj | 12 +- .../EventStores/MsSqlEventPersistence.cs | 2 +- .../Integrations/TableParameter.cs | 4 +- .../MsSqlErrorRetryStrategy.cs | 2 +- .../MsSqlSnapshotPersistence.cs | 2 +- .../EventFlow.PostgreSql.csproj | 2 + .../EventFlow.SQLite/EventFlow.SQLite.csproj | 5 + .../EventFlow.Sql.Tests.csproj | 10 +- .../Integrations/DbUpUpgradeLogTests.cs | 143 ++++++++++++++++++ Source/EventFlow.Sql/EventFlow.Sql.csproj | 8 +- .../Integrations/DbUpUpgradeLog.cs | 35 +++++ .../EventFlow.TestHelpers.csproj | 4 +- Source/EventFlow.Tests/EventFlow.Tests.csproj | 10 +- Source/EventFlow/Core/ReflectionHelper.cs | 4 + Source/EventFlow/EventFlow.csproj | 6 +- .../Files/FilesEventPersistence.cs | 2 +- global.json | 6 + 34 files changed, 438 insertions(+), 40 deletions(-) create mode 100644 Source/EventFlow.MsSql.Tests/IntegrationTests/MsSqlDatabaseMigratorTests.cs create mode 100644 Source/EventFlow.Sql.Tests/UnitTests/Integrations/DbUpUpgradeLogTests.cs create mode 100644 global.json diff --git a/.github/workflows/pull-requests-v0.yml b/.github/workflows/pull-requests-v0.yml index cb1b61ea7..686d02b36 100644 --- a/.github/workflows/pull-requests-v0.yml +++ b/.github/workflows/pull-requests-v0.yml @@ -29,9 +29,13 @@ jobs: run: | powershell -NoProfile -ExecutionPolicy unrestricted -Command ".\up-integration-environment.ps1" + - name: Install Bake + run: | + dotnet tool update -g Bake --version 0.37.51 + - name: Run Bake run: | - bake run --build-version 0.85.${{ github.run_number }} + bake run --build-version 0.86.${{ github.run_number }} - name: Upload NuGet packages uses: actions/upload-artifact@v4 diff --git a/.github/workflows/release-v0.yml b/.github/workflows/release-v0.yml index f30a37a8f..789f75474 100644 --- a/.github/workflows/release-v0.yml +++ b/.github/workflows/release-v0.yml @@ -8,6 +8,7 @@ on: permissions: contents: write + packages: write jobs: build: @@ -36,11 +37,13 @@ jobs: run: | powershell -NoProfile -ExecutionPolicy unrestricted -Command ".\up-integration-environment.ps1" + - name: Install Bake + run: | + dotnet tool update -g Bake --version 0.37.51 + - name: Run Bake run: | - declare -i REVISION - REVISION=4714+$GITHUB_RUN_NUMBER - bake run --convention=Release --build-version 0.85.$REVISION --destination="nuget>github,nuget,release>github" + bake run --convention=Release --build-version 0.86.${{ github.run_number }} --destination="nuget>github,nuget,release>github" - name: Upload NuGet packages uses: actions/upload-artifact@v4 diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 8ed449691..4ce789d26 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,4 +1,54 @@ -### New in 0.85 (not released yet) +### New in 0.86 (not released yet) + +Additive .NET 10 support plus security dependency floors. Existing target +frameworks and their dependency groups are unchanged except for the security +floors explicitly listed below - net452 and netstandard1.6 consumers resolve +exactly the same assets and dependencies as 0.85.5. Only applications +targeting net10.0 (or later) pick up the new net10.0 assets below. + +* New: Added `net10.0` target framework to `EventFlow`, `EventFlow.Sql`, + `EventFlow.MsSql`, `EventFlow.AspNetCore` and `EventFlow.DependencyInjection` +* New: On `net10.0`, the DbUp integration is compiled against `dbup-core` `6.1.1` + (new `IUpgradeLog` interface; adds a transitive dependency on + `Microsoft.Extensions.Logging.Abstractions`) and `dbup-sqlserver` `7.2.0`, + which unblocks consumers that need DbUp 6.x elsewhere in their dependency graph +* New: On `net10.0`, `EventFlow.MsSql` depends on `Microsoft.Data.SqlClient` `6.1.4` +* New: On `net10.0`, `EventFlow.AspNetCore` uses the ASP.NET Core shared framework + reference instead of the legacy `Microsoft.AspNetCore.*` `2.2`/`3.1` packages, + and `Microsoft.AspNetCore.Mvc.NewtonsoftJson` `10.0.0` +* New: On `net10.0`, `EventFlow.DependencyInjection` depends on + `Microsoft.Extensions.DependencyInjection` `10.0.0` +* Fix: Security floor `System.Text.Encodings.Web` `4.7.2` added to + `EventFlow.PostgreSql` (GHSA-ghhp-997w-qr28, pulled in via `Npgsql`) +* Fix: Security floor `Snappier` `1.3.1` added to `EventFlow.MongoDB` + (GHSA-pggp-6c3x-2xmx, pulled in via `MongoDB.Driver`) +* Breaking: Updated `Hangfire.Core` from `1.6.20` to `1.7.37` in + `EventFlow.Hangfire` for `netstandard2.0` only, due to GHSA-xcvr-qv8h-m7xw in + the 1.6 netstandard dependency chain. Consumers using `Hangfire.SqlServer` + (or other Hangfire 1.6.x storage packages) must move them to `1.7.x` together + (1.6.x storage packages pin `Hangfire.Core` exactly and will fail restore + with NU1107 otherwise); see the Hangfire 1.7 upgrade guide if you extend + Hangfire internals. `net452`/`netstandard1.6` keep `Hangfire.Core` `1.6.20` +* Fix: Security floor `System.Text.RegularExpressions` `4.3.1` added to + `EventFlow.EventStores.EventStore` (GHSA-cmhx-cq75-c4mj, via + `EventStore.Client` -> `protobuf-net`) +* Fix: Security floor `System.Text.RegularExpressions` `4.3.1` added to + `EventFlow.SQLite` for `netstandard2.0` only (GHSA-cmhx-cq75-c4mj, via + `dbup-sqlserver` `5.0.40` chain) +* Fix: `EventFlow.TestHelpers` updated `Microsoft.Data.SqlClient` from `5.1.4` + to `5.2.2` and added security floor `System.Text.RegularExpressions` `4.3.1` + (GHSA-cmhx-cq75-c4mj, via `AutoFixture.AutoMoq` and `Moq`) +* Fix: `EventFlow.MsSql` updated `Microsoft.Data.SqlClient` from `5.2.0` to + `5.2.2` on `netstandard2.0` and added security floor + `System.Text.RegularExpressions` `4.3.1` (GHSA-cmhx-cq75-c4mj, via + `dbup-sqlserver` `5.0.40` chain) +* Note: `SharpCompress` (GHSA-6c8g-7p36-r338, via `MongoDB.Driver`) has no + patched release yet; EventFlow does not extract archives - monitor for a + fixed version +* Note: The `net452` and `netstandard1.6` dependency graphs are intentionally + unchanged (legacy, platform-covered) + +### New in 0.85.5 (released 2025-05-29) * New: Update from `System.Data.SqlClient` to `Microsoft.Data.SqlClient` (thanks @janrybka) diff --git a/Source/Common.props b/Source/Common.props index e9b0f3119..6868e86dd 100644 --- a/Source/Common.props +++ b/Source/Common.props @@ -9,6 +9,14 @@ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb icon-128.png false + + false + $(NoWarn);NETSDK1215 + + false diff --git a/Source/EventFlow.AspNetCore.Tests/EventFlow.AspNetCore.Tests.csproj b/Source/EventFlow.AspNetCore.Tests/EventFlow.AspNetCore.Tests.csproj index 514463204..42dfb9fa4 100644 --- a/Source/EventFlow.AspNetCore.Tests/EventFlow.AspNetCore.Tests.csproj +++ b/Source/EventFlow.AspNetCore.Tests/EventFlow.AspNetCore.Tests.csproj @@ -1,17 +1,24 @@  - netcoreapp3.1 + netcoreapp3.1;net10.0 False + + + - + + + + + diff --git a/Source/EventFlow.AspNetCore/Configuration/EventFlowJsonOptionsMvcConfiguration.cs b/Source/EventFlow.AspNetCore/Configuration/EventFlowJsonOptionsMvcConfiguration.cs index 7aad484e0..4460b4acc 100644 --- a/Source/EventFlow.AspNetCore/Configuration/EventFlowJsonOptionsMvcConfiguration.cs +++ b/Source/EventFlow.AspNetCore/Configuration/EventFlowJsonOptionsMvcConfiguration.cs @@ -30,7 +30,7 @@ public class EventFlowJsonOptionsMvcConfiguration #if NETSTANDARD2_0 : IConfigureOptions #endif -#if (NETCOREAPP3_0 || NETCOREAPP3_1) +#if NETCOREAPP3_0_OR_GREATER : IConfigureOptions #endif { @@ -47,7 +47,7 @@ public void Configure(MvcJsonOptions options) _jsonOptions.Apply(options.SerializerSettings); } #endif -#if (NETCOREAPP3_0 || NETCOREAPP3_1) +#if NETCOREAPP3_0_OR_GREATER public void Configure(MvcNewtonsoftJsonOptions options) { _jsonOptions.Apply(options.SerializerSettings); diff --git a/Source/EventFlow.AspNetCore/EventFlow.AspNetCore.csproj b/Source/EventFlow.AspNetCore/EventFlow.AspNetCore.csproj index ed7874ed5..cc696186f 100644 --- a/Source/EventFlow.AspNetCore/EventFlow.AspNetCore.csproj +++ b/Source/EventFlow.AspNetCore/EventFlow.AspNetCore.csproj @@ -1,7 +1,7 @@  - netstandard2.0;netcoreapp3.0;netcoreapp3.1 + netstandard2.0;netcoreapp3.0;netcoreapp3.1;net10.0 True True False @@ -21,11 +21,17 @@ true - + + + + + + + diff --git a/Source/EventFlow.AspNetCore/Extensions/AspNetCoreEventFlowOptions.cs b/Source/EventFlow.AspNetCore/Extensions/AspNetCoreEventFlowOptions.cs index e7a935a88..f45b0486c 100644 --- a/Source/EventFlow.AspNetCore/Extensions/AspNetCoreEventFlowOptions.cs +++ b/Source/EventFlow.AspNetCore/Extensions/AspNetCoreEventFlowOptions.cs @@ -100,7 +100,7 @@ public AspNetCoreEventFlowOptions UseMvcJsonOptions() return this; } #endif -#if (NETCOREAPP3_0 || NETCOREAPP3_1) +#if NETCOREAPP3_0_OR_GREATER public AspNetCoreEventFlowOptions UseMvcJsonOptions() { _options.RegisterServices(s => diff --git a/Source/EventFlow.DependencyInjection.Tests/EventFlow.DependencyInjection.Tests.csproj b/Source/EventFlow.DependencyInjection.Tests/EventFlow.DependencyInjection.Tests.csproj index 1e6282d8f..041ac1803 100644 --- a/Source/EventFlow.DependencyInjection.Tests/EventFlow.DependencyInjection.Tests.csproj +++ b/Source/EventFlow.DependencyInjection.Tests/EventFlow.DependencyInjection.Tests.csproj @@ -1,16 +1,23 @@ - netcoreapp3.1 + netcoreapp3.1;net10.0 False + + + - + + + + + diff --git a/Source/EventFlow.DependencyInjection/EventFlow.DependencyInjection.csproj b/Source/EventFlow.DependencyInjection/EventFlow.DependencyInjection.csproj index 04a47162f..292270045 100644 --- a/Source/EventFlow.DependencyInjection/EventFlow.DependencyInjection.csproj +++ b/Source/EventFlow.DependencyInjection/EventFlow.DependencyInjection.csproj @@ -1,7 +1,7 @@ - netstandard2.0 + netstandard2.0;net10.0 True True False @@ -21,9 +21,15 @@ true - + + + + + + + diff --git a/Source/EventFlow.EventStores.EventStore/EventFlow.EventStores.EventStore.csproj b/Source/EventFlow.EventStores.EventStore/EventFlow.EventStores.EventStore.csproj index 10c091f4f..a25cdbcb5 100644 --- a/Source/EventFlow.EventStores.EventStore/EventFlow.EventStores.EventStore.csproj +++ b/Source/EventFlow.EventStores.EventStore/EventFlow.EventStores.EventStore.csproj @@ -24,6 +24,8 @@ + + diff --git a/Source/EventFlow.Hangfire.Tests/EventFlow.Hangfire.Tests.csproj b/Source/EventFlow.Hangfire.Tests/EventFlow.Hangfire.Tests.csproj index 9ef70081c..6a2e84ca9 100644 --- a/Source/EventFlow.Hangfire.Tests/EventFlow.Hangfire.Tests.csproj +++ b/Source/EventFlow.Hangfire.Tests/EventFlow.Hangfire.Tests.csproj @@ -10,7 +10,7 @@ - + diff --git a/Source/EventFlow.Hangfire/EventFlow.Hangfire.csproj b/Source/EventFlow.Hangfire/EventFlow.Hangfire.csproj index ec63d8168..6dd2f7d1c 100644 --- a/Source/EventFlow.Hangfire/EventFlow.Hangfire.csproj +++ b/Source/EventFlow.Hangfire/EventFlow.Hangfire.csproj @@ -22,7 +22,11 @@ - + + + diff --git a/Source/EventFlow.MongoDB/EventFlow.MongoDB.csproj b/Source/EventFlow.MongoDB/EventFlow.MongoDB.csproj index 9c0e8fe3b..bcfcc4ead 100644 --- a/Source/EventFlow.MongoDB/EventFlow.MongoDB.csproj +++ b/Source/EventFlow.MongoDB/EventFlow.MongoDB.csproj @@ -28,6 +28,8 @@ + + diff --git a/Source/EventFlow.MsSql.Tests/EventFlow.MsSql.Tests.csproj b/Source/EventFlow.MsSql.Tests/EventFlow.MsSql.Tests.csproj index 4037e746d..64dc92747 100644 --- a/Source/EventFlow.MsSql.Tests/EventFlow.MsSql.Tests.csproj +++ b/Source/EventFlow.MsSql.Tests/EventFlow.MsSql.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + netcoreapp3.1;net10.0 True False False @@ -18,10 +18,16 @@ - + + + + + + + diff --git a/Source/EventFlow.MsSql.Tests/IntegrationTests/MsSqlDatabaseMigratorTests.cs b/Source/EventFlow.MsSql.Tests/IntegrationTests/MsSqlDatabaseMigratorTests.cs new file mode 100644 index 000000000..307e5627d --- /dev/null +++ b/Source/EventFlow.MsSql.Tests/IntegrationTests/MsSqlDatabaseMigratorTests.cs @@ -0,0 +1,74 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015-2024 Rasmus Mikkelsen +// https://github.com/eventflow/EventFlow +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +using System; +using EventFlow.Configuration; +using EventFlow.MsSql.EventStores; +using EventFlow.MsSql.Extensions; +using EventFlow.TestHelpers; +using EventFlow.TestHelpers.MsSql; +using NUnit.Framework; + +namespace EventFlow.MsSql.Tests.IntegrationTests +{ + /// + /// Exercises the DbUp integration end-to-end (UpgradeEngine + DbUpUpgradeLog) against + /// a real SQL Server. On netcoreapp3.1 this runs against dbup-core 5.x, on net10.0 + /// against dbup-core 6.x, proving both TFM-specific dependency sets migrate correctly. + /// + [Category(Categories.Integration)] + public class MsSqlDatabaseMigratorTests + { + private IMsSqlDatabase _testDatabase; + private IRootResolver _resolver; + + [SetUp] + public void SetUp() + { + _testDatabase = MsSqlHelpz.CreateDatabase("eventflow-migrator"); + _resolver = EventFlowOptions.New + .ConfigureMsSql(MsSqlConfiguration.New.SetConnectionString(_testDatabase.ConnectionString.Value)) + .CreateResolver(); + } + + [TearDown] + public void TearDown() + { + _resolver?.Dispose(); + _testDatabase?.Dispose(); + } + + [Test] + public void EmbeddedScriptsAreMigratedAndIdempotent() + { + // Arrange + var databaseMigrator = _resolver.Resolve(); + + // Act (twice - DbUp journals executed scripts, so the second run must be a no-op) + EventFlowEventStoresMsSql.MigrateDatabase(databaseMigrator); + EventFlowEventStoresMsSql.MigrateDatabase(databaseMigrator); + + // Assert - the migrated table exists and is queryable + _testDatabase.Execute("SELECT TOP 1 GlobalSequenceNumber FROM [dbo].[EventFlow]"); + } + } +} diff --git a/Source/EventFlow.MsSql/Connections/MsSqlConnectionFactory.cs b/Source/EventFlow.MsSql/Connections/MsSqlConnectionFactory.cs index 8d9f84f8b..70c7ee51d 100644 --- a/Source/EventFlow.MsSql/Connections/MsSqlConnectionFactory.cs +++ b/Source/EventFlow.MsSql/Connections/MsSqlConnectionFactory.cs @@ -21,7 +21,7 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using System.Data; -#if NETSTANDARD2_0_OR_GREATER +#if NETSTANDARD2_0_OR_GREATER || NET5_0_OR_GREATER using Microsoft.Data.SqlClient; #else using System.Data.SqlClient; diff --git a/Source/EventFlow.MsSql/EventFlow.MsSql.csproj b/Source/EventFlow.MsSql/EventFlow.MsSql.csproj index 6f4958630..097ae7c00 100644 --- a/Source/EventFlow.MsSql/EventFlow.MsSql.csproj +++ b/Source/EventFlow.MsSql/EventFlow.MsSql.csproj @@ -1,7 +1,7 @@  - net452;netstandard1.6;netstandard2.0 + net452;netstandard1.6;netstandard2.0;net10.0 True True False @@ -23,11 +23,17 @@ - + + + - + + + + + diff --git a/Source/EventFlow.MsSql/EventStores/MsSqlEventPersistence.cs b/Source/EventFlow.MsSql/EventStores/MsSqlEventPersistence.cs index 8d96fb3ce..99af8a188 100644 --- a/Source/EventFlow.MsSql/EventStores/MsSqlEventPersistence.cs +++ b/Source/EventFlow.MsSql/EventStores/MsSqlEventPersistence.cs @@ -22,7 +22,7 @@ using System; using System.Collections.Generic; -#if NETSTANDARD2_0_OR_GREATER +#if NETSTANDARD2_0_OR_GREATER || NET5_0_OR_GREATER using Microsoft.Data.SqlClient; #else using System.Data.SqlClient; diff --git a/Source/EventFlow.MsSql/Integrations/TableParameter.cs b/Source/EventFlow.MsSql/Integrations/TableParameter.cs index 8f7ff59f9..033cdbb9b 100644 --- a/Source/EventFlow.MsSql/Integrations/TableParameter.cs +++ b/Source/EventFlow.MsSql/Integrations/TableParameter.cs @@ -23,7 +23,7 @@ using System; using System.Collections.Generic; using System.Data; -#if NETSTANDARD2_0_OR_GREATER +#if NETSTANDARD2_0_OR_GREATER || NET5_0_OR_GREATER using Microsoft.Data.SqlClient; #else using System.Data.SqlClient; @@ -32,7 +32,7 @@ using System.Linq; using System.Reflection; using Dapper; -#if NETSTANDARD2_0_OR_GREATER +#if NETSTANDARD2_0_OR_GREATER || NET5_0_OR_GREATER using Microsoft.Data.SqlClient.Server; #else using Microsoft.SqlServer.Server; diff --git a/Source/EventFlow.MsSql/RetryStrategies/MsSqlErrorRetryStrategy.cs b/Source/EventFlow.MsSql/RetryStrategies/MsSqlErrorRetryStrategy.cs index c81955211..c082502cf 100644 --- a/Source/EventFlow.MsSql/RetryStrategies/MsSqlErrorRetryStrategy.cs +++ b/Source/EventFlow.MsSql/RetryStrategies/MsSqlErrorRetryStrategy.cs @@ -23,7 +23,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; -#if NETSTANDARD2_0_OR_GREATER +#if NETSTANDARD2_0_OR_GREATER || NET5_0_OR_GREATER using Microsoft.Data.SqlClient; #else using System.Data.SqlClient; diff --git a/Source/EventFlow.MsSql/SnapshotStores/MsSqlSnapshotPersistence.cs b/Source/EventFlow.MsSql/SnapshotStores/MsSqlSnapshotPersistence.cs index c51f4fe65..ee63846d2 100644 --- a/Source/EventFlow.MsSql/SnapshotStores/MsSqlSnapshotPersistence.cs +++ b/Source/EventFlow.MsSql/SnapshotStores/MsSqlSnapshotPersistence.cs @@ -21,7 +21,7 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using System; -#if NETSTANDARD2_0_OR_GREATER +#if NETSTANDARD2_0_OR_GREATER || NET5_0_OR_GREATER using Microsoft.Data.SqlClient; #else using System.Data.SqlClient; diff --git a/Source/EventFlow.PostgreSql/EventFlow.PostgreSql.csproj b/Source/EventFlow.PostgreSql/EventFlow.PostgreSql.csproj index 8ac3f947b..a4659ae64 100644 --- a/Source/EventFlow.PostgreSql/EventFlow.PostgreSql.csproj +++ b/Source/EventFlow.PostgreSql/EventFlow.PostgreSql.csproj @@ -37,6 +37,8 @@ + + diff --git a/Source/EventFlow.SQLite/EventFlow.SQLite.csproj b/Source/EventFlow.SQLite/EventFlow.SQLite.csproj index 6022f3155..e2b30ec98 100644 --- a/Source/EventFlow.SQLite/EventFlow.SQLite.csproj +++ b/Source/EventFlow.SQLite/EventFlow.SQLite.csproj @@ -28,6 +28,11 @@ + + + + + diff --git a/Source/EventFlow.Sql.Tests/EventFlow.Sql.Tests.csproj b/Source/EventFlow.Sql.Tests/EventFlow.Sql.Tests.csproj index 2d81b2091..b337ecb2c 100644 --- a/Source/EventFlow.Sql.Tests/EventFlow.Sql.Tests.csproj +++ b/Source/EventFlow.Sql.Tests/EventFlow.Sql.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + netcoreapp3.1;net10.0 True False False @@ -10,10 +10,16 @@ - + + + + + + + diff --git a/Source/EventFlow.Sql.Tests/UnitTests/Integrations/DbUpUpgradeLogTests.cs b/Source/EventFlow.Sql.Tests/UnitTests/Integrations/DbUpUpgradeLogTests.cs new file mode 100644 index 000000000..839608105 --- /dev/null +++ b/Source/EventFlow.Sql.Tests/UnitTests/Integrations/DbUpUpgradeLogTests.cs @@ -0,0 +1,143 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015-2024 Rasmus Mikkelsen +// https://github.com/eventflow/EventFlow +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +using System; +using EventFlow.Logs; +using EventFlow.Sql.Integrations; +using EventFlow.TestHelpers; +using Moq; +using NUnit.Framework; + +namespace EventFlow.Sql.Tests.UnitTests.Integrations +{ + [Category(Categories.Unit)] + public class DbUpUpgradeLogTests + { + private Mock _log; + private DbUpUpgradeLog _sut; + + [SetUp] + public void SetUp() + { + _log = new Mock(); + _sut = new DbUpUpgradeLog(_log.Object); + } + +#if NET8_0_OR_GREATER + // dbup-core 6.x IUpgradeLog surface + + [Test] + public void LogTraceIsMappedToVerbose() + { + _sut.LogTrace("format {0}", 42); + + _log.Verify( + l => l.Verbose("format {0}", It.Is(a => a.Length == 1 && (int) a[0] == 42)), + Times.Once); + } + + [Test] + public void LogDebugIsMappedToDebug() + { + _sut.LogDebug("format {0}", 42); + + _log.Verify( + l => l.Debug("format {0}", It.Is(a => a.Length == 1 && (int) a[0] == 42)), + Times.Once); + } + + [Test] + public void LogInformationIsMappedToInformation() + { + _sut.LogInformation("format {0}", 42); + + _log.Verify( + l => l.Information("format {0}", It.Is(a => a.Length == 1 && (int) a[0] == 42)), + Times.Once); + } + + [Test] + public void LogWarningIsMappedToWarning() + { + _sut.LogWarning("format {0}", 42); + + _log.Verify( + l => l.Warning("format {0}", It.Is(a => a.Length == 1 && (int) a[0] == 42)), + Times.Once); + } + + [Test] + public void LogErrorIsMappedToError() + { + _sut.LogError("format {0}", 42); + + _log.Verify( + l => l.Error("format {0}", It.Is(a => a.Length == 1 && (int) a[0] == 42)), + Times.Once); + } + + [Test] + public void LogErrorWithExceptionIsMappedToError() + { + var exception = new InvalidOperationException(); + + _sut.LogError(exception, "format {0}", 42); + + _log.Verify( + l => l.Error(exception, "format {0}", It.Is(a => a.Length == 1 && (int) a[0] == 42)), + Times.Once); + } +#else + // dbup-core 4.x/5.x IUpgradeLog surface + + [Test] + public void WriteInformationIsMappedToInformation() + { + _sut.WriteInformation("format {0}", 42); + + _log.Verify( + l => l.Information("format {0}", It.Is(a => a.Length == 1 && (int) a[0] == 42)), + Times.Once); + } + + [Test] + public void WriteWarningIsMappedToWarning() + { + _sut.WriteWarning("format {0}", 42); + + _log.Verify( + l => l.Warning("format {0}", It.Is(a => a.Length == 1 && (int) a[0] == 42)), + Times.Once); + } + + [Test] + public void WriteErrorIsMappedToError() + { + _sut.WriteError("format {0}", 42); + + _log.Verify( + l => l.Error("format {0}", It.Is(a => a.Length == 1 && (int) a[0] == 42)), + Times.Once); + } +#endif + } +} diff --git a/Source/EventFlow.Sql/EventFlow.Sql.csproj b/Source/EventFlow.Sql/EventFlow.Sql.csproj index f55506a86..e6ce9d8ec 100644 --- a/Source/EventFlow.Sql/EventFlow.Sql.csproj +++ b/Source/EventFlow.Sql/EventFlow.Sql.csproj @@ -1,7 +1,7 @@  - net452;netstandard1.6;netstandard2.0 + net452;netstandard1.6;netstandard2.0;net10.0 True True False @@ -25,10 +25,14 @@ - + + + + + diff --git a/Source/EventFlow.Sql/Integrations/DbUpUpgradeLog.cs b/Source/EventFlow.Sql/Integrations/DbUpUpgradeLog.cs index b7b75675f..12e1c456b 100644 --- a/Source/EventFlow.Sql/Integrations/DbUpUpgradeLog.cs +++ b/Source/EventFlow.Sql/Integrations/DbUpUpgradeLog.cs @@ -22,6 +22,9 @@ using DbUp.Engine.Output; using EventFlow.Logs; +#if NET8_0_OR_GREATER +using System; +#endif namespace EventFlow.Sql.Integrations { @@ -34,6 +37,37 @@ public DbUpUpgradeLog(ILog log) _log = log; } +#if NET8_0_OR_GREATER + public void LogTrace(string format, params object[] args) + { + _log.Verbose(format, args); + } + + public void LogDebug(string format, params object[] args) + { + _log.Debug(format, args); + } + + public void LogInformation(string format, params object[] args) + { + _log.Information(format, args); + } + + public void LogWarning(string format, params object[] args) + { + _log.Warning(format, args); + } + + public void LogError(string format, params object[] args) + { + _log.Error(format, args); + } + + public void LogError(Exception ex, string format, params object[] args) + { + _log.Error(ex, format, args); + } +#else public void WriteInformation(string format, params object[] args) { _log.Information(format, args); @@ -48,5 +82,6 @@ public void WriteWarning(string format, params object[] args) { _log.Warning(format, args); } +#endif } } diff --git a/Source/EventFlow.TestHelpers/EventFlow.TestHelpers.csproj b/Source/EventFlow.TestHelpers/EventFlow.TestHelpers.csproj index 696fb4e1f..3c862f55c 100644 --- a/Source/EventFlow.TestHelpers/EventFlow.TestHelpers.csproj +++ b/Source/EventFlow.TestHelpers/EventFlow.TestHelpers.csproj @@ -33,8 +33,10 @@ - + + + diff --git a/Source/EventFlow.Tests/EventFlow.Tests.csproj b/Source/EventFlow.Tests/EventFlow.Tests.csproj index d11279f21..a5cac1fa2 100644 --- a/Source/EventFlow.Tests/EventFlow.Tests.csproj +++ b/Source/EventFlow.Tests/EventFlow.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + netcoreapp3.1;net10.0 True False False @@ -11,9 +11,15 @@ + + + - + + + + diff --git a/Source/EventFlow/Core/ReflectionHelper.cs b/Source/EventFlow/Core/ReflectionHelper.cs index 68a7befde..dde7b8012 100644 --- a/Source/EventFlow/Core/ReflectionHelper.cs +++ b/Source/EventFlow/Core/ReflectionHelper.cs @@ -34,9 +34,13 @@ public static class ReflectionHelper { public static string GetCodeBase(Assembly assembly, bool includeFileName = false) { +#if NET5_0_OR_GREATER + var path = assembly.Location; +#else var codebase = assembly.CodeBase; var uri = new UriBuilder(codebase); var path = Path.GetFullPath(Uri.UnescapeDataString(uri.Path)); +#endif var codeBase = includeFileName ? path : Path.GetDirectoryName(path); diff --git a/Source/EventFlow/EventFlow.csproj b/Source/EventFlow/EventFlow.csproj index ff3ebf25a..d7cc3d5db 100644 --- a/Source/EventFlow/EventFlow.csproj +++ b/Source/EventFlow/EventFlow.csproj @@ -1,7 +1,7 @@  - net452;netstandard1.6;netstandard2.0;netcoreapp3.0;netcoreapp3.1 + net452;netstandard1.6;netstandard2.0;netcoreapp3.0;netcoreapp3.1;net10.0 True True False @@ -19,7 +19,7 @@ en-US UPDATED BY BUILD bin\$(Configuration)\$(TargetFramework)\EventFlow.xml - 1701;1702;1705;1591 + $(NoWarn);1701;1702;1705;1591 true @@ -28,7 +28,7 @@ - + diff --git a/Source/EventFlow/EventStores/Files/FilesEventPersistence.cs b/Source/EventFlow/EventStores/Files/FilesEventPersistence.cs index 0a3ed2684..afaaff8bf 100644 --- a/Source/EventFlow/EventStores/Files/FilesEventPersistence.cs +++ b/Source/EventFlow/EventStores/Files/FilesEventPersistence.cs @@ -289,7 +289,7 @@ private EventStoreLog RecreateEventStoreLog(string path) /// private string GetRelativePath(string relativeTo, string path) { -#if NETCOREAPP3_1 || NETCOREAPP3_0 +#if NETCOREAPP3_0_OR_GREATER return Path.GetRelativePath(relativeTo, path); #else if (string.IsNullOrEmpty(relativeTo)) diff --git a/global.json b/global.json new file mode 100644 index 000000000..512142d2b --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "10.0.100", + "rollForward": "latestFeature" + } +}