From 18b9b972fdb61a93e6838cabb9e7155638102c26 Mon Sep 17 00:00:00 2001 From: Dan Kent <83468000+kentdr@users.noreply.github.com> Date: Tue, 12 Sep 2023 13:21:17 -0400 Subject: [PATCH] Prepare repo for .NET 8 (#614) * Bump major version * Update TFMs to net8.0 * Remove obsolete classes * Update test SDK * Update to NServiceBus 9 * Update workflows * Fix approval file * Bump dependencies * Clean up project files * Update NServiceBus.TransactionalSession * Remove ifdefs * Remove outdated comment * Avoid needing confusing using alias * Update release workflow --------- Co-authored-by: Brandon Ording --- .github/workflows/ci.yml | 15 +-- .github/workflows/release.yml | 7 +- src/Custom.Build.props | 2 +- ...mosDB.LogicalOutbox.AcceptanceTests.csproj | 24 ++-- ...nTransactionalSagas.AcceptanceTests.csproj | 25 ++-- ...rsistence.CosmosDB.PersistenceTests.csproj | 30 ++--- ...exceed_lock_request_timeout_pessimistic.cs | 120 ------------------ ...sDB.PessimisticLock.AcceptanceTests.csproj | 25 ++-- ...osDB.PhysicalOutbox.AcceptanceTests.csproj | 24 ++-- .../APIApprovals.Approve.approved.txt | 10 +- ...rviceBus.Persistence.CosmosDB.Tests.csproj | 25 ++-- .../Outbox/LogicalOutboxBehaviorTests.cs | 2 +- .../NServiceBusAcceptanceTest.cs | 5 - ...ransactionalSession.AcceptanceTests.csproj | 23 ++-- ...CosmosDB.TransactionalSession.Tests.csproj | 19 ++- ...tence.CosmosDB.TransactionalSession.csproj | 9 +- .../Config/CosmosPersistenceConfig.cs | 11 -- .../NServiceBus.Persistence.CosmosDB.csproj | 9 +- ...oxBehavior.cs => LogicalOutboxBehavior.cs} | 19 +-- .../Outbox/OutboxPersister.cs | 3 +- .../Outbox/OutboxStorage.cs | 4 +- .../Outbox/ReadOnlyMemoryConverter.cs | 9 -- .../Saga/CosmosSagaIdGenerator.cs | 64 ---------- .../Saga/SagaStorage.cs | 2 - ...estableCosmosSynchronizedStorageSession.cs | 2 +- .../Utility/NonNativePubSubCheck.cs | 18 --- 26 files changed, 107 insertions(+), 399 deletions(-) delete mode 100644 src/NServiceBus.Persistence.CosmosDB.PersistenceTests/When_concurrent_update_exceed_lock_request_timeout_pessimistic.cs rename src/NServiceBus.Persistence.CosmosDB/Outbox/{OutboxBehavior.cs => LogicalOutboxBehavior.cs} (75%) delete mode 100644 src/NServiceBus.Persistence.CosmosDB/Utility/NonNativePubSubCheck.cs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9f92f64..1c230345 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,15 +9,15 @@ on: env: DOTNET_NOLOGO: true jobs: - build: + build: name: ${{ matrix.name }} runs-on: ${{ matrix.os }} strategy: matrix: include: - - os: windows-2019 + - os: windows-2022 name: Windows - - os: ubuntu-20.04 + - os: ubuntu-22.04 name: Linux fail-fast: false steps: @@ -26,16 +26,15 @@ jobs: SECRETS_AVAILABLE: ${{ secrets.SECRETS_AVAILABLE }} shell: pwsh run: exit $(If ($env:SECRETS_AVAILABLE -eq 'true') { 0 } Else { 1 }) - - name: Checkout + - name: Checkout uses: actions/checkout@v3.6.0 with: - fetch-depth: 0 + fetch-depth: 0 - name: Setup .NET SDK uses: actions/setup-dotnet@v3.2.0 with: - dotnet-version: | - 7.0.x - 6.0.x + dotnet-version: 8.0.x + dotnet-quality: 'preview' - name: Build run: dotnet build src --configuration Release - name: Upload packages diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a186307..3176d6f3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,16 +8,17 @@ env: DOTNET_NOLOGO: true jobs: release: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v3.6.0 with: - fetch-depth: 0 + fetch-depth: 0 - name: Setup .NET SDK uses: actions/setup-dotnet@v3.2.0 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x + dotnet-quality: 'preview' - name: Build run: dotnet build src --configuration Release - name: Sign NuGet packages diff --git a/src/Custom.Build.props b/src/Custom.Build.props index 528e351a..379e0d58 100644 --- a/src/Custom.Build.props +++ b/src/Custom.Build.props @@ -1,7 +1,7 @@ - 2.1 + 3.0 minor diff --git a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests.csproj b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests.csproj index 0113f144..bbeb9f3f 100644 --- a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests.csproj @@ -1,27 +1,23 @@ - + - net472;net6.0;net7.0 + net8.0 true ..\NServiceBusTests.snk - - - - - - - - - - - - + + + + + + + + diff --git a/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests.csproj b/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests.csproj index 2e8c8a2c..8c728cfc 100644 --- a/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests.csproj @@ -1,34 +1,29 @@ - + - net472;net6.0;net7.0 + net8.0 true ..\NServiceBusTests.snk - - - - - - - - - - - - + + + + + + + + - diff --git a/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/NServiceBus.Persistence.CosmosDB.PersistenceTests.csproj b/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/NServiceBus.Persistence.CosmosDB.PersistenceTests.csproj index 3f3735d0..52de618e 100644 --- a/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/NServiceBus.Persistence.CosmosDB.PersistenceTests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/NServiceBus.Persistence.CosmosDB.PersistenceTests.csproj @@ -1,32 +1,22 @@ - + - net472;net6.0;net7.0 + net8.0 true ..\NServiceBusTests.snk - 11 - - - - - - - - - - - - - - - + - + + + + + + - + diff --git a/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/When_concurrent_update_exceed_lock_request_timeout_pessimistic.cs b/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/When_concurrent_update_exceed_lock_request_timeout_pessimistic.cs deleted file mode 100644 index 7900984b..00000000 --- a/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/When_concurrent_update_exceed_lock_request_timeout_pessimistic.cs +++ /dev/null @@ -1,120 +0,0 @@ -namespace NServiceBus.PersistenceTesting.Sagas -{ - using System; - using System.Threading.Tasks; - using NUnit.Framework; - - public class When_concurrent_update_exceed_lock_request_timeout_pessimistic : SagaPersisterTests - { - bool resetSessionTimeout; - - public override async Task OneTimeSetUp() - { - if (!param.SessionTimeout.HasValue) - { - resetSessionTimeout = true; - param.SessionTimeout = TimeSpan.FromMilliseconds(500); - } - configuration = new PersistenceTestsConfiguration(param); - await configuration.Configure(); - } - - public override Task OneTimeTearDown() - { - if (resetSessionTimeout) - { - param.SessionTimeout = null; - } - return base.OneTimeTearDown(); - } - - [Test] - public async Task Should_fail_with_timeout() - { - configuration.RequiresPessimisticConcurrencySupport(); - - var correlationPropertyData = Guid.NewGuid().ToString(); - var saga = new TestSagaData { SomeId = correlationPropertyData, SagaProperty = "initial value" }; - await SaveSaga(saga); - - var firstSessionGetDone = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - var secondSessionGetDone = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - var persister = configuration.SagaStorage; - - async Task FirstSession() - { - var firstSessionContext = configuration.GetContextBagForSagaStorage(); - using (var firstSaveSession = configuration.CreateStorageSession()) - { - await firstSaveSession.Open(firstSessionContext); - var record = await persister.Get(saga.Id, firstSaveSession, firstSessionContext); - firstSessionGetDone.SetResult(true); - - var delayTime = configuration.SessionTimeout.GetValueOrDefault(TimeSpan.FromMilliseconds(1000)); - await Task.Delay(delayTime.Add(delayTime)).ConfigureAwait(false); - await secondSessionGetDone.Task.ConfigureAwait(false); - - record.SagaProperty = "session 1 value"; - await persister.Update(record, firstSaveSession, firstSessionContext); - await firstSaveSession.CompleteAsync(); - } - } - - async Task SecondSession() - { - var secondContext = configuration.GetContextBagForSagaStorage(); - using (var secondSession = configuration.CreateStorageSession()) - { - await secondSession.Open(secondContext); - await firstSessionGetDone.Task.ConfigureAwait(false); - - var recordTask = persister.Get(saga.Id, secondSession, secondContext); - secondSessionGetDone.SetResult(true); - - var record = await recordTask.ConfigureAwait(false); - record.SagaProperty = "session 2 value"; - await persister.Update(record, secondSession, secondContext); - await secondSession.CompleteAsync(); - } - } - - var firstSessionTask = FirstSession(); - var secondSessionTask = SecondSession(); - - Assert.DoesNotThrowAsync(async () => await firstSessionTask); - Assert.CatchAsync(async () => await secondSessionTask); // not all persisters guarantee a TimeoutException - - var updatedSaga = await GetById(saga.Id); - Assert.That(updatedSaga.SagaProperty, Is.EqualTo("session 1 value")); - } - - public class TestSaga : Saga, IAmStartedByMessages - { - public Task Handle(StartMessage message, IMessageHandlerContext context) - { - throw new NotImplementedException(); - } - - protected override void ConfigureHowToFindSaga(SagaPropertyMapper mapper) - { - mapper.ConfigureMapping(msg => msg.SomeId).ToSaga(saga => saga.SomeId); - } - } - - public class TestSagaData : ContainSagaData - { - public string SomeId { get; set; } - - public string SagaProperty { get; set; } - } - - public class StartMessage - { - public string SomeId { get; set; } - } - - public When_concurrent_update_exceed_lock_request_timeout_pessimistic(TestVariant param) : base(param) - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests.csproj b/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests.csproj index efc68fac..f0847529 100644 --- a/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests.csproj @@ -1,27 +1,23 @@ - + - net472;net6.0;net7.0 + net8.0 true ..\NServiceBusTests.snk - - - - - - - - - - - - + + + + + + + + @@ -30,7 +26,6 @@ - diff --git a/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests.csproj b/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests.csproj index 0113f144..bbeb9f3f 100644 --- a/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests.csproj @@ -1,27 +1,23 @@ - + - net472;net6.0;net7.0 + net8.0 true ..\NServiceBusTests.snk - - - - - - - - - - - - + + + + + + + + diff --git a/src/NServiceBus.Persistence.CosmosDB.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt b/src/NServiceBus.Persistence.CosmosDB.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt index 488bd49b..412232ca 100644 --- a/src/NServiceBus.Persistence.CosmosDB.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt +++ b/src/NServiceBus.Persistence.CosmosDB.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt @@ -1,4 +1,4 @@ -[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests, PublicKey=00240000048000009400000006020000002400005253413100040000010001007f16e21368ff041183fab592d9e8ed37e7be355e93323147a1d29983d6e591b04282e4da0c9e18bd901e112c0033925eb7d7872c2f1706655891c5c9d57297994f707d16ee9a8f40d978f064ee1ffc73c0db3f4712691b23bf596f75130f4ec978cf78757ec034625a5f27e6bb50c618931ea49f6f628fd74271c32959efb1c5")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests, PublicKey=00240000048000009400000006020000002400005253413100040000010001007f16e21368ff041183fab592d9e8ed37e7be355e93323147a1d29983d6e591b04282e4da0c9e18bd901e112c0033925eb7d7872c2f1706655891c5c9d57297994f707d16ee9a8f40d978f064ee1ffc73c0db3f4712691b23bf596f75130f4ec978cf78757ec034625a5f27e6bb50c618931ea49f6f628fd74271c32959efb1c5")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests, PublicKey=00240000048000009400000006020000002400005253413100040000010001007f16e21368ff041183fab592d9e8ed37e7be355e93323147a1d29983d6e591b04282e4da0c9e18bd901e112c0033925eb7d7872c2f1706655891c5c9d57297994f707d16ee9a8f40d978f064ee1ffc73c0db3f4712691b23bf596f75130f4ec978cf78757ec034625a5f27e6bb50c618931ea49f6f628fd74271c32959efb1c5")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"NServiceBus.Persistence.CosmosDB.PersistenceTests, PublicKey=00240000048000009400000006020000002400005253413100040000010001007f16e21368ff041183fab592d9e8ed37e7be355e93323147a1d29983d6e591b04282e4da0c9e18bd901e112c0033925eb7d7872c2f1706655891c5c9d57297994f707d16ee9a8f40d978f064ee1ffc73c0db3f4712691b23bf596f75130f4ec978cf78757ec034625a5f27e6bb50c618931ea49f6f628fd74271c32959efb1c5")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests, PublicKey=00240000048000009400000006020000002400005253413100040000010001007f16e21368ff041183fab592d9e8ed37e7be355e93323147a1d29983d6e591b04282e4da0c9e18bd901e112c0033925eb7d7872c2f1706655891c5c9d57297994f707d16ee9a8f40d978f064ee1ffc73c0db3f4712691b23bf596f75130f4ec978cf78757ec034625a5f27e6bb50c618931ea49f6f628fd74271c32959efb1c5")] @@ -24,9 +24,6 @@ namespace NServiceBus public static NServiceBus.PersistenceExtensions DatabaseName(this NServiceBus.PersistenceExtensions persistenceExtensions, string databaseName) { } public static NServiceBus.PersistenceExtensions DefaultContainer(this NServiceBus.PersistenceExtensions persistenceExtensions, string containerName, string partitionKeyPath) { } public static void DisableContainerCreation(this NServiceBus.PersistenceExtensions persistenceExtensions) { } - [System.Obsolete("Use persistence.Sagas().EnableMigrationMode() instead. Will be removed in version" + - " 3.0.0.", true)] - public static void EnableMigrationMode(this NServiceBus.PersistenceExtensions persistenceExtensions) { } public static NServiceBus.Persistence.CosmosDB.SagaPersistenceConfiguration Sagas(this NServiceBus.PersistenceExtensions persistenceExtensions) { } public static NServiceBus.Persistence.CosmosDB.TransactionInformationConfiguration TransactionInformation(this NServiceBus.PersistenceExtensions persistenceExtensions) { } } @@ -75,11 +72,6 @@ namespace NServiceBus.Persistence.CosmosDB { Microsoft.Azure.Cosmos.CosmosClient Client { get; } } - [System.Obsolete(@"This class was only ever used as a constant to place custom behaviors in the right part of the pipeline. It is no longer necessary to have a custom behavior to extract the transaction information. Use `persistence.TransactionInformation()` to conveniently map headers or message content to partition keys. Will be removed in version 3.0.0.", true)] - public sealed class LogicalOutboxBehavior : NServiceBus.Pipeline.IBehavior, NServiceBus.Pipeline.IBehavior - { - public System.Threading.Tasks.Task Invoke(NServiceBus.Pipeline.IIncomingLogicalMessageContext context, System.Func next) { } - } public class PessimisticLockingConfiguration { public PessimisticLockingConfiguration() { } diff --git a/src/NServiceBus.Persistence.CosmosDB.Tests/NServiceBus.Persistence.CosmosDB.Tests.csproj b/src/NServiceBus.Persistence.CosmosDB.Tests/NServiceBus.Persistence.CosmosDB.Tests.csproj index d465101e..f74c4971 100644 --- a/src/NServiceBus.Persistence.CosmosDB.Tests/NServiceBus.Persistence.CosmosDB.Tests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.Tests/NServiceBus.Persistence.CosmosDB.Tests.csproj @@ -1,29 +1,28 @@ - + - net472;net6.0;net7.0 + net8.0 true ..\NServiceBusTests.snk - 10.0 - - - - - - - + - - + + + + - + + + + + \ No newline at end of file diff --git a/src/NServiceBus.Persistence.CosmosDB.Tests/Outbox/LogicalOutboxBehaviorTests.cs b/src/NServiceBus.Persistence.CosmosDB.Tests/Outbox/LogicalOutboxBehaviorTests.cs index 7264c8f7..61942180 100644 --- a/src/NServiceBus.Persistence.CosmosDB.Tests/Outbox/LogicalOutboxBehaviorTests.cs +++ b/src/NServiceBus.Persistence.CosmosDB.Tests/Outbox/LogicalOutboxBehaviorTests.cs @@ -48,7 +48,7 @@ public async Task Should_clear_added_pending_operations_and_restore_ones_from_ou var containerHolderHolderResolver = new ContainerHolderResolver(new FakeProvider(fakeCosmosClient), new ContainerInformation("fakeContainer", new PartitionKeyPath("")), "fakeDatabase"); - var behavior = new OutboxBehavior(containerHolderHolderResolver, new JsonSerializer()); + var behavior = new LogicalOutboxBehavior(containerHolderHolderResolver, new JsonSerializer()); var testableContext = new TestableIncomingLogicalMessageContext(); diff --git a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/Infrastructure/NServiceBusAcceptanceTest.cs b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/Infrastructure/NServiceBusAcceptanceTest.cs index 3d4c4b29..f907e7a5 100644 --- a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/Infrastructure/NServiceBusAcceptanceTest.cs +++ b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/Infrastructure/NServiceBusAcceptanceTest.cs @@ -14,11 +14,6 @@ public abstract class NServiceBusAcceptanceTest [SetUp] public void SetUp() { -#if NETFRAMEWORK - // Hack: prevents SerializationException ... Type 'x' in assembly 'y' is not marked as serializable. - // https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/mitigation-deserialization-of-objects-across-app-domains - System.Configuration.ConfigurationManager.GetSection("X"); -#endif Conventions.EndpointNamingConvention = t => { string classAndEndpoint = t.FullName.Split('.').Last(); diff --git a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests.csproj b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests.csproj index a4d9552f..8028ea04 100644 --- a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests.csproj @@ -1,30 +1,25 @@ - net472;net6.0;net7.0 + net8.0 true ..\NServiceBusTests.snk - 10.0 NServiceBus.TransactionalSession.AcceptanceTests - - - - - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests.csproj b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests.csproj index 135309f7..6fc73c4d 100644 --- a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests.csproj @@ -1,27 +1,26 @@ - net472;net6.0;net7.0 + net8.0 true ..\NServiceBusTests.snk - 10.0 - - - - - + - - + + + + - + + + \ No newline at end of file diff --git a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession/NServiceBus.Persistence.CosmosDB.TransactionalSession.csproj b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession/NServiceBus.Persistence.CosmosDB.TransactionalSession.csproj index a29a8e5e..4f95ef3d 100644 --- a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession/NServiceBus.Persistence.CosmosDB.TransactionalSession.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession/NServiceBus.Persistence.CosmosDB.TransactionalSession.csproj @@ -1,22 +1,21 @@ - net472;net6.0 + net8.0 true ..\NServiceBus.snk - 10.0 NServiceBus.TransactionalSession NServiceBus Transactional Session for the CosmosDB persistence. - - + - + + \ No newline at end of file diff --git a/src/NServiceBus.Persistence.CosmosDB/Config/CosmosPersistenceConfig.cs b/src/NServiceBus.Persistence.CosmosDB/Config/CosmosPersistenceConfig.cs index 6a77ce7b..7ae0da85 100644 --- a/src/NServiceBus.Persistence.CosmosDB/Config/CosmosPersistenceConfig.cs +++ b/src/NServiceBus.Persistence.CosmosDB/Config/CosmosPersistenceConfig.cs @@ -58,17 +58,6 @@ public static void DisableContainerCreation(this PersistenceExtensions - /// Enable support for sagas migrated from other persistence technologies by querying the saga from storage using a migrated saga id. - /// - [ObsoleteEx(Message = "Use persistence.Sagas().EnableMigrationMode() instead.", TreatAsErrorFromVersion = "2", RemoveInVersion = "3")] - public static void EnableMigrationMode(this PersistenceExtensions persistenceExtensions) - { - Guard.AgainstNull(nameof(persistenceExtensions), persistenceExtensions); - - persistenceExtensions.GetSettings().GetOrCreate().EnableMigrationMode(); - } - /// /// Obtains the saga persistence configuration options. /// diff --git a/src/NServiceBus.Persistence.CosmosDB/NServiceBus.Persistence.CosmosDB.csproj b/src/NServiceBus.Persistence.CosmosDB/NServiceBus.Persistence.CosmosDB.csproj index f16f9561..bb1d8ab4 100644 --- a/src/NServiceBus.Persistence.CosmosDB/NServiceBus.Persistence.CosmosDB.csproj +++ b/src/NServiceBus.Persistence.CosmosDB/NServiceBus.Persistence.CosmosDB.csproj @@ -1,18 +1,17 @@ - + - net472;net6.0 + net8.0 true ..\NServiceBus.snk - 10.0 true + + - - diff --git a/src/NServiceBus.Persistence.CosmosDB/Outbox/OutboxBehavior.cs b/src/NServiceBus.Persistence.CosmosDB/Outbox/LogicalOutboxBehavior.cs similarity index 75% rename from src/NServiceBus.Persistence.CosmosDB/Outbox/OutboxBehavior.cs rename to src/NServiceBus.Persistence.CosmosDB/Outbox/LogicalOutboxBehavior.cs index 66d3dfcb..f83aefff 100644 --- a/src/NServiceBus.Persistence.CosmosDB/Outbox/OutboxBehavior.cs +++ b/src/NServiceBus.Persistence.CosmosDB/Outbox/LogicalOutboxBehavior.cs @@ -11,27 +11,12 @@ using Transport; using TransportOperation = Transport.TransportOperation; - /// - /// Mimics the outbox behavior as part of the logical phase. This type is public so that it isn't renamed and it can be used to register logical behaviors before this behavior - /// - [ObsoleteEx(Message = "This class was only ever used as a constant to place custom behaviors in the right part of the pipeline. It is no longer necessary to have a custom behavior to extract the transaction information. Use `persistence.TransactionInformation()` to conveniently map headers or message content to partition keys.", TreatAsErrorFromVersion = "2", RemoveInVersion = "3")] - public sealed class LogicalOutboxBehavior : IBehavior - { - internal LogicalOutboxBehavior() - { - } - - /// - public Task Invoke(IIncomingLogicalMessageContext context, Func next) => throw new NotImplementedException(); - } - /// /// Mimics the outbox behavior as part of the logical phase. /// - /// Can be renamed back to LogicalOutboxBehavior once the type is gone from the public API. - class OutboxBehavior : IBehavior + class LogicalOutboxBehavior : IBehavior { - internal OutboxBehavior(ContainerHolderResolver containerHolderResolver, JsonSerializer serializer) + internal LogicalOutboxBehavior(ContainerHolderResolver containerHolderResolver, JsonSerializer serializer) { this.containerHolderResolver = containerHolderResolver; this.serializer = serializer; diff --git a/src/NServiceBus.Persistence.CosmosDB/Outbox/OutboxPersister.cs b/src/NServiceBus.Persistence.CosmosDB/Outbox/OutboxPersister.cs index 0d345a0c..8a462611 100644 --- a/src/NServiceBus.Persistence.CosmosDB/Outbox/OutboxPersister.cs +++ b/src/NServiceBus.Persistence.CosmosDB/Outbox/OutboxPersister.cs @@ -8,7 +8,6 @@ using Newtonsoft.Json; using Outbox; using Transport; - using Headers = NServiceBus.Headers; class OutboxPersister : IOutboxStorage { @@ -43,7 +42,7 @@ public async Task Get(string messageId, ContextBag context, Cance { // because of the transactional session we cannot assume the incoming message is always present if (!context.TryGet(out var incomingMessage) || - !incomingMessage.Headers.ContainsKey(Headers.ControlMessageHeader)) + !incomingMessage.Headers.ContainsKey(NServiceBus.Headers.ControlMessageHeader)) { // we return null here to enable outbox work at logical stage return null; diff --git a/src/NServiceBus.Persistence.CosmosDB/Outbox/OutboxStorage.cs b/src/NServiceBus.Persistence.CosmosDB/Outbox/OutboxStorage.cs index 6b00894f..43607f76 100644 --- a/src/NServiceBus.Persistence.CosmosDB/Outbox/OutboxStorage.cs +++ b/src/NServiceBus.Persistence.CosmosDB/Outbox/OutboxStorage.cs @@ -22,8 +22,6 @@ class OutboxStorage : Feature protected override void Setup(FeatureConfigurationContext context) { - NonNativePubSubCheck.ThrowIfMessageDrivenPubSubInUse(context); - var serializer = new JsonSerializer { ContractResolver = new UpperCaseIdIntoLowerCaseIdContractResolver(), @@ -33,7 +31,7 @@ protected override void Setup(FeatureConfigurationContext context) var ttlInSeconds = context.Settings.Get(SettingsKeys.OutboxTimeToLiveInSeconds); context.Services.AddSingleton(builder => new OutboxPersister(builder.GetService(), serializer, ttlInSeconds)); - context.Pipeline.Register("LogicalOutboxBehavior", builder => new OutboxBehavior(builder.GetService(), serializer), "Behavior that mimics the outbox as part of the logical stage."); + context.Pipeline.Register("LogicalOutboxBehavior", builder => new LogicalOutboxBehavior(builder.GetService(), serializer), "Behavior that mimics the outbox as part of the logical stage."); } } } \ No newline at end of file diff --git a/src/NServiceBus.Persistence.CosmosDB/Outbox/ReadOnlyMemoryConverter.cs b/src/NServiceBus.Persistence.CosmosDB/Outbox/ReadOnlyMemoryConverter.cs index 3ad9fd78..69a2eaa1 100644 --- a/src/NServiceBus.Persistence.CosmosDB/Outbox/ReadOnlyMemoryConverter.cs +++ b/src/NServiceBus.Persistence.CosmosDB/Outbox/ReadOnlyMemoryConverter.cs @@ -1,9 +1,6 @@ namespace NServiceBus.Persistence.CosmosDB { using System; -#if NETFRAMEWORK - using System.Runtime.InteropServices; -#endif using Newtonsoft.Json; /// @@ -27,13 +24,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s var mem = (ReadOnlyMemory)value; string base64; -#if NETFRAMEWORK - base64 = MemoryMarshal.TryGetArray(mem, out var bodySegment) - ? Convert.ToBase64String(bodySegment.Array, bodySegment.Offset, bodySegment.Count) - : Convert.ToBase64String(mem.ToArray()); -#else base64 = Convert.ToBase64String(mem.Span); -#endif writer.WriteValue(base64); } diff --git a/src/NServiceBus.Persistence.CosmosDB/Saga/CosmosSagaIdGenerator.cs b/src/NServiceBus.Persistence.CosmosDB/Saga/CosmosSagaIdGenerator.cs index a85054da..2fac334e 100644 --- a/src/NServiceBus.Persistence.CosmosDB/Saga/CosmosSagaIdGenerator.cs +++ b/src/NServiceBus.Persistence.CosmosDB/Saga/CosmosSagaIdGenerator.cs @@ -2,12 +2,7 @@ { using System; using System.Buffers; -#if NETFRAMEWORK - using System.Runtime.InteropServices; -#endif -#if NET using System.Runtime.CompilerServices; -#endif using System.Security.Cryptography; using System.Text; using Newtonsoft.Json; @@ -26,45 +21,6 @@ public static Guid Generate(string sagaEntityTypeFullName, string correlationPro return DeterministicGuid(sagaEntityTypeFullName, correlationPropertyName, serializedPropertyValue); } -#if NETFRAMEWORK - static Guid DeterministicGuid(string sagaEntityTypeFullName, string correlationPropertyName, string serializedPropertyValue) - { - // sagaEntityTypeFullName_correlationPropertyName_serializedPropertyValue - var length = sagaEntityTypeFullName.Length + correlationPropertyName.Length + serializedPropertyValue.Length + 2; - - var encoding = Encoding.UTF8; - var maxByteCount = encoding.GetMaxByteCount(length); - var stringBuffer = ArrayPool.Shared.Rent(maxByteCount); - var stringBufferSpan = stringBuffer.AsSpan(); - - try - { - // sagaEntityTypeFullName_ - var numberOfBytesWritten = encoding.GetBytes(sagaEntityTypeFullName.AsSpan(), stringBufferSpan); - stringBufferSpan[numberOfBytesWritten++] = SeparatorByte; - - // sagaEntityTypeFullName_correlationPropertyName_ - numberOfBytesWritten += encoding.GetBytes(correlationPropertyName.AsSpan(), stringBufferSpan.Slice(numberOfBytesWritten)); - stringBufferSpan[numberOfBytesWritten++] = SeparatorByte; - - // sagaEntityTypeFullName_correlationPropertyName_serializedPropertyValue - numberOfBytesWritten += encoding.GetBytes(serializedPropertyValue.AsSpan(), stringBufferSpan.Slice(numberOfBytesWritten)); - - using var sha1CryptoServiceProvider = SHA1.Create(); - var guidBytes = sha1CryptoServiceProvider.ComputeHash(stringBuffer, 0, numberOfBytesWritten).AsSpan().Slice(0, 16); - if (!MemoryMarshal.TryRead(guidBytes, out var deterministicGuid)) - { - deterministicGuid = new Guid(guidBytes.ToArray()); - } - return deterministicGuid; - } - finally - { - ArrayPool.Shared.Return(stringBuffer, clearArray: true); - } - } -#endif -#if NET [SkipLocalsInit] static Guid DeterministicGuid(string sagaEntityTypeFullName, string correlationPropertyName, string serializedPropertyValue) { @@ -106,25 +62,5 @@ static Guid DeterministicGuid(string sagaEntityTypeFullName, string correlationP } } } -#endif - } - -#if NETFRAMEWORK - static class SpanExtensions - { - public static unsafe int GetBytes(this Encoding encoding, ReadOnlySpan src, Span dst) - { - if (src.IsEmpty) - { - return 0; - } - - fixed (char* chars = &src.GetPinnableReference()) - fixed (byte* bytes = &dst.GetPinnableReference()) - { - return encoding.GetBytes(chars, src.Length, bytes, dst.Length); - } - } } -#endif } diff --git a/src/NServiceBus.Persistence.CosmosDB/Saga/SagaStorage.cs b/src/NServiceBus.Persistence.CosmosDB/Saga/SagaStorage.cs index 8db57c13..5fe876cc 100644 --- a/src/NServiceBus.Persistence.CosmosDB/Saga/SagaStorage.cs +++ b/src/NServiceBus.Persistence.CosmosDB/Saga/SagaStorage.cs @@ -21,8 +21,6 @@ internal SagaStorage() protected override void Setup(FeatureConfigurationContext context) { - NonNativePubSubCheck.ThrowIfMessageDrivenPubSubInUse(context); - var sagaConfiguration = context.Settings.GetOrDefault() ?? new SagaPersistenceConfiguration(); var pessimisticLockingConfiguration = sagaConfiguration.PessimisticLockingConfiguration; if (pessimisticLockingConfiguration.PessimisticLockingEnabled) diff --git a/src/NServiceBus.Persistence.CosmosDB/Testing/TestableCosmosSynchronizedStorageSession.cs b/src/NServiceBus.Persistence.CosmosDB/Testing/TestableCosmosSynchronizedStorageSession.cs index 37140f26..3b30c930 100644 --- a/src/NServiceBus.Persistence.CosmosDB/Testing/TestableCosmosSynchronizedStorageSession.cs +++ b/src/NServiceBus.Persistence.CosmosDB/Testing/TestableCosmosSynchronizedStorageSession.cs @@ -6,7 +6,7 @@ using Persistence.CosmosDB; /// - /// A fake implementation for for testing purposes. + /// A fake implementation for for testing purposes. /// public class TestableCosmosSynchronizedStorageSession : ISynchronizedStorageSession, IWorkWithSharedTransactionalBatch { diff --git a/src/NServiceBus.Persistence.CosmosDB/Utility/NonNativePubSubCheck.cs b/src/NServiceBus.Persistence.CosmosDB/Utility/NonNativePubSubCheck.cs deleted file mode 100644 index ab69e7de..00000000 --- a/src/NServiceBus.Persistence.CosmosDB/Utility/NonNativePubSubCheck.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NServiceBus.Persistence.CosmosDB -{ - using System; - using NServiceBus.Features; - - class NonNativePubSubCheck - { - public static void ThrowIfMessageDrivenPubSubInUse(FeatureConfigurationContext context) - { -#pragma warning disable CS0618 // Type or member is obsolete - Remove this method along with MessageDrivenSubscriptions - if (context.Settings.IsFeatureEnabled(typeof(MessageDrivenSubscriptions)) || context.Settings.IsFeatureActive(typeof(MessageDrivenSubscriptions))) - { - throw new Exception("NServiceBus.Persistence.CosmosDB must be used with a transport that provides native publish/subscribe capabilities, and cannot be used with message-driven publish/subscribe."); - } -#pragma warning restore CS0618 // Type or member is obsolete - } - } -}