From 4f0ebbe0a0d6f37f8795722b340a7077ca42c0f9 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 8 Aug 2023 11:57:03 -0400 Subject: [PATCH 01/51] Update project files --- .../NServiceBus.AcceptanceTesting.csproj | 7 +------ .../NServiceBus.AcceptanceTests.csproj | 7 +------ .../NServiceBus.ContainerTests.csproj | 2 +- ...NServiceBus.Core.Analyzer.Tests.Roslyn3.csproj | 2 +- ...NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj | 2 +- .../NServiceBus.Core.Tests.csproj | 11 +---------- src/NServiceBus.Core/NServiceBus.Core.csproj | 15 +-------------- .../NServiceBus.Learning.AcceptanceTests.csproj | 7 +------ .../NServiceBus.PersistenceTests.csproj | 7 +------ .../NServiceBus.Testing.Fakes.csproj | 3 +-- .../NServiceBus.TransportTests.csproj | 6 +----- 11 files changed, 11 insertions(+), 58 deletions(-) diff --git a/src/NServiceBus.AcceptanceTesting/NServiceBus.AcceptanceTesting.csproj b/src/NServiceBus.AcceptanceTesting/NServiceBus.AcceptanceTesting.csproj index 14efed28d7..fd6f2bd397 100644 --- a/src/NServiceBus.AcceptanceTesting/NServiceBus.AcceptanceTesting.csproj +++ b/src/NServiceBus.AcceptanceTesting/NServiceBus.AcceptanceTesting.csproj @@ -1,21 +1,16 @@ - net472;net6.0 + net8.0 true ..\NServiceBus.snk false - 10.0 - - - - diff --git a/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj b/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj index c98fd74a71..11f66c3704 100644 --- a/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj +++ b/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj @@ -1,8 +1,7 @@ - net472;net6.0;net7.0 - 10.0 + net8.0 @@ -10,10 +9,6 @@ - - - - diff --git a/src/NServiceBus.ContainerTests/NServiceBus.ContainerTests.csproj b/src/NServiceBus.ContainerTests/NServiceBus.ContainerTests.csproj index 013f736532..a4118afe02 100644 --- a/src/NServiceBus.ContainerTests/NServiceBus.ContainerTests.csproj +++ b/src/NServiceBus.ContainerTests/NServiceBus.ContainerTests.csproj @@ -1,7 +1,7 @@ - net472;net6.0;net7.0 + net8.0 true ..\NServiceBusTests.snk diff --git a/src/NServiceBus.Core.Analyzer.Tests.Roslyn3/NServiceBus.Core.Analyzer.Tests.Roslyn3.csproj b/src/NServiceBus.Core.Analyzer.Tests.Roslyn3/NServiceBus.Core.Analyzer.Tests.Roslyn3.csproj index 5cb8407ecb..19e7937c8e 100644 --- a/src/NServiceBus.Core.Analyzer.Tests.Roslyn3/NServiceBus.Core.Analyzer.Tests.Roslyn3.csproj +++ b/src/NServiceBus.Core.Analyzer.Tests.Roslyn3/NServiceBus.Core.Analyzer.Tests.Roslyn3.csproj @@ -1,7 +1,7 @@ - net472;net6.0;net7.0 + net8.0 $(DefineConstants);ROSLYN3 diff --git a/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj b/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj index 8ab8fa05f1..23f585c8ca 100644 --- a/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj +++ b/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj @@ -1,7 +1,7 @@ - net472;net6.0;net7.0 + net8.0 $(DefineConstants);ROSLYN4 diff --git a/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj b/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj index fb416d4122..0cc1f12b69 100644 --- a/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj +++ b/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj @@ -1,10 +1,9 @@ - net472;net6.0;net7.0 + net8.0 true ..\NServiceBusTests.snk - 10.0 @@ -12,14 +11,6 @@ - - - - - - - - diff --git a/src/NServiceBus.Core/NServiceBus.Core.csproj b/src/NServiceBus.Core/NServiceBus.Core.csproj index da33480763..4443474a7b 100644 --- a/src/NServiceBus.Core/NServiceBus.Core.csproj +++ b/src/NServiceBus.Core/NServiceBus.Core.csproj @@ -1,21 +1,12 @@ - net472;net6.0 + net8.0 NServiceBus true ..\NServiceBus.snk - 10.0 - - - - - - - - @@ -31,10 +22,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/NServiceBus.Learning.AcceptanceTests/NServiceBus.Learning.AcceptanceTests.csproj b/src/NServiceBus.Learning.AcceptanceTests/NServiceBus.Learning.AcceptanceTests.csproj index 37f5400c02..e4f7f786ee 100644 --- a/src/NServiceBus.Learning.AcceptanceTests/NServiceBus.Learning.AcceptanceTests.csproj +++ b/src/NServiceBus.Learning.AcceptanceTests/NServiceBus.Learning.AcceptanceTests.csproj @@ -1,8 +1,7 @@ - net472;net6.0;net7.0 - 10.0 + net8.0 @@ -10,10 +9,6 @@ - - - - diff --git a/src/NServiceBus.PersistenceTests/NServiceBus.PersistenceTests.csproj b/src/NServiceBus.PersistenceTests/NServiceBus.PersistenceTests.csproj index 45526519ea..76a7733f96 100644 --- a/src/NServiceBus.PersistenceTests/NServiceBus.PersistenceTests.csproj +++ b/src/NServiceBus.PersistenceTests/NServiceBus.PersistenceTests.csproj @@ -1,20 +1,15 @@ - net472;net6.0;net7.0 + net8.0 true ..\NServiceBusTests.snk - 10.0 - - - - diff --git a/src/NServiceBus.Testing.Fakes/NServiceBus.Testing.Fakes.csproj b/src/NServiceBus.Testing.Fakes/NServiceBus.Testing.Fakes.csproj index c154b6803e..5d8f06fb05 100644 --- a/src/NServiceBus.Testing.Fakes/NServiceBus.Testing.Fakes.csproj +++ b/src/NServiceBus.Testing.Fakes/NServiceBus.Testing.Fakes.csproj @@ -1,11 +1,10 @@  - net472;net6.0 + net8.0 NServiceBus.Testing true ..\NServiceBusTests.snk - 10.0 diff --git a/src/NServiceBus.TransportTests/NServiceBus.TransportTests.csproj b/src/NServiceBus.TransportTests/NServiceBus.TransportTests.csproj index b606fd4a01..7664cfa227 100644 --- a/src/NServiceBus.TransportTests/NServiceBus.TransportTests.csproj +++ b/src/NServiceBus.TransportTests/NServiceBus.TransportTests.csproj @@ -1,17 +1,13 @@ - net472;net6.0;net7.0 + net8.0 - - - - From 20a3132ca557ec219cb2869e769bff2480431c88 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 8 Aug 2023 12:08:49 -0400 Subject: [PATCH 02/51] Remove ifdefs --- .../NServiceBusAcceptanceTest.cs | 5 - .../Tx/When_receiving_with_dtc_enabled.cs | 2 - .../ForwardCancellationTokenTests.cs | 3 - .../Helpers/AnalyzerTestFixture.cs | 2 - .../API/NullableAnnotations.cs | 4 +- .../AssemblyScanner/AssemblyScannerTests.cs | 441 ------------------ .../MessageMapper/MessageMapperTests.cs | 2 - .../Hosting/Helpers/AssemblyScanner.cs | 7 +- .../Hosting/Helpers/AssemblyValidator.cs | 33 -- src/NServiceBus.Core/IdGeneration/CombGuid.cs | 122 +---- .../Pipeline/PipelineExecutionExtensions.cs | 12 +- .../Serializers/ReadOnlyStream.cs | 2 - .../Transports/Learning/AsyncFile.cs | 4 - .../Unicast/RunningEndpointInstance.cs | 6 +- ...ensionsForPersistenceTestsConfiguration.cs | 4 - ...When_persisting_a_saga_with_record_type.cs | 2 - 16 files changed, 6 insertions(+), 645 deletions(-) delete mode 100644 src/NServiceBus.Core.Tests/AssemblyScanner/AssemblyScannerTests.cs diff --git a/src/NServiceBus.AcceptanceTests/NServiceBusAcceptanceTest.cs b/src/NServiceBus.AcceptanceTests/NServiceBusAcceptanceTest.cs index d71f55e82c..d1c5d02501 100644 --- a/src/NServiceBus.AcceptanceTests/NServiceBusAcceptanceTest.cs +++ b/src/NServiceBus.AcceptanceTests/NServiceBusAcceptanceTest.cs @@ -18,11 +18,6 @@ public abstract partial 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 => { var classAndEndpoint = t.FullName.Split('.').Last(); diff --git a/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs b/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs index c02c5a0d15..213e54348a 100644 --- a/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs +++ b/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs @@ -21,7 +21,6 @@ public async Task Should_enlist_the_receive_in_the_dtc_tx() Assert.False(context.CanEnlistPromotable, "There should exists a DTC tx"); } -#if NETFRAMEWORK [Test] public void Basic_assumptions_promotable_should_fail_if_durable_already_exists() { @@ -33,7 +32,6 @@ public void Basic_assumptions_promotable_should_fail_if_durable_already_exists() tx.Complete(); } } -#endif [Test] public void Basic_assumptions_second_promotable_should_fail() diff --git a/src/NServiceBus.Core.Analyzer.Tests.Common/ForwardCancellationToken/ForwardCancellationTokenTests.cs b/src/NServiceBus.Core.Analyzer.Tests.Common/ForwardCancellationToken/ForwardCancellationTokenTests.cs index 886b18715d..ddaf3bf669 100644 --- a/src/NServiceBus.Core.Analyzer.Tests.Common/ForwardCancellationToken/ForwardCancellationTokenTests.cs +++ b/src/NServiceBus.Core.Analyzer.Tests.Common/ForwardCancellationToken/ForwardCancellationTokenTests.cs @@ -512,8 +512,6 @@ Task Test(string s, int i, DateTime d, CancellationToken token = default) public class TestMessage : ICommand {} "); -#if NET // IAsyncEnumerable requires package Microsoft.Bcl.AsyncInterfaces on .NET Framework - [TestCase("AsyncEnumerator(context.CancellationToken)")] [TestCase("AsyncEnumerator(CancellationToken.None)")] [TestCase("AsyncEnumerator(default(CancellationToken))")] @@ -551,7 +549,6 @@ static async IAsyncEnumerable AsyncEnumerator([EnumeratorCancellation] Canc } public class TestMessage : ICommand {} "); -#endif } public class ForwardCancellationTokenTestsCSharp9 : ForwardCancellationTokenTestsCSharp8 diff --git a/src/NServiceBus.Core.Analyzer.Tests.Common/Helpers/AnalyzerTestFixture.cs b/src/NServiceBus.Core.Analyzer.Tests.Common/Helpers/AnalyzerTestFixture.cs index b98dffcce2..9a2aefb604 100644 --- a/src/NServiceBus.Core.Analyzer.Tests.Common/Helpers/AnalyzerTestFixture.cs +++ b/src/NServiceBus.Core.Analyzer.Tests.Common/Helpers/AnalyzerTestFixture.cs @@ -108,11 +108,9 @@ static AnalyzerTestFixture() MetadataReference.CreateFromFile(typeof(object).GetTypeInfo().Assembly.Location), MetadataReference.CreateFromFile(typeof(Enumerable).GetTypeInfo().Assembly.Location), MetadataReference.CreateFromFile(typeof(System.Linq.Expressions.Expression).GetTypeInfo().Assembly.Location), -#if NET MetadataReference.CreateFromFile(Assembly.Load("System.Runtime").Location), MetadataReference.CreateFromFile(Assembly.Load("System.Console").Location), MetadataReference.CreateFromFile(Assembly.Load("System.Private.CoreLib").Location), -#endif MetadataReference.CreateFromFile(typeof(EndpointConfiguration).GetTypeInfo().Assembly.Location), MetadataReference.CreateFromFile(typeof(IUniformSession).GetTypeInfo().Assembly.Location)); } diff --git a/src/NServiceBus.Core.Tests/API/NullableAnnotations.cs b/src/NServiceBus.Core.Tests/API/NullableAnnotations.cs index d3b0755388..49434e540b 100644 --- a/src/NServiceBus.Core.Tests/API/NullableAnnotations.cs +++ b/src/NServiceBus.Core.Tests/API/NullableAnnotations.cs @@ -1,5 +1,4 @@ -#if NET6_0_OR_GREATER -namespace NServiceBus.Core.Tests.API +namespace NServiceBus.Core.Tests.API { using System; using System.Collections.Generic; @@ -100,4 +99,3 @@ bool HasNonAnnotatedMember(Type type) } } } -#endif \ No newline at end of file diff --git a/src/NServiceBus.Core.Tests/AssemblyScanner/AssemblyScannerTests.cs b/src/NServiceBus.Core.Tests/AssemblyScanner/AssemblyScannerTests.cs deleted file mode 100644 index 3a404e8af2..0000000000 --- a/src/NServiceBus.Core.Tests/AssemblyScanner/AssemblyScannerTests.cs +++ /dev/null @@ -1,441 +0,0 @@ -#if NETFRAMEWORK -namespace NServiceBus.Core.Tests.AssemblyScanner -{ - using System; - using System.CodeDom.Compiler; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Text; - using System.Threading; - using Hosting.Helpers; - using Microsoft.CSharp; - using Mono.Cecil; - using NUnit.Framework; - - [TestFixture] - public class AssemblyScannerTests - { - [SetUp] - public void SetUp() - { - if (!AppDomainRunner.IsInTestAppDomain) - { - AppDomainRunner.DataStore.Set("TestDirectory", TestContext.CurrentContext.TestDirectory); - - if (Directory.Exists(DynamicAssembly.TestAssemblyDirectory)) - { - Directory.Delete(DynamicAssembly.TestAssemblyDirectory, true); - } - - Directory.CreateDirectory(DynamicAssembly.TestAssemblyDirectory); - } - } - - [TearDown] - public void TearDown() - { - if (!AppDomainRunner.IsInTestAppDomain) - { - Directory.Delete(DynamicAssembly.TestAssemblyDirectory, true); - } - } - - [Test] - [RunInApplicationDomain] - public void Assemblies_with_direct_core_reference_are_included() - { - var busAssembly = new DynamicAssembly("Fake.NServiceBus.Core.dll"); - var assemblyWithReference = new DynamicAssembly("AssemblyWithReference.dll", new[] { busAssembly }); - - var scanner = CreateDefaultAssemblyScanner(busAssembly); - - var result = scanner.GetScannableAssemblies(); - - Assert.IsTrue(result.Assemblies.Contains(assemblyWithReference)); - Assert.AreEqual(2, result.Assemblies.Count); - } - - [Test] - [RunInApplicationDomain] - public void Assemblies_with_no_core_reference_are_excluded() - { - var busAssembly = new DynamicAssembly("Fake.NServiceBus.Core"); - var assemblyWithReference = new DynamicAssembly("AssemblyWithReference", new[] - { - busAssembly - }); - var assemblyWithoutReference = new DynamicAssembly("AssemblyWithoutReference"); - - var scanner = CreateDefaultAssemblyScanner(busAssembly); - - var result = scanner.GetScannableAssemblies(); - - Assert.IsTrue(result.Assemblies.Contains(assemblyWithReference)); - Assert.IsFalse(result.Assemblies.Contains(assemblyWithoutReference)); - Assert.AreEqual(2, result.Assemblies.Count); - } - - [Test] - [RunInApplicationDomain] - public void Assemblies_which_reference_older_core_version_are_included() - { - var busAssemblyV2 = new DynamicAssembly("Fake.NServiceBus.Core", version: new Version(2, 0, 0), fakeIdentity: true); - var assemblyReferencesV2 = new DynamicAssembly("AssemblyWithReference2", new[] - { - busAssemblyV2 - }); - var busAssemblyV1 = new DynamicAssembly("Fake.NServiceBus.Core", version: new Version(1, 0, 0), fakeIdentity: true); - var assemblyReferencesV1 = new DynamicAssembly("AssemblyWithReference1", new[] - { - busAssemblyV1 - }); - - var scanner = new AssemblyScanner(DynamicAssembly.TestAssemblyDirectory) - { - ThrowExceptions = false, - ScanAppDomainAssemblies = false, - CoreAssemblyName = busAssemblyV2.Name - }; - - var result = scanner.GetScannableAssemblies(); - - Assert.IsTrue(result.Assemblies.Contains(assemblyReferencesV1)); - Assert.IsTrue(result.Assemblies.Contains(assemblyReferencesV2)); - Assert.AreEqual(3, result.Assemblies.Count); - } - - [Test] - [RunInApplicationDomain] - public void Assemblies_with_transitive_core_references_are_included() - { - var busAssembly = new DynamicAssembly("Fake.NServiceBus.Core"); - var assemblyC = new DynamicAssembly("C", new[] - { - busAssembly - }); - var assemblyB = new DynamicAssembly("B", new[] - { - assemblyC - }); - var assemblyA = new DynamicAssembly("A", new[] - { - assemblyB - }); - var assemblyD = new DynamicAssembly("D", new[] - { - assemblyB - }); - - var scanner = CreateDefaultAssemblyScanner(busAssembly); - - var result = scanner.GetScannableAssemblies(); - - Assert.IsTrue(result.Assemblies.Contains(assemblyA)); - Assert.IsTrue(result.Assemblies.Contains(assemblyB)); - Assert.IsTrue(result.Assemblies.Contains(assemblyC)); - Assert.IsTrue(result.Assemblies.Contains(assemblyD)); - Assert.IsTrue(result.Assemblies.Contains(busAssembly)); - Assert.AreEqual(5, result.Assemblies.Count); - } - - [Test] - [RunInApplicationDomain] - public void Transitive_references_are_excluded() - { - var busAssembly = new DynamicAssembly("Fake.NServiceBus.Core"); - var assemblyC = new DynamicAssembly("C"); - var assemblyB = new DynamicAssembly("B", new[] - { - busAssembly - }); - var assemblyA = new DynamicAssembly("A", new[] - { - assemblyB, - assemblyC - }); - - var scanner = CreateDefaultAssemblyScanner(busAssembly); - - var result = scanner.GetScannableAssemblies(); - - Assert.IsTrue(result.Assemblies.Contains(busAssembly)); - Assert.IsTrue(result.Assemblies.Contains(assemblyA)); - Assert.IsTrue(result.Assemblies.Contains(assemblyB)); - Assert.IsFalse(result.Assemblies.Contains(assemblyC)); - Assert.AreEqual(3, result.Assemblies.Count); - } - - [Test] - [RunInApplicationDomain] - public void Should_always_include_core_assembly_types() - { - var busAssembly = new DynamicAssembly("Fake.NServiceBus.Core"); - - var scanner = new AssemblyScanner - { - CoreAssemblyName = "NServiceBus.Core", - ScanAppDomainAssemblies = false, - ScanFileSystemAssemblies = false - }; // don't scan the dynamic assembly folder - - var result = scanner.GetScannableAssemblies(); - - Assert.IsTrue(result.Assemblies.Any(a => a.FullName == typeof(Endpoint).Assembly.FullName)); - } - - [Test] - [RunInApplicationDomain] - public void AppDomainAssemblies_are_included_when_enabling_ScanAppDomainAssemblies() - { - var busAssembly = new DynamicAssembly("Fake.NServiceBus.Core"); - var appDomainAssembly = new DynamicAssembly("AppDomainAssembly", references: new[] { busAssembly }); - Assembly.LoadFrom(appDomainAssembly.FilePath); - - var scanner = CreateDefaultAssemblyScanner(busAssembly); - scanner.ScanAppDomainAssemblies = true; - scanner.ScanFileSystemAssemblies = false; - - var result = scanner.GetScannableAssemblies(); - - Assert.IsTrue(result.Assemblies.Contains(appDomainAssembly)); - } - - [Test] - [RunInApplicationDomain] - public void FileSystemAssemblies_are_excluded_when_disabling_ScanFileSystemAssemblies() - { - var busAssembly = new DynamicAssembly("Fake.NServiceBus.Core"); - - var scanner = CreateDefaultAssemblyScanner(busAssembly); - scanner.ScanAppDomainAssemblies = false; - scanner.ScanFileSystemAssemblies = false; - - var result = scanner.GetScannableAssemblies(); - - Assert.IsFalse(result.Assemblies.Contains(busAssembly)); - } - - [Test] - [RunInApplicationDomain] - public void Does_not_throw_exception_when_scanning_duplicate_assemblies() - { - var busAssembly = new DynamicAssembly("Fake.NServiceBus.Core"); - var duplicateAssembly = new DynamicAssembly("DuplicateAssembly", references: new[] { busAssembly }); - - Directory.CreateDirectory(Path.Combine(DynamicAssembly.TestAssemblyDirectory, "subdir")); - var destFileName = Path.Combine(DynamicAssembly.TestAssemblyDirectory, "subdir", duplicateAssembly.FileName); - // create a duplicate of the scanned assembly in a subfolder: - File.Copy(duplicateAssembly.FilePath, destFileName); - - var scanner = CreateDefaultAssemblyScanner(busAssembly); - scanner.ScanNestedDirectories = true; - - var result = scanner.GetScannableAssemblies(); // should not throw - Assert.IsTrue(result.Assemblies.Contains(duplicateAssembly)); - } - - [Ignore("can't force an actual error")] - [Test] - [RunInApplicationDomain] - public void Ignore_assembly_loading_errors_when_disabling_ThrowExceptions() - { - // can't setup a test scenario that causes assembly loading to fail - - var scanner = new AssemblyScanner(DynamicAssembly.TestAssemblyDirectory) - { - ScanAppDomainAssemblies = true, - ThrowExceptions = false - }; - - var result = scanner.GetScannableAssemblies(); - - Assert.IsTrue(result.ErrorsThrownDuringScanning); - } - - [Test] - [RunInApplicationDomain] - public void Skipped_dlls_should_be_excluded() - { - var busAssembly = new DynamicAssembly("Fake.NServiceBus.Core"); - var excludedAssembly1 = new DynamicAssembly("A", new[] - { - busAssembly - }); - var excludedAssembly2 = new DynamicAssembly("A", new[] - { - busAssembly - }); - var includedAssembly = new DynamicAssembly("B", new[] - { - busAssembly - }); - - var scanner = CreateDefaultAssemblyScanner(busAssembly); - scanner.AssembliesToSkip.Add(excludedAssembly1.DynamicName); // without file extension - scanner.AssembliesToSkip.Add(excludedAssembly2.FileName); // with file extension - - var result = scanner.GetScannableAssemblies(); - Assert.That(result.SkippedFiles.Any(s => s.FilePath == excludedAssembly1.FilePath)); - Assert.That(result.SkippedFiles.Any(s => s.FilePath == excludedAssembly2.FilePath)); - Assert.That(result.Assemblies.Contains(includedAssembly.Assembly)); - } - - [Test] - [RunInApplicationDomain] - public void Skipped_exes_should_be_excluded() - { - var busAssembly = new DynamicAssembly("Fake.NServiceBus.Core"); - var excludedAssembly1 = new DynamicAssembly("A", new[] - { - busAssembly - }, executable: true); - var excludedAssembly2 = new DynamicAssembly("A", new[] - { - busAssembly - }, executable: true); - var includedAssembly = new DynamicAssembly("B", new[] - { - busAssembly - }, executable: true); - - var scanner = CreateDefaultAssemblyScanner(busAssembly); - scanner.AssembliesToSkip.Add(excludedAssembly1.DynamicName); // without file extension - scanner.AssembliesToSkip.Add(excludedAssembly2.FileName); // with file extension - - var result = scanner.GetScannableAssemblies(); - Assert.That(result.SkippedFiles.Any(s => s.FilePath == excludedAssembly1.FilePath)); - Assert.That(result.SkippedFiles.Any(s => s.FilePath == excludedAssembly2.FilePath)); - Assert.That(result.Assemblies.Contains(includedAssembly.Assembly)); - } - - static AssemblyScanner CreateDefaultAssemblyScanner(DynamicAssembly coreAssembly = null) => - new AssemblyScanner(DynamicAssembly.TestAssemblyDirectory) - { - CoreAssemblyName = coreAssembly.DynamicName, - ScanAppDomainAssemblies = true, - ScanFileSystemAssemblies = true, - ThrowExceptions = true - }; - - [DebuggerDisplay("Name = {Name}, DynamicName = {DynamicName}, Namespace = {Namespace}, FileName = {FileName}")] - class DynamicAssembly - { - public DynamicAssembly(string nameWithoutExtension, DynamicAssembly[] references = null, Version version = null, bool fakeIdentity = false, string content = null, bool executable = false) - { - if (version == null) - { - version = new Version(1, 0, 0, 0); - } - - references ??= new DynamicAssembly[0]; - - Name = nameWithoutExtension; - Namespace = nameWithoutExtension; - var fileExtension = executable ? "exe" : "dll"; - FileName = $"{Namespace}{Path.GetFileNameWithoutExtension(Path.GetRandomFileName())}{Interlocked.Increment(ref dynamicAssemblyId)}.{fileExtension}"; - DynamicName = Path.GetFileNameWithoutExtension(FileName); - - var builder = new StringBuilder(); - builder.AppendLine("using System.Reflection;"); - builder.AppendLine($"[assembly: AssemblyVersion(\"{version}\")]"); - builder.AppendLine($"[assembly: AssemblyFileVersion(\"{version}\")]"); - - builder.AppendFormat("namespace {0} {{ ", Namespace); - - var provider = new CSharpCodeProvider(); - var param = new CompilerParameters(new string[] - { - }, FileName) - { - GenerateExecutable = false, - GenerateInMemory = false, - OutputAssembly = FilePath = Path.Combine(TestAssemblyDirectory, FileName), - TempFiles = new TempFileCollection(TestAssemblyDirectory, false) - }; - - foreach (var reference in references) - { - builder.AppendLine($"using {reference.Namespace};"); - param.ReferencedAssemblies.Add(reference.FilePath); - } - - if (executable) - { - param.GenerateExecutable = true; - builder.AppendLine("public static class Program { public static void Main(string[] args){} }"); - } - - if (content == null) - { - builder.AppendLine("public class Foo { public Foo() {"); - foreach (var reference in references) - { - builder.AppendLine($"new {reference.Namespace}.Foo();"); - } - builder.AppendLine("} }"); - } - else - { - builder.AppendLine(content); - } - - builder.AppendLine(" }"); - - var result = provider.CompileAssemblyFromSource(param, builder.ToString()); - ThrowIfCompilationWasNotSuccessful(result); - provider.Dispose(); - - if (fakeIdentity) - { - using (var assemblyDefinition = AssemblyDefinition.ReadAssembly(FilePath, new ReaderParameters - { - ReadWrite = true - })) - { - assemblyDefinition.Name.Name = nameWithoutExtension; - assemblyDefinition.MainModule.Name = nameWithoutExtension; - assemblyDefinition.Write(); - } - } - - Assembly = result.CompiledAssembly; - } - - public string Namespace { get; } - - public string Name { get; } - - public string DynamicName { get; } - - public string FileName { get; } - - public string FilePath { get; } - - public Assembly Assembly { get; } - - public static string TestDirectory => AppDomainRunner.DataStore.Get("TestDirectory"); - - public static string TestAssemblyDirectory => Path.Combine(TestDirectory, "assemblyscannerfiles"); - - static void ThrowIfCompilationWasNotSuccessful(CompilerResults results) - { - if (results.Errors.HasErrors) - { - var errors = new StringBuilder($"Compiler Errors :{Environment.NewLine}"); - foreach (CompilerError error in results.Errors) - { - errors.Append($"Line {error.Line},{error.Column}\t: {error.ErrorText}{Environment.NewLine}"); - } - throw new Exception(errors.ToString()); - } - } - - public static implicit operator Assembly(DynamicAssembly dynamicAssembly) => dynamicAssembly.Assembly; - - static long dynamicAssemblyId; - } - } -} -#endif diff --git a/src/NServiceBus.Core.Tests/MessageMapper/MessageMapperTests.cs b/src/NServiceBus.Core.Tests/MessageMapper/MessageMapperTests.cs index 5432ff5593..7b47a31f16 100644 --- a/src/NServiceBus.Core.Tests/MessageMapper/MessageMapperTests.cs +++ b/src/NServiceBus.Core.Tests/MessageMapper/MessageMapperTests.cs @@ -47,7 +47,6 @@ public void CreateInstance_WhenMessageInitialized_ShouldBeThreadsafe() }); } -#if NET #nullable enable [Test] public void Should_handle_messages_with_nullable_reference_types() @@ -68,7 +67,6 @@ public class NullableComplexTypeItem { } #nullable disable -#endif [Test] public void CreateInstance_WhenMessageNotInitialized_ShouldBeThreadsafe() diff --git a/src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs b/src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs index aafd0dde7d..35bcb02e3a 100644 --- a/src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs +++ b/src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs @@ -6,9 +6,7 @@ namespace NServiceBus.Hosting.Helpers using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; -#if NET using System.Runtime.Loader; -#endif using System.Text; using Logging; @@ -170,12 +168,9 @@ bool TryLoadScannableAssembly(string assemblyPath, AssemblyScannerResults result try { -#if NET var context = AssemblyLoadContext.GetLoadContext(Assembly.GetExecutingAssembly()); assembly = context.LoadFromAssemblyPath(assemblyPath); -#else - assembly = Assembly.LoadFrom(assemblyPath); -#endif + return true; } catch (Exception ex) when (ex is BadImageFormatException or FileLoadException) diff --git a/src/NServiceBus.Core/Hosting/Helpers/AssemblyValidator.cs b/src/NServiceBus.Core/Hosting/Helpers/AssemblyValidator.cs index 8baca0d701..ae028fd192 100644 --- a/src/NServiceBus.Core/Hosting/Helpers/AssemblyValidator.cs +++ b/src/NServiceBus.Core/Hosting/Helpers/AssemblyValidator.cs @@ -1,45 +1,13 @@ namespace NServiceBus { using System; -#if NETFRAMEWORK - using System.Reflection; -#endif -#if NET using System.IO; using System.Reflection.Metadata; using System.Reflection.PortableExecutable; using System.Security.Cryptography; -#endif class AssemblyValidator { -#if NETFRAMEWORK - public void ValidateAssemblyFile(string assemblyPath, out bool shouldLoad, out string reason) - { - try - { - var token = AssemblyName.GetAssemblyName(assemblyPath).GetPublicKeyToken(); - - if (IsRuntimeAssembly(token)) - { - shouldLoad = false; - reason = "File is a .NET runtime assembly."; - return; - } - } - catch (BadImageFormatException) - { - shouldLoad = false; - reason = "File is not a .NET assembly."; - return; - } - - shouldLoad = true; - reason = "File is a .NET assembly."; - } -#endif - -#if NET public void ValidateAssemblyFile(string assemblyPath, out bool shouldLoad, out string reason) { using (var stream = File.OpenRead(assemblyPath)) @@ -96,7 +64,6 @@ static byte[] GetPublicKeyToken(byte[] publicKey) return publicKeyToken; } } -#endif public static bool IsRuntimeAssembly(byte[] publicKeyToken) { diff --git a/src/NServiceBus.Core/IdGeneration/CombGuid.cs b/src/NServiceBus.Core/IdGeneration/CombGuid.cs index 86ee77f1de..835b910e52 100644 --- a/src/NServiceBus.Core/IdGeneration/CombGuid.cs +++ b/src/NServiceBus.Core/IdGeneration/CombGuid.cs @@ -2,10 +2,6 @@ namespace NServiceBus { using System; using System.Buffers.Binary; -#if NETFRAMEWORK - using System.Runtime.InteropServices; - using System.Runtime.CompilerServices; -#endif /// /// Generates a Guid using http://www.informit.com/articles/article.asp?p=25862 @@ -23,13 +19,9 @@ internal static Guid Generate(Guid inputGuid, DateTime inputNow) { var newGuid = inputGuid; Span guidArray = stackalloc byte[16]; -#if NET + if (!newGuid.TryWriteBytes(guidArray)) -#else - if (TryWriteBytes(newGuid, guidArray)) -#endif { - guidArray = newGuid.ToByteArray(); } @@ -66,121 +58,9 @@ internal static Guid Generate(Guid inputGuid, DateTime inputNow) daysArray.Slice(daysArray.Length - 2).CopyTo(guidArray.Slice(10, 2)); milliSecondsArray.Slice(milliSecondsArray.Length - 4).CopyTo(guidArray.Slice(12, 4)); -#if NET return new Guid(guidArray); -#else - if (!TryParseGuidBytes(guidArray, out Guid readGuid)) - { - readGuid = new Guid(guidArray.ToArray()); - } - return readGuid; -#endif - } - -#if NETFRAMEWORK - - static bool TryWriteBytes(Guid guid, Span buffer) - { - // Based on https://github.com/dotnet/runtime/blob/9129083c2fc6ef32479168f0555875b54aee4dfb/src/libraries/System.Private.CoreLib/src/System/Guid.cs#L836 - - if (buffer.Length < 16) - { - return false; - } - - if (BitConverter.IsLittleEndian) - { - MemoryMarshal.Write(buffer, ref guid); - return true; - } - - // slower path for BigEndian - GuidData data = Unsafe.As(ref guid); - - buffer[15] = data.K; // hoist bounds checks - BinaryPrimitives.WriteInt32LittleEndian(buffer, data.A); - BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(4), data.B); - BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(6), data.C); - buffer[8] = data.D; - buffer[9] = data.E; - buffer[10] = data.F; - buffer[11] = data.G; - buffer[12] = data.H; - buffer[13] = data.I; - buffer[14] = data.J; - return true; } - // This struct has the fields layed out to be GUID-like in order to read the GUID fields - // to efficiently write them into memory without having to deal with endianness - // Do not rename or reorder the fields. - readonly struct GuidData - { - public readonly int A; - public readonly short B; - public readonly short C; - public readonly byte D; - public readonly byte E; - public readonly byte F; - public readonly byte G; - public readonly byte H; - public readonly byte I; - public readonly byte J; - public readonly byte K; - - // Creates a new GUID like struct initialized to the value represented by the - // arguments. The bytes are specified like this to avoid endianness issues. - public GuidData(int a, short b, short c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k) - { - A = a; - B = b; - C = c; - D = d; - E = e; - F = f; - G = g; - H = h; - I = i; - J = j; - K = k; - } - } - - static bool TryParseGuidBytes(ReadOnlySpan bytes, out Guid guid) - { - if (bytes.Length != GuidSizeInBytes) - { - guid = default; - return false; - } - - if (BitConverter.IsLittleEndian) - { - guid = MemoryMarshal.Read(bytes); - return true; - } - - // copied from https://github.com/dotnet/runtime/blob/9129083c2fc6ef32479168f0555875b54aee4dfb/src/libraries/System.Private.CoreLib/src/System/Guid.cs#L49 - // slower path for BigEndian: - byte k = bytes[15]; // hoist bounds checks - int a = BinaryPrimitives.ReadInt32LittleEndian(bytes); - short b = BinaryPrimitives.ReadInt16LittleEndian(bytes.Slice(4)); - short c = BinaryPrimitives.ReadInt16LittleEndian(bytes.Slice(6)); - byte d = bytes[8]; - byte e = bytes[9]; - byte f = bytes[10]; - byte g = bytes[11]; - byte h = bytes[12]; - byte i = bytes[13]; - byte j = bytes[14]; - - guid = new Guid(a, b, c, d, e, f, g, h, i, j, k); - return true; - } - - const int GuidSizeInBytes = 16; -#endif - // Represents new DateTime(1900, 1, 1).Ticks, while this would be more readable having a const here instead of // a static field the less readable version slightly improves the throughput const long BaseDateTicks = 599266080000000000; // new DateTime(1900, 1, 1).Ticks diff --git a/src/NServiceBus.Core/Pipeline/PipelineExecutionExtensions.cs b/src/NServiceBus.Core/Pipeline/PipelineExecutionExtensions.cs index 240a44ebc7..f266497ce5 100644 --- a/src/NServiceBus.Core/Pipeline/PipelineExecutionExtensions.cs +++ b/src/NServiceBus.Core/Pipeline/PipelineExecutionExtensions.cs @@ -5,10 +5,8 @@ using System.Linq; using System.Linq.Expressions; using System.Reflection; -#if NET - using System.Runtime.InteropServices; -#endif using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; using System.Threading.Tasks; using FastExpressionCompiler; using Pipeline; @@ -71,20 +69,12 @@ static Delegate CreateBehaviorCallDelegate(MethodInfo methodInfo, ParameterExpre return lambdaExpression.CompileFast(); } -#if NET [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TBehavior GetBehavior(TContext context, int index) where TContext : class, IBehaviorContext where TBehavior : class, IBehavior => Unsafe.As( Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(context.Extensions.Behaviors), index)); -#else - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TBehavior GetBehavior(TContext context, int index) - where TContext : class, IBehaviorContext - where TBehavior : class, IBehavior - => (TBehavior)context.Extensions.Behaviors[index]; -#endif /// /// context{i} => return TaskEx.CompletedTask; diff --git a/src/NServiceBus.Core/Serializers/ReadOnlyStream.cs b/src/NServiceBus.Core/Serializers/ReadOnlyStream.cs index c7f80ef675..966be0076d 100644 --- a/src/NServiceBus.Core/Serializers/ReadOnlyStream.cs +++ b/src/NServiceBus.Core/Serializers/ReadOnlyStream.cs @@ -34,7 +34,6 @@ public override int Read(byte[] buffer, int offset, int count) return bytesToCopy; } -#if NET public override int Read(Span buffer) { var bytesToCopy = Math.Min(memory.Length - position, buffer.Length); @@ -49,7 +48,6 @@ public override int Read(Span buffer) position += bytesToCopy; return bytesToCopy; } -#endif public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException(); diff --git a/src/NServiceBus.Core/Transports/Learning/AsyncFile.cs b/src/NServiceBus.Core/Transports/Learning/AsyncFile.cs index 6b8e2a2b53..17e7810702 100644 --- a/src/NServiceBus.Core/Transports/Learning/AsyncFile.cs +++ b/src/NServiceBus.Core/Transports/Learning/AsyncFile.cs @@ -15,11 +15,7 @@ public static async Task WriteBytes(string filePath, ReadOnlyMemory bytes, { using (var stream = CreateWriteStream(filePath, FileMode.Create)) { -#if NET await stream.WriteAsync(bytes, cancellationToken).ConfigureAwait(false); -#else - await stream.WriteAsync(bytes.ToArray(), 0, bytes.Length, cancellationToken).ConfigureAwait(false); -#endif } } diff --git a/src/NServiceBus.Core/Unicast/RunningEndpointInstance.cs b/src/NServiceBus.Core/Unicast/RunningEndpointInstance.cs index 010520c5ae..d332edb57a 100644 --- a/src/NServiceBus.Core/Unicast/RunningEndpointInstance.cs +++ b/src/NServiceBus.Core/Unicast/RunningEndpointInstance.cs @@ -77,11 +77,9 @@ public async Task Stop(CancellationToken cancellationToken = default) finally { stopSemaphore.Release(); -#if NET + await tokenRegistration.DisposeAsync().ConfigureAwait(false); -#else - tokenRegistration.Dispose(); -#endif + stoppingTokenSource.Dispose(); } } diff --git a/src/NServiceBus.PersistenceTests/RequiresExtensionsForPersistenceTestsConfiguration.cs b/src/NServiceBus.PersistenceTests/RequiresExtensionsForPersistenceTestsConfiguration.cs index 0927c9bacc..c61d112377 100644 --- a/src/NServiceBus.PersistenceTests/RequiresExtensionsForPersistenceTestsConfiguration.cs +++ b/src/NServiceBus.PersistenceTests/RequiresExtensionsForPersistenceTestsConfiguration.cs @@ -10,10 +10,6 @@ public static void RequiresDtcSupport(this IPersistenceTestsConfiguration config { Assert.Ignore("Ignoring this test because it requires DTC transaction support from persister."); } - -#if NET - Assert.Ignore(".NET does not support distributed transactions."); -#endif } public static void RequiresOutboxSupport(this IPersistenceTestsConfiguration configuration) diff --git a/src/NServiceBus.PersistenceTests/Sagas/When_persisting_a_saga_with_record_type.cs b/src/NServiceBus.PersistenceTests/Sagas/When_persisting_a_saga_with_record_type.cs index 61d7ad2148..f76260b85e 100644 --- a/src/NServiceBus.PersistenceTests/Sagas/When_persisting_a_saga_with_record_type.cs +++ b/src/NServiceBus.PersistenceTests/Sagas/When_persisting_a_saga_with_record_type.cs @@ -1,6 +1,5 @@ namespace NServiceBus.PersistenceTesting.Sagas { -#if NET using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -102,5 +101,4 @@ public When_persisting_a_saga_with_record_type(TestVariant param) : base(param) } } -#endif } \ No newline at end of file From 1b83e3cddf9fd3d778aa793db07db4136c97cc93 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 8 Aug 2023 12:56:33 -0400 Subject: [PATCH 03/51] Update Analyzer to use latest 17.7 package --- .../.editorconfig | 13 --------- ...viceBus.Core.Analyzer.Tests.Roslyn3.csproj | 28 ------------------- ...viceBus.Core.Analyzer.Tests.Roslyn4.csproj | 2 +- .../AwaitOrCaptureTasksAnalyzer.cs | 2 +- .../NServiceBus.Core.Analyzer.csproj | 3 +- .../RewriteConfigureHowToFindSagaFixer.cs | 2 +- src/NServiceBus.sln | 7 ----- 7 files changed, 5 insertions(+), 52 deletions(-) delete mode 100644 src/NServiceBus.Core.Analyzer.Tests.Roslyn3/.editorconfig delete mode 100644 src/NServiceBus.Core.Analyzer.Tests.Roslyn3/NServiceBus.Core.Analyzer.Tests.Roslyn3.csproj diff --git a/src/NServiceBus.Core.Analyzer.Tests.Roslyn3/.editorconfig b/src/NServiceBus.Core.Analyzer.Tests.Roslyn3/.editorconfig deleted file mode 100644 index e8504d15cf..0000000000 --- a/src/NServiceBus.Core.Analyzer.Tests.Roslyn3/.editorconfig +++ /dev/null @@ -1,13 +0,0 @@ -[*.cs] - -# Justification: Test project -dotnet_diagnostic.CA2007.severity = none - -# Justification: Tests don't support cancellation and don't need to forward IMessageHandlerContext.CancellationToken -dotnet_diagnostic.NSB0002.severity = suggestion - -# Justification: Tests don't support cancellation -dotnet_diagnostic.PS0018.severity = suggestion - -# bug in analyzer when multi-targetting -dotnet_diagnostic.IDE0063.severity = none # Use simple 'using' statement diff --git a/src/NServiceBus.Core.Analyzer.Tests.Roslyn3/NServiceBus.Core.Analyzer.Tests.Roslyn3.csproj b/src/NServiceBus.Core.Analyzer.Tests.Roslyn3/NServiceBus.Core.Analyzer.Tests.Roslyn3.csproj deleted file mode 100644 index 19e7937c8e..0000000000 --- a/src/NServiceBus.Core.Analyzer.Tests.Roslyn3/NServiceBus.Core.Analyzer.Tests.Roslyn3.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - net8.0 - $(DefineConstants);ROSLYN3 - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj b/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj index 23f585c8ca..ced7a7b991 100644 --- a/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj +++ b/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/NServiceBus.Core.Analyzer/AwaitOrCaptureTasksAnalyzer.cs b/src/NServiceBus.Core.Analyzer/AwaitOrCaptureTasksAnalyzer.cs index 0c07459bdd..8cd2b0b208 100644 --- a/src/NServiceBus.Core.Analyzer/AwaitOrCaptureTasksAnalyzer.cs +++ b/src/NServiceBus.Core.Analyzer/AwaitOrCaptureTasksAnalyzer.cs @@ -51,7 +51,7 @@ static void Analyze(SyntaxNodeAnalysisContext context) } static bool CouldBeMethodRequiringAwait(SyntaxToken syntaxToken) => - syntaxToken.Kind() == SyntaxKind.IdentifierToken && methodNames.Contains(syntaxToken.Text); + syntaxToken.IsKind(SyntaxKind.IdentifierToken) && methodNames.Contains(syntaxToken.Text); static bool IsMethodRequiringAwait(ExpressionSyntax call, SyntaxNodeAnalysisContext context) => context.SemanticModel.GetSymbolInfo(call, context.CancellationToken).Symbol is IMethodSymbol methodSymbol && diff --git a/src/NServiceBus.Core.Analyzer/NServiceBus.Core.Analyzer.csproj b/src/NServiceBus.Core.Analyzer/NServiceBus.Core.Analyzer.csproj index d5c045afe2..3ed71f9321 100644 --- a/src/NServiceBus.Core.Analyzer/NServiceBus.Core.Analyzer.csproj +++ b/src/NServiceBus.Core.Analyzer/NServiceBus.Core.Analyzer.csproj @@ -6,12 +6,13 @@ ..\NServiceBus.snk false false + true - + diff --git a/src/NServiceBus.Core.Analyzer/Sagas/RewriteConfigureHowToFindSagaFixer.cs b/src/NServiceBus.Core.Analyzer/Sagas/RewriteConfigureHowToFindSagaFixer.cs index dc1da0c1b0..879fe78959 100644 --- a/src/NServiceBus.Core.Analyzer/Sagas/RewriteConfigureHowToFindSagaFixer.cs +++ b/src/NServiceBus.Core.Analyzer/Sagas/RewriteConfigureHowToFindSagaFixer.cs @@ -26,7 +26,7 @@ public class RewriteConfigureHowToFindSagaFixer : CodeFixProvider public override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer; - static readonly string NewLine = System.Environment.NewLine; + static readonly string NewLine = "\r\n"; //System.Environment.NewLine; public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) { diff --git a/src/NServiceBus.sln b/src/NServiceBus.sln index 70332477f7..75edc3f3fb 100644 --- a/src/NServiceBus.sln +++ b/src/NServiceBus.sln @@ -30,8 +30,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.Core.Analyzer", "NServiceBus.Core.Analyzer\NServiceBus.Core.Analyzer.csproj", "{A5C32904-ECEC-492B-8217-8BFB5CC1443C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.Core.Analyzer.Tests.Roslyn3", "NServiceBus.Core.Analyzer.Tests.Roslyn3\NServiceBus.Core.Analyzer.Tests.Roslyn3.csproj", "{940AD1FA-E3D7-41FB-A832-2A84EF06C4DD}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analyzer", "Analyzer", "{6CF85707-290E-4FA1-8444-25D29B6A6BA8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.PersistenceTests", "NServiceBus.PersistenceTests\NServiceBus.PersistenceTests.csproj", "{157D1894-BAE7-45B2-9906-0445B38F3A97}" @@ -78,10 +76,6 @@ Global {A5C32904-ECEC-492B-8217-8BFB5CC1443C}.Debug|Any CPU.Build.0 = Debug|Any CPU {A5C32904-ECEC-492B-8217-8BFB5CC1443C}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5C32904-ECEC-492B-8217-8BFB5CC1443C}.Release|Any CPU.Build.0 = Release|Any CPU - {940AD1FA-E3D7-41FB-A832-2A84EF06C4DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {940AD1FA-E3D7-41FB-A832-2A84EF06C4DD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {940AD1FA-E3D7-41FB-A832-2A84EF06C4DD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {940AD1FA-E3D7-41FB-A832-2A84EF06C4DD}.Release|Any CPU.Build.0 = Release|Any CPU {157D1894-BAE7-45B2-9906-0445B38F3A97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {157D1894-BAE7-45B2-9906-0445B38F3A97}.Debug|Any CPU.Build.0 = Debug|Any CPU {157D1894-BAE7-45B2-9906-0445B38F3A97}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -106,7 +100,6 @@ Global {82BB433F-96BB-43D1-98E4-EEDE437D70AE} = {2904B75F-8F07-4C07-BABC-BC42533B3E75} {65578230-EF42-43A6-A943-624F2DF01E66} = {2904B75F-8F07-4C07-BABC-BC42533B3E75} {A5C32904-ECEC-492B-8217-8BFB5CC1443C} = {6CF85707-290E-4FA1-8444-25D29B6A6BA8} - {940AD1FA-E3D7-41FB-A832-2A84EF06C4DD} = {2904B75F-8F07-4C07-BABC-BC42533B3E75} {157D1894-BAE7-45B2-9906-0445B38F3A97} = {2904B75F-8F07-4C07-BABC-BC42533B3E75} {360438BD-AEDE-48AC-BE75-FBB6BF2F004D} = {2904B75F-8F07-4C07-BABC-BC42533B3E75} {71330321-DA6D-4199-89C4-FB36F92E77C2} = {2904B75F-8F07-4C07-BABC-BC42533B3E75} From 8b5617b0fb24041fac1204e7803b62090f218fe8 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 8 Aug 2023 14:34:32 -0400 Subject: [PATCH 04/51] Fix obsolete errors --- ...en_registering_additional_deserializers.cs | 1 - .../When_registering_custom_serializer.cs | 1 - ...registering_deserializers_with_settings.cs | 1 - .../DataBus/DataBusProperty.cs | 13 +++++------- .../MessageDeserializationException.cs | 8 -------- .../Reflection/ConcreteProxyCreator.cs | 2 +- .../MessageMapper/Reflection/MessageMapper.cs | 6 +++--- src/NServiceBus.Core/Sagas/SagaMetadata.cs | 4 ++-- .../Transports/Learning/AsyncFile.cs | 2 +- .../Unicast/Queuing/QueueNotFoundException.cs | 20 ------------------- 10 files changed, 12 insertions(+), 46 deletions(-) diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_registering_additional_deserializers.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_registering_additional_deserializers.cs index 4e1204ca98..3ac570b15b 100644 --- a/src/NServiceBus.AcceptanceTests/Serialization/When_registering_additional_deserializers.cs +++ b/src/NServiceBus.AcceptanceTests/Serialization/When_registering_additional_deserializers.cs @@ -84,7 +84,6 @@ public Task Handle(MyRequest request, IMessageHandlerContext context) } } - [Serializable] public class MyRequest : IMessage { } diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_registering_custom_serializer.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_registering_custom_serializer.cs index dd4abe0409..5ff97184b1 100644 --- a/src/NServiceBus.AcceptanceTests/Serialization/When_registering_custom_serializer.cs +++ b/src/NServiceBus.AcceptanceTests/Serialization/When_registering_custom_serializer.cs @@ -63,7 +63,6 @@ public Task Handle(MyRequest request, IMessageHandlerContext context) } } - [Serializable] public class MyRequest : IMessage { } diff --git a/src/NServiceBus.AcceptanceTests/Serialization/When_registering_deserializers_with_settings.cs b/src/NServiceBus.AcceptanceTests/Serialization/When_registering_deserializers_with_settings.cs index 5f8b4ecd9c..4098b4c229 100644 --- a/src/NServiceBus.AcceptanceTests/Serialization/When_registering_deserializers_with_settings.cs +++ b/src/NServiceBus.AcceptanceTests/Serialization/When_registering_deserializers_with_settings.cs @@ -76,7 +76,6 @@ public Task Handle(MyRequest request, IMessageHandlerContext context) } } - [Serializable] public class MyRequest : IMessage { } diff --git a/src/NServiceBus.Core/DataBus/DataBusProperty.cs b/src/NServiceBus.Core/DataBus/DataBusProperty.cs index 9a61886fea..bb351b957b 100644 --- a/src/NServiceBus.Core/DataBus/DataBusProperty.cs +++ b/src/NServiceBus.Core/DataBus/DataBusProperty.cs @@ -8,13 +8,12 @@ /// Default implementation for . /// /// Type of data to store in . - [Serializable] - public class DataBusProperty : IDataBusProperty, ISerializable where T : class + public class DataBusProperty : IDataBusProperty where T : class { /// /// initializes a with no value set. /// - public DataBusProperty() : this(null) + public DataBusProperty() { Type = typeof(T); } @@ -49,7 +48,7 @@ protected DataBusProperty(SerializationInfo info, StreamingContext context) /// /// The value. /// - public T Value => value; + public T Value { get; private set; } /// /// The property . @@ -72,8 +71,8 @@ protected DataBusProperty(SerializationInfo info, StreamingContext context) /// The value to set. public void SetValue(object valueToSet) { - value = valueToSet as T; - HasValue = value != null; + Value = valueToSet as T; + HasValue = Value != null; } /// @@ -98,7 +97,5 @@ public void GetObjectData(SerializationInfo info, StreamingContext context) info.AddValue("Key", Key); info.AddValue("HasValue", HasValue); } - - T value; } } \ No newline at end of file diff --git a/src/NServiceBus.Core/MessageDeserializationException.cs b/src/NServiceBus.Core/MessageDeserializationException.cs index 0dbd74a730..6879908fe1 100644 --- a/src/NServiceBus.Core/MessageDeserializationException.cs +++ b/src/NServiceBus.Core/MessageDeserializationException.cs @@ -9,7 +9,6 @@ /// Wraps the that occurs when the contents of an is deserialized /// to a list of s. /// - [Serializable] public class MessageDeserializationException : SerializationException { /// @@ -28,12 +27,5 @@ public MessageDeserializationException(string messageId, Exception innerExceptio : base("An error occurred while attempting to extract logical messages from incoming physical message " + messageId, innerException) { } - - /// - /// Initializes a new instance of . - /// - protected MessageDeserializationException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/NServiceBus.Core/MessageInterfaces/MessageMapper/Reflection/ConcreteProxyCreator.cs b/src/NServiceBus.Core/MessageInterfaces/MessageMapper/Reflection/ConcreteProxyCreator.cs index 86ca2f0cc3..cd40dab16b 100644 --- a/src/NServiceBus.Core/MessageInterfaces/MessageMapper/Reflection/ConcreteProxyCreator.cs +++ b/src/NServiceBus.Core/MessageInterfaces/MessageMapper/Reflection/ConcreteProxyCreator.cs @@ -22,7 +22,7 @@ public ConcreteProxyCreator() public Type CreateTypeFrom(Type type) { var typeBuilder = moduleBuilder.DefineType(type.FullName + SUFFIX, - TypeAttributes.Serializable | TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed, + TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed, typeof(object) ); diff --git a/src/NServiceBus.Core/MessageInterfaces/MessageMapper/Reflection/MessageMapper.cs b/src/NServiceBus.Core/MessageInterfaces/MessageMapper/Reflection/MessageMapper.cs index b5a73353bb..b83d7c2762 100644 --- a/src/NServiceBus.Core/MessageInterfaces/MessageMapper/Reflection/MessageMapper.cs +++ b/src/NServiceBus.Core/MessageInterfaces/MessageMapper/Reflection/MessageMapper.cs @@ -6,7 +6,7 @@ namespace NServiceBus.MessageInterfaces.MessageMapper.Reflection using System.Collections.Generic; using System.Linq; using System.Reflection; - using System.Runtime.Serialization; + using System.Runtime.CompilerServices; /// /// Uses reflection to map between interfaces and their generated concrete implementations. @@ -123,7 +123,7 @@ public object CreateInstance(Type t) if (t.IsInterface || t.IsAbstract) { var mapped = GetMappedTypeFor(t); - return FormatterServices.GetUninitializedObject(mapped); + return RuntimeHelpers.GetUninitializedObject(mapped); } if (typeToConstructor.TryGetValue(t.TypeHandle, out var ctor)) @@ -131,7 +131,7 @@ public object CreateInstance(Type t) return ((ConstructorInfo)MethodBase.GetMethodFromHandle(ctor, t.TypeHandle)).Invoke(null); } - return FormatterServices.GetUninitializedObject(t); + return RuntimeHelpers.GetUninitializedObject(t); } void InitType(Type t) diff --git a/src/NServiceBus.Core/Sagas/SagaMetadata.cs b/src/NServiceBus.Core/Sagas/SagaMetadata.cs index f48032f085..8aaa3da63a 100644 --- a/src/NServiceBus.Core/Sagas/SagaMetadata.cs +++ b/src/NServiceBus.Core/Sagas/SagaMetadata.cs @@ -5,7 +5,7 @@ namespace NServiceBus.Sagas using System.Linq; using System.Linq.Expressions; using System.Reflection; - using System.Runtime.Serialization; + using System.Runtime.CompilerServices; /// /// Contains metadata for known sagas. @@ -167,7 +167,7 @@ public static SagaMetadata Create(Type sagaType, IEnumerable availableType throw new Exception($"'{sagaType.Name}' saga type does not implement Saga"); } - var saga = (Saga)FormatterServices.GetUninitializedObject(sagaType); + var saga = (Saga)RuntimeHelpers.GetUninitializedObject(sagaType); var mapper = new SagaMapper(); saga.ConfigureHowToFindSaga(mapper); diff --git a/src/NServiceBus.Core/Transports/Learning/AsyncFile.cs b/src/NServiceBus.Core/Transports/Learning/AsyncFile.cs index 17e7810702..339dc47758 100644 --- a/src/NServiceBus.Core/Transports/Learning/AsyncFile.cs +++ b/src/NServiceBus.Core/Transports/Learning/AsyncFile.cs @@ -79,7 +79,7 @@ public static async Task ReadText(string filePath, CancellationToken can // This line makes the parameter "required". cancellationToken.ThrowIfCancellationRequested(); - var result = await stream.ReadToEndAsync().ConfigureAwait(false); + var result = await stream.ReadToEndAsync(cancellationToken).ConfigureAwait(false); return result; } diff --git a/src/NServiceBus.Core/Unicast/Queuing/QueueNotFoundException.cs b/src/NServiceBus.Core/Unicast/Queuing/QueueNotFoundException.cs index 59f7040b02..f203a3b270 100644 --- a/src/NServiceBus.Core/Unicast/Queuing/QueueNotFoundException.cs +++ b/src/NServiceBus.Core/Unicast/Queuing/QueueNotFoundException.cs @@ -1,12 +1,10 @@ namespace NServiceBus.Unicast.Queuing { using System; - using System.Runtime.Serialization; /// /// Thrown when the queue could not be found. /// - [Serializable] public class QueueNotFoundException : Exception { /// @@ -24,27 +22,9 @@ public QueueNotFoundException(string queue, string message, Exception inner) : b Queue = queue; } - /// - /// Initializes a new instance of . - /// - protected QueueNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) - { - Queue = info.GetString("Queue"); - } - /// /// The queue address. /// public string Queue { get; set; } - - /// - /// Gets the object data for serialization purposes. - /// - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - - info.AddValue("Queue", Queue); - } } } \ No newline at end of file From 8ca51ede7fe3ceed3a7f7ff5e3a539f6fe1c7107 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 8 Aug 2023 16:03:14 -0400 Subject: [PATCH 05/51] Fix error --- .../Support/SimulatedException.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/NServiceBus.AcceptanceTesting/Support/SimulatedException.cs b/src/NServiceBus.AcceptanceTesting/Support/SimulatedException.cs index 7bc3a75258..e18efdde3f 100644 --- a/src/NServiceBus.AcceptanceTesting/Support/SimulatedException.cs +++ b/src/NServiceBus.AcceptanceTesting/Support/SimulatedException.cs @@ -1,7 +1,6 @@ namespace NServiceBus.AcceptanceTesting { using System; - using System.Runtime.Serialization; /// /// A dummy exception to be used in acceptance tests for easier differentiation from real exceptions. @@ -19,9 +18,5 @@ public SimulatedException(string message) : base(message) public SimulatedException(string message, Exception innerException) : base(message, innerException) { } - - protected SimulatedException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } } } \ No newline at end of file From bbc0d99ff6c7bf55a62b84efa9306fc0180f7bdd Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 8 Aug 2023 17:28:15 -0400 Subject: [PATCH 06/51] Add workaround for testhost packaging error --- .../NServiceBus.AcceptanceTests.csproj | 6 ++++++ .../NServiceBus.PersistenceTests.csproj | 6 ++++++ .../NServiceBus.TransportTests.csproj | 8 +++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj b/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj index 11f66c3704..c7cadd2391 100644 --- a/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj +++ b/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj @@ -29,4 +29,10 @@ + + + + + + diff --git a/src/NServiceBus.PersistenceTests/NServiceBus.PersistenceTests.csproj b/src/NServiceBus.PersistenceTests/NServiceBus.PersistenceTests.csproj index 76a7733f96..61f84a03fe 100644 --- a/src/NServiceBus.PersistenceTests/NServiceBus.PersistenceTests.csproj +++ b/src/NServiceBus.PersistenceTests/NServiceBus.PersistenceTests.csproj @@ -32,4 +32,10 @@ + + + + + + \ No newline at end of file diff --git a/src/NServiceBus.TransportTests/NServiceBus.TransportTests.csproj b/src/NServiceBus.TransportTests/NServiceBus.TransportTests.csproj index 7664cfa227..04e2e5ae5e 100644 --- a/src/NServiceBus.TransportTests/NServiceBus.TransportTests.csproj +++ b/src/NServiceBus.TransportTests/NServiceBus.TransportTests.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -28,4 +28,10 @@ + + + + + + From 5925d224d8c938d7759c1ffaea72382cbeae9405 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Thu, 10 Aug 2023 10:58:57 -0400 Subject: [PATCH 07/51] Bump major version --- src/Custom.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Custom.Build.props b/src/Custom.Build.props index 3b8624d348..ee5ed47084 100644 --- a/src/Custom.Build.props +++ b/src/Custom.Build.props @@ -5,7 +5,7 @@ - 8.1 + 9.0 minor From 7315e77202aadf9dadda53078272a152a040226d Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Thu, 10 Aug 2023 11:10:18 -0400 Subject: [PATCH 08/51] Remove v8 obsoletes --- src/NServiceBus.Core/Notifications.cs | 6 - .../ServiceCollectionExtensions.cs | 3 +- .../ServiceProviderExtensions.cs | 19 +- .../Tracing/ActivityDecorator.cs | 1 - .../Pipeline/ConnectorContextExtensions.cs | 12 - .../Pipeline/PipelineCache.cs | 1 - .../Transports/ErrorContext.cs | 2 +- ...earningTransportConfigurationExtensions.cs | 26 - .../Transports/TransportExtensions.cs | 27 - src/NServiceBus.Core/obsoletes-v8.cs | 1725 ----------------- src/NServiceBus.Testing.Fakes/obsoletes-v8.cs | 13 - 11 files changed, 4 insertions(+), 1831 deletions(-) delete mode 100644 src/NServiceBus.Core/obsoletes-v8.cs delete mode 100644 src/NServiceBus.Testing.Fakes/obsoletes-v8.cs diff --git a/src/NServiceBus.Core/Notifications.cs b/src/NServiceBus.Core/Notifications.cs index 4377489fc1..1c278b3578 100644 --- a/src/NServiceBus.Core/Notifications.cs +++ b/src/NServiceBus.Core/Notifications.cs @@ -2,16 +2,10 @@ namespace NServiceBus { - using Faults; - /// /// Notifications. /// public class Notifications { - /// - /// Push-based error notifications. - /// - public ErrorsNotifications Errors { get; } = new ErrorsNotifications(); } } \ No newline at end of file diff --git a/src/NServiceBus.Core/ObjectBuilder/ServiceCollectionExtensions.cs b/src/NServiceBus.Core/ObjectBuilder/ServiceCollectionExtensions.cs index fba191aa17..df048eb218 100644 --- a/src/NServiceBus.Core/ObjectBuilder/ServiceCollectionExtensions.cs +++ b/src/NServiceBus.Core/ObjectBuilder/ServiceCollectionExtensions.cs @@ -3,10 +3,9 @@ using System; using System.Linq; using Microsoft.Extensions.DependencyInjection; - using ObjectBuilder; /// - /// Contains extension methods for that were formerly provided by . + /// Contains extension methods for that were formerly provided by IConfigureComponents />. /// [ObsoleteEx( Message = "Use methods on IServiceCollection instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information.", diff --git a/src/NServiceBus.Core/ObjectBuilder/ServiceProviderExtensions.cs b/src/NServiceBus.Core/ObjectBuilder/ServiceProviderExtensions.cs index c8544414cc..b0c1bbe909 100644 --- a/src/NServiceBus.Core/ObjectBuilder/ServiceProviderExtensions.cs +++ b/src/NServiceBus.Core/ObjectBuilder/ServiceProviderExtensions.cs @@ -1,13 +1,11 @@ -#pragma warning disable 1591 - -namespace NServiceBus.ObjectBuilder +namespace NServiceBus.ObjectBuilder { using System; using System.Collections.Generic; using Microsoft.Extensions.DependencyInjection; /// - /// Contains extension methods for that were formerly provided by . + /// Contains extension methods for that were formerly provided by IBuilder />. /// public static class ServiceProviderExtensions { @@ -65,18 +63,5 @@ public static class ServiceProviderExtensions TreatAsErrorFromVersion = "9", RemoveInVersion = "10")] public static IEnumerable BuildAll(this IServiceProvider serviceProvider, Type typeToBuild) => serviceProvider.GetServices(typeToBuild); - - [ObsoleteEx( - Message = "The Release method is not supported.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void Release(this IServiceProvider serviceProvider, object instance) => throw new NotImplementedException(); - - [ObsoleteEx( - Message = "The BuildAndDispatch method is not supported anymore. Use `IServiceProvider.GetService(typeToBuild)` and call the action on the returned service.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void BuildAndDispatch(this IServiceProvider serviceProvider, Type typeToBuild, Action action) => throw new NotImplementedException(); } } -#pragma warning restore 1591 diff --git a/src/NServiceBus.Core/OpenTelemetry/Tracing/ActivityDecorator.cs b/src/NServiceBus.Core/OpenTelemetry/Tracing/ActivityDecorator.cs index ee2d89190f..7f06a46c0d 100644 --- a/src/NServiceBus.Core/OpenTelemetry/Tracing/ActivityDecorator.cs +++ b/src/NServiceBus.Core/OpenTelemetry/Tracing/ActivityDecorator.cs @@ -54,7 +54,6 @@ public static void PromoteHeadersToTags(Activity activity, Dictionary - /// Creates a based on the current context. - /// - public static IRoutingContext CreateRoutingContext(this StageConnector stageConnector, OutgoingMessage outgoingMessage, RoutingStrategy routingStrategy, IForwardingContext sourceContext) - { - Guard.ThrowIfNull(outgoingMessage); - Guard.ThrowIfNull(routingStrategy); - Guard.ThrowIfNull(sourceContext); - - return new RoutingContext(outgoingMessage, routingStrategy, sourceContext); - } - /// /// Creates a based on the current context. /// diff --git a/src/NServiceBus.Core/Pipeline/PipelineCache.cs b/src/NServiceBus.Core/Pipeline/PipelineCache.cs index 92ff888840..1afba61767 100644 --- a/src/NServiceBus.Core/Pipeline/PipelineCache.cs +++ b/src/NServiceBus.Core/Pipeline/PipelineCache.cs @@ -15,7 +15,6 @@ public PipelineCache(IServiceProvider rootBuilder, PipelineModifications pipelin FromMainPipeline(rootBuilder); FromMainPipeline(rootBuilder); FromMainPipeline(rootBuilder); - FromMainPipeline(rootBuilder); } public IPipeline Pipeline() diff --git a/src/NServiceBus.Core/Transports/ErrorContext.cs b/src/NServiceBus.Core/Transports/ErrorContext.cs index 5696340fe9..83844765cb 100644 --- a/src/NServiceBus.Core/Transports/ErrorContext.cs +++ b/src/NServiceBus.Core/Transports/ErrorContext.cs @@ -19,7 +19,7 @@ public class ErrorContext /// Transaction (along with connection if applicable) used to receive the message. /// Number of failed immediate processing attempts. /// The receive address. - /// A which can be used to extend the current object. + /// A which can be used to extend the current object. public ErrorContext(Exception exception, Dictionary headers, string nativeMessageId, ReadOnlyMemory body, TransportTransaction transportTransaction, int immediateProcessingFailures, string receiveAddress, ContextBag context) { Guard.ThrowIfNull(exception); diff --git a/src/NServiceBus.Core/Transports/Learning/LearningTransportConfigurationExtensions.cs b/src/NServiceBus.Core/Transports/Learning/LearningTransportConfigurationExtensions.cs index 43b4e39312..c2063e3451 100644 --- a/src/NServiceBus.Core/Transports/Learning/LearningTransportConfigurationExtensions.cs +++ b/src/NServiceBus.Core/Transports/Learning/LearningTransportConfigurationExtensions.cs @@ -1,36 +1,10 @@ namespace NServiceBus { - using System; - /// /// Configuration options for the learning transport. /// public static class LearningTransportConfigurationExtensions { - /// - /// Configures the transport to use the given func as the connection string. - /// - [ObsoleteEx( - Message = "The learning transport does not support a connection string.", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public static TransportExtensions ConnectionString(this TransportExtensions transport, string connectionString) - { - throw new NotImplementedException(); - } - - /// - /// Configures the transport to use the given func as the connection string. - /// - [ObsoleteEx( - Message = "The learning transport does not support a connection string.", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public static TransportExtensions ConnectionString(this TransportExtensions transport, Func connectionString) - { - throw new NotImplementedException(); - } - /// /// Configures NServiceBus to use the given transport. /// diff --git a/src/NServiceBus.Core/Transports/TransportExtensions.cs b/src/NServiceBus.Core/Transports/TransportExtensions.cs index 80c8e4c1dc..bd75aaf64c 100644 --- a/src/NServiceBus.Core/Transports/TransportExtensions.cs +++ b/src/NServiceBus.Core/Transports/TransportExtensions.cs @@ -1,7 +1,5 @@ namespace NServiceBus { - using System; - using Settings; using Transport; /// @@ -30,18 +28,6 @@ public TransportExtensions(T transport, RoutingSettings routing) this.routing = routing; } - /// - /// Initializes a new instance of . - /// - [ObsoleteEx( - Message = "TransportExtensions does not use a SettingsHolder. Get an instance from endpointConfiguration.UseTransport(), or configure the transport directly via the TransportDefinition instance's properties.", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public TransportExtensions(SettingsHolder settings) - { - throw new NotImplementedException(); - } - /// /// Routing configuration. /// @@ -51,19 +37,6 @@ public TransportExtensions(SettingsHolder settings) RemoveInVersion = "10")] public RoutingSettings Routing() => routing; - /// - /// Configures the transport to use the connection string with the given name. - /// - [ObsoleteEx( - Message = "Loading named connection strings is no longer supported", - ReplacementTypeOrMember = "ConnectionString(connectionString)", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public TransportExtensions ConnectionStringName(string name) - { - throw new NotImplementedException(); - } - /// /// Configures the transport to use a specific transaction mode. /// diff --git a/src/NServiceBus.Core/obsoletes-v8.cs b/src/NServiceBus.Core/obsoletes-v8.cs deleted file mode 100644 index 77da39f6d7..0000000000 --- a/src/NServiceBus.Core/obsoletes-v8.cs +++ /dev/null @@ -1,1725 +0,0 @@ -#pragma warning disable 1591 -#pragma warning disable PS0013 // A Func used as a method parameter with a Task, ValueTask, or ValueTask return type argument should have at least one CancellationToken parameter type argument unless it has a parameter type argument implementing ICancellableContext -#pragma warning disable PS0018 // A task-returning method should have a CancellationToken parameter unless it has a parameter implementing ICancellableContext - -namespace NServiceBus.Gateway.Deduplication -{ - using System; - using System.Threading.Tasks; - using Extensibility; - - [ObsoleteEx( - Message = "Gateway persistence has been moved to the NServiceBus.Gateway dedicated package.", - RemoveInVersion = "9.0.0", - TreatAsErrorFromVersion = "8.0.0")] - public interface IDeduplicateMessages - { - Task DeduplicateMessage(string clientId, DateTime timeReceived, ContextBag context); - } -} - -namespace NServiceBus -{ - using System; - using Container; - using ObjectBuilder.Common; - using Settings; - - public partial class EndpointConfiguration - { - [ObsoleteEx( - Message = "Use the externally managed container mode to integrate with third party dependency injection containers.", - RemoveInVersion = "9.0", - TreatAsErrorFromVersion = "8.0")] - public void UseContainer(Action customizations = null) where T : ContainerDefinition, new() - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - Message = "Use the externally managed container mode to integrate with third party dependency injection containers.", - RemoveInVersion = "9.0", - TreatAsErrorFromVersion = "8.0")] - public void UseContainer(Type definitionType) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - Message = "Use the externally managed container mode to integrate with third party dependency injection containers.", - RemoveInVersion = "9.0", - TreatAsErrorFromVersion = "8.0")] - public void UseContainer(IContainer builder) - { - throw new NotImplementedException(); - } - } - - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8", - ReplacementTypeOrMember = "EndpointConfiguration.UseTransport(TransportDefinition)")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class UseTransportExtensions - { - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8", - ReplacementTypeOrMember = "EndpointConfiguration.UseTransport(TransportDefinition)")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static TransportExtensions UseTransport(this EndpointConfiguration endpointConfiguration, Type transportDefinitionType) - { - throw new NotImplementedException(); - } - } - - public static partial class Headers - { - [ObsoleteEx( - RemoveInVersion = "9.0", - TreatAsErrorFromVersion = "8.0", - Message = "Not intended for public usage.")] - public const string HeaderName = "Header"; - - [ObsoleteEx( - Message = "Non-durable delivery support has been moved to the transports that can support it. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public const string NonDurableMessage = "NServiceBus.NonDurableMessage"; - } - - [ObsoleteEx( - Message = "Gateway persistence has been moved to the NServiceBus.Gateway dedicated package.", - RemoveInVersion = "9.0.0", - TreatAsErrorFromVersion = "8.0.0")] - public static class InMemoryGatewayPersistenceConfigurationExtensions - { - [ObsoleteEx( - Message = "Gateway persistence has been moved to the NServiceBus.Gateway dedicated package.", - RemoveInVersion = "9.0.0", - TreatAsErrorFromVersion = "8.0.0")] - public static void GatewayDeduplicationCacheSize(this PersistenceExtensions persistenceExtensions, int maxSize) - { - throw new NotImplementedException(); - } - } - - [ObsoleteEx( - Message = "Transport infrastructure setup control is not based on the installer configuration.", - RemoveInVersion = "9.0.0", - TreatAsErrorFromVersion = "8.0.0")] - public static class ConfigureQueueCreation - { - [ObsoleteEx( - Message = "Transport infrastructure setup control is not based on the installer configuration.", - RemoveInVersion = "9.0.0", - TreatAsErrorFromVersion = "8.0.0")] - public static void DoNotCreateQueues(this EndpointConfiguration config) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - Message = "Transport infrastructure setup control is not based on the installer configuration.", - RemoveInVersion = "9.0.0", - TreatAsErrorFromVersion = "8.0.0")] - public static bool CreateQueues(this ReadOnlySettings settings) - { - throw new NotImplementedException(); - } - } -} - -namespace NServiceBus.Container -{ - [ObsoleteEx( - Message = "The NServiceBus dependency injection container API has been deprecated. Use the externally managed container mode to use custom containers.", - RemoveInVersion = "9.0.0", - TreatAsErrorFromVersion = "8.0.0")] - public abstract class ContainerDefinition - { - } - - [ObsoleteEx( - Message = "The NServiceBus dependency injection container API has been deprecated. Use the externally managed container mode to use custom containers.", - RemoveInVersion = "9.0.0", - TreatAsErrorFromVersion = "8.0.0")] - public class ContainerCustomizations - { - ContainerCustomizations() - { - // private ctor - } - } -} - -namespace NServiceBus.ObjectBuilder -{ - using System; - using System.Collections.Generic; - using Microsoft.Extensions.DependencyInjection; - - [ObsoleteEx( - ReplacementTypeOrMember = nameof(IServiceProvider), - TreatAsErrorFromVersion = "8.0.0", - RemoveInVersion = "9.0.0")] - public interface IBuilder : IDisposable - { - [ObsoleteEx(Message = "The Build method is not supported anymore.", ReplacementTypeOrMember = nameof(IServiceProvider.GetService), TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - object Build(Type typeToBuild); - - [ObsoleteEx(Message = "The CreateChildBuilder method is not supported anymore.", ReplacementTypeOrMember = nameof(ServiceProviderServiceExtensions.CreateScope), TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - IBuilder CreateChildBuilder(); - - [ObsoleteEx(Message = "The Build method is not supported anymore.", ReplacementTypeOrMember = nameof(ServiceProviderServiceExtensions.GetService), TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - T Build(); - - [ObsoleteEx(Message = "The BuildAll method is not supported anymore.", ReplacementTypeOrMember = nameof(ServiceProviderServiceExtensions.GetServices), TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - IEnumerable BuildAll(); - - [ObsoleteEx(Message = "The BuildAll method is not supported anymore.", ReplacementTypeOrMember = nameof(ServiceProviderServiceExtensions.GetServices), TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - IEnumerable BuildAll(Type typeToBuild); - - [ObsoleteEx(Message = "The Release method is not supported anymore.", TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - void Release(object instance); - - [ObsoleteEx(Message = "The BuildAndDispatch method is not supported anymore.", TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - void BuildAndDispatch(Type typeToBuild, Action action); - } - - [ObsoleteEx( - ReplacementTypeOrMember = nameof(IServiceCollection), - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public interface IConfigureComponents - { - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceCollection.ConfigureComponent", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - void ConfigureComponent(Type concreteComponent, DependencyLifecycle dependencyLifecycle); - - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceCollection.ConfigureComponent", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - void ConfigureComponent(DependencyLifecycle dependencyLifecycle); - - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceCollection.ConfigureComponent", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - void ConfigureComponent(Func componentFactory, DependencyLifecycle dependencyLifecycle); - - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceCollection.ConfigureComponent", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - void ConfigureComponent(Func componentFactory, DependencyLifecycle dependencyLifecycle); - - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceCollection.AddSingleton", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - void RegisterSingleton(Type lookupType, object instance); - - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceCollection.AddSingleton", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - void RegisterSingleton(T instance); - - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceCollection.HasComponent", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - bool HasComponent(); - - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceCollection.HasComponent", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - bool HasComponent(Type componentType); - } -} - -namespace NServiceBus.ObjectBuilder.Common -{ - using System; - - [ObsoleteEx( - Message = "The NServiceBus dependency injection container API has been deprecated. Use the externally managed container mode to use custom containers.", - RemoveInVersion = "9.0.0", - TreatAsErrorFromVersion = "8.0.0")] - public interface IContainer : IDisposable - { - } -} - -namespace NServiceBus.Features -{ - using System; - - [ObsoleteEx( - Message = "Gateway persistence has been moved to the NServiceBus.Gateway dedicated package.", - RemoveInVersion = "9.0.0", - TreatAsErrorFromVersion = "8.0.0")] - public class InMemoryGatewayPersistence - { - internal InMemoryGatewayPersistence() => throw new NotImplementedException(); - } -} - -namespace NServiceBus -{ - using System; - - public abstract partial class StorageType - { - [ObsoleteEx( - Message = "Gateway persistence has been moved to the NServiceBus.Gateway dedicated package.", - RemoveInVersion = "9.0.0", - TreatAsErrorFromVersion = "8.0.0")] - public sealed class GatewayDeduplication - { - internal GatewayDeduplication() => throw new NotImplementedException(); - } - } -} - -namespace NServiceBus.Faults -{ - using System; - - public class ErrorsNotifications - { -#pragma warning disable 67 - - [ObsoleteEx( - Message = "The .NET event based error notifications will be deprecated in favor of Task-based callbacks. Use endpointConfiguration.Recoverability().Failed(settings => settings.OnMessageSentToErrorQueue(callback)) instead.", - RemoveInVersion = "9.0", - TreatAsErrorFromVersion = "8.0")] - public event EventHandler MessageSentToErrorQueue; - - [ObsoleteEx( - Message = "The .NET event based error notifications will be deprecated in favor of Task-based callbacks. Use endpointConfiguration.Recoverability().Immediate(settings => settings.OnMessageBeingRetried(callback)) instead.", - RemoveInVersion = "9.0", - TreatAsErrorFromVersion = "8.0")] - public event EventHandler MessageHasFailedAnImmediateRetryAttempt; - - [ObsoleteEx( - Message = "The .NET event based error notifications will be deprecated in favor of Task-based callbacks. Use endpointConfiguration.Recoverability().Delayed(settings => settings.OnMessageBeingRetried(callback)) instead.", - RemoveInVersion = "9.0", - TreatAsErrorFromVersion = "8.0")] - public event EventHandler MessageHasBeenSentToDelayedRetries; - -#pragma warning restore 67 - } -} - -namespace NServiceBus.Settings -{ - using System; - - public partial class SettingsHolder - { - [ObsoleteEx( - ReplacementTypeOrMember = "Set(T value)", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public void Set(object value) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - ReplacementTypeOrMember = "SetDefault(T value)", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public void SetDefault(object value) - { - throw new NotImplementedException(); - } - } -} - -namespace NServiceBus -{ - using System; - using Settings; - - // NOTE: This class no longer is a base class of TransportExtensions, so all these items can be obsolete without affecting anything - - [ObsoleteEx( - Message = "Configure the transport via the TransportDefinition instance's properties", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public class TransportExtensions - { - [ObsoleteEx( - Message = "Configure the transport via the TransportDefinition instance's properties", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public TransportExtensions(SettingsHolder settings) - { - } - - [ObsoleteEx( - Message = "The ability to used named connection strings has been removed. Instead, load the connection string in your code and pass the value to TransportExtensions.ConnectionString(connectionString)", - ReplacementTypeOrMember = "ConnectionString(connectionString)", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public TransportExtensions ConnectionStringName(string name) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - Message = "Setting connection string at the endpoint level is no longer supported. Transport specific configuration options should be used instead", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public TransportExtensions ConnectionString(string connectionString) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - Message = "Setting connection string at the endpoint level is no longer supported. Transport specific configuration options should be used instead", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public TransportExtensions ConnectionString(Func connectionString) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0", - ReplacementTypeOrMember = "TransportDefinition.TransportTransactionMode")] - public TransportExtensions Transactions(TransportTransactionMode transportTransactionMode) - { - throw new NotImplementedException(); - } - } -} - -namespace NServiceBus -{ - using System; - - [ObsoleteEx(TreatAsErrorFromVersion = "8", RemoveInVersion = "9")] - public static class ConfigureForwarding - { - [ObsoleteEx( - Message = "Message forwarding is no longer supported natively by NServiceBus. For auditing messages, use endpointConfiguration.AuditProcessedMessagesTo(address). If true message forwarding capabilities are needed, use a custom pipeline behavior, an example of which can be found in the documentation.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void ForwardReceivedMessagesTo(this EndpointConfiguration config, string address) - { - throw new NotImplementedException(); - } - } -} - -namespace NServiceBus.Features -{ - using System; - - [ObsoleteEx( - Message = "Message forwarding is no longer supported, but can be implemented as a custom pipeline behavior.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public class ForwardReceivedMessages - { - internal ForwardReceivedMessages() => throw new NotImplementedException(); - } -} - -namespace NServiceBus.Pipeline -{ - using System; - - [ObsoleteEx( - Message = "Message forwarding is no longer supported, but can be implemented as a custom pipeline behavior.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public interface IForwardingContext : IBehaviorContext - { - } - - public partial class PipelineSettings - { - [ObsoleteEx( - Message = "Removing behaviors from the pipeline is discouraged, to disable a behavior replace the behavior by an empty one. Documentation: https://docs.particular.net/nservicebus/pipeline/manipulate-with-behaviors ", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public void Remove(string stepId) - { - throw new NotImplementedException(); - } - } -} - -namespace NServiceBus -{ - using System; - using Pipeline; - using Transport; - - public static partial class ConnectorContextExtensions - { - [ObsoleteEx( - Message = "Message forwarding is no longer supported, but can be implemented as a custom pipeline behavior.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static IForwardingContext CreateForwardingContext(this ForkConnector forwardingContext, OutgoingMessage message, string forwardingAddress, IIncomingPhysicalMessageContext sourceContext) - { - throw new NotImplementedException(); - } - } -} - -namespace NServiceBus.Unicast -{ - using System; - - [ObsoleteEx( - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static class BuilderExtensions - { - [ObsoleteEx( - Message = "Replace usages of ForEach with a foreach loop", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void ForEach(this IServiceProvider builder, Action action) - { - throw new NotImplementedException(); - } - } -} - -namespace NServiceBus -{ - using System; - - [ObsoleteEx( - Message = "The built-in scheduler is no longer supported, see our upgrade guide for details on how to migrate to plain .NET Timers", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public class ScheduledTask - { - internal ScheduledTask() => throw new NotImplementedException(); - } -} - -namespace NServiceBus -{ - using System; - using System.Threading.Tasks; - - - [ObsoleteEx( - Message = "The built-in scheduler is no longer supported, see our upgrade guide for details on how to migrate to plain .NET Timers", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static class ScheduleExtensions - { - public static Task ScheduleEvery(this IMessageSession session, TimeSpan timeSpan, Func task) - { - throw new NotImplementedException(); - } - - public static Task ScheduleEvery(this IMessageSession session, TimeSpan timeSpan, string name, Func task) - { - throw new NotImplementedException(); - - } - } -} - -namespace NServiceBus.Features -{ - [ObsoleteEx( - Message = "The built-in scheduler is no longer supported, see our upgrade guide for details on how to migrate to plain .NET Timers", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public class Scheduler - { - } -} - -namespace NServiceBus -{ - using System; - using Outbox; - using Persistence; - - [ObsoleteEx(Message = "The InMemoryPersistence has been moved to a dedicated Nuget Package called NServiceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence", TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - public class InMemoryPersistence : PersistenceDefinition - { - } - - [ObsoleteEx(Message = "The InMemoryPersistence has been moved to a dedicated Nuget Package called NServiceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence", TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - public class InMemoryTimeoutPersistence - { - } - - [ObsoleteEx(Message = "The InMemoryPersistence has been moved to a dedicated Nuget Package called NServiceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence", TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - public class InMemorySubscriptionPersistence - { - } - - [ObsoleteEx(Message = "The InMemoryPersistence has been moved to a dedicated Nuget Package called NServiceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence", TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - public class InMemorySagaPersistence - { - } - - [ObsoleteEx(Message = "The InMemoryPersistence has been moved to a dedicated Nuget Package called NServiceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence", TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - public static class InMemoryOutboxSettingsExtensions - { - [ObsoleteEx(Message = "The InMemoryPersistence has been moved to a dedicated Nuget Package called NServiceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence", TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - public static OutboxSettings TimeToKeepDeduplicationData(this OutboxSettings settings, TimeSpan time) - { - throw new NotSupportedException(); - } - } - - [ObsoleteEx(Message = "The InMemoryPersistence has been moved to a dedicated Nuget Package called NServiceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence", TreatAsErrorFromVersion = "8.0.0", RemoveInVersion = "9.0.0")] - public class InMemoryOutboxPersistence - { - } -} - -namespace NServiceBus -{ - [ObsoleteEx( - Message = "Non-durable delivery support has been moved to the transports that can support it. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public class NonDurableDelivery - { - } -} - -namespace NServiceBus -{ - using System; - using Settings; - - [ObsoleteEx( - Message = "Non-durable delivery support has been moved to the transports that can support it. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static class DurableMessagesConfig - { - [ObsoleteEx( - Message = "Non-durable delivery support has been moved to the transports that can support it. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void EnableDurableMessages(this EndpointConfiguration config) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - Message = "Non-durable delivery support has been moved to the transports that can support it. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void DisableDurableMessages(this EndpointConfiguration config) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - Message = "Non-durable delivery support has been moved to the transports that can support it. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static bool DurableMessagesEnabled(this ReadOnlySettings settings) - { - throw new NotImplementedException(); - } - } -} - -namespace NServiceBus -{ - using System; - - [ObsoleteEx( - Message = "Non-durable delivery support has been moved to the transports that can support it. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static class DurableMessagesConventionExtensions - { - [ObsoleteEx( - Message = "Non-durable delivery support has been moved to the transports that can support it. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static ConventionsBuilder DefiningExpressMessagesAs(this ConventionsBuilder builder, Func definesExpressMessageType) - { - throw new NotImplementedException(); - } - } -} - -namespace NServiceBus -{ - using System; - - [ObsoleteEx( - Message = "Non-durable delivery support has been moved to the transports that can support it. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)] - public sealed class ExpressAttribute : Attribute - { - } -} - -namespace NServiceBus -{ - using System; - - [ObsoleteEx( - Message = "Public APIs no longer use DateTime but DateTimeOffset. See the upgrade guide for more details.", - ReplacementTypeOrMember = "NServiceBus.DateTimeOffsetExtensions", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static class DateTimeExtensions - { - [ObsoleteEx( - Message = "Public APIs no longer use DateTime but DateTimeOffset. See the upgrade guide for more details.", - ReplacementTypeOrMember = "NServiceBus.DateTimeOffsetHelper.ToWireFormattedString", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static string ToWireFormattedString(DateTime dateTime) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - Message = "Public APIs no longer use DateTime but DateTimeOffset. See the upgrade guide for more details.", - ReplacementTypeOrMember = "NServiceBus.DateTimeOffsetHelper.ToDateTimeOffset", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static DateTime ToUtcDateTime(string wireFormattedString) - { - throw new NotImplementedException(); - } - } -} - -namespace NServiceBus -{ - using System; - - public abstract partial class StorageType - { - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public sealed class Timeouts - { - internal Timeouts() - { - throw new NotImplementedException(); - } - } - } - - public class TimeoutManagerConfiguration - { - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - internal TimeoutManagerConfiguration() => throw new NotImplementedException(); - } - - [ObsoleteEx( - Message = "The timeout manager has been removed. See the upgrade guide for more details", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static class TimeoutManagerConfigurationExtensions - { - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static TimeoutManagerConfiguration TimeoutManager(this EndpointConfiguration endpointConfiguration) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void LimitMessageProcessingConcurrencyTo(this TimeoutManagerConfiguration timeoutManagerConfiguration, int maxConcurrency) - { - throw new NotImplementedException(); - } - } - - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static class ConfigurationTimeoutExtensions - { - [ObsoleteEx( - Message = "The timeout manager has been removed. See the upgrade guide for more details", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void TimeToWaitBeforeTriggeringCriticalErrorOnTimeoutOutages(this EndpointConfiguration config, TimeSpan timeToWait) - { - throw new NotImplementedException(); - } - } - -} - -namespace NServiceBus.Features -{ - using System; - - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public class TimeoutManager - { - internal TimeoutManager() => throw new NotImplementedException(); - } -} - -namespace NServiceBus.Timeout.Core -{ - using System; - using System.Collections.Generic; - using System.Threading.Tasks; - using Extensibility; - - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public interface IPersistTimeouts - { - Task Add(TimeoutData timeout, ContextBag context); - - Task TryRemove(string timeoutId, ContextBag context); - - Task Peek(string timeoutId, ContextBag context); - - Task RemoveTimeoutBy(Guid sagaId, ContextBag context); - } - - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public interface IQueryTimeouts - { - Task GetNextChunk(DateTime startSlice); - } - - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public class TimeoutData - { - public string Id => throw new NotImplementedException(); - - public string Destination => throw new NotImplementedException(); - - public Guid SagaId => throw new NotImplementedException(); - - public byte[] State => throw new NotImplementedException(); - - public DateTime Time => throw new NotImplementedException(); - - public string OwningTimeoutManager => throw new NotImplementedException(); - - public Dictionary Headers => throw new NotImplementedException(); - } - - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public class TimeoutsChunk - { - public TimeoutsChunk(Timeout[] dueTimeouts, DateTime nextTimeToQuery) - { - throw new NotImplementedException(); - } - - public Timeout[] DueTimeouts => throw new NotImplementedException(); - - public DateTime NextTimeToQuery => throw new NotImplementedException(); - - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public struct Timeout - { - public Timeout(string id, DateTime dueTime) - { - throw new NotImplementedException(); - } - - public string Id => throw new NotImplementedException(); - - public DateTime DueTime => throw new NotImplementedException(); - } - } -} - -namespace NServiceBus.DelayedDelivery -{ - using System; - - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static class ExternalTimeoutManagerConfigurationExtensions - { - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void UseExternalTimeoutManager(this EndpointConfiguration endpointConfiguration, string externalTimeoutManagerAddress) - { - throw new NotImplementedException(); - } - } -} - -namespace NServiceBus.Transport -{ - using System.Threading.Tasks; - using Pipeline; - - [ObsoleteEx( - Message = "The timeout manager has been removed in favor of native delayed delivery support provided by transports. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public interface ICancelDeferredMessages - { - Task CancelDeferredMessages(string messageKey, IBehaviorContext context); - } -} - -namespace NServiceBus.Transport -{ - using System.Threading.Tasks; - using Extensibility; - - [ObsoleteEx( - Message = "The IDispatchMessages interface has been removed. See the upgrade guide for more details.", - ReplacementTypeOrMember = nameof(IMessageDispatcher), - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public interface IDispatchMessages - { - /// - /// Dispatches the given operations to the transport. - /// - Task Dispatch(TransportOperations outgoingMessages, TransportTransaction transaction, ContextBag context); - } -} - -namespace NServiceBus.Transport -{ - using System.Threading.Tasks; - - [ObsoleteEx( - Message = "Queue creation is done by TransportDefinition.Initialize", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public interface ICreateQueues - { - [ObsoleteEx( - Message = "Queue creation is done by TransportDefinition.Initialize", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity); - } -} - -namespace NServiceBus.Transport -{ - [ObsoleteEx( - ReplacementTypeOrMember = nameof(ReceiveSettings), - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public class PushSettings - { - } -} - -namespace NServiceBus.Transport -{ - using System; - using System.Threading.Tasks; - - [ObsoleteEx( - ReplacementTypeOrMember = nameof(IMessageReceiver), - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public interface IPushMessages - { - [ObsoleteEx( - ReplacementTypeOrMember = "IMessageReceiver.Initialize", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - Task Init(Func onMessage, - Func> onError, - CriticalError criticalError, - PushSettings settings); - - [ObsoleteEx( - ReplacementTypeOrMember = "IMessageReceiver.StartReceive", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - void Start(PushRuntimeSettings limitations); - - [ObsoleteEx( - ReplacementTypeOrMember = "IMessageReceiver.StopReceive", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - Task Stop(); - } -} - -namespace NServiceBus.Transport -{ - using System; - - [ObsoleteEx( - Message = "This type is no longer necessary when implementing a transport", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public class OutboundRoutingPolicy - { - [ObsoleteEx( - Message = "This type is no longer necessary when implementing a transport", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public OutboundRoutingPolicy(OutboundRoutingType sends, OutboundRoutingType publishes, OutboundRoutingType replies) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - Message = "This property is no longer necessary when implementing a transport", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public OutboundRoutingType Sends => throw new NotImplementedException(); - - [ObsoleteEx( - ReplacementTypeOrMember = "TransportDefinition.SupportsPublishSubscribe", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public OutboundRoutingType Publishes => throw new NotImplementedException(); - - [ObsoleteEx( - Message = "This property is no longer necessary when implementing a transport", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public OutboundRoutingType Replies => throw new NotImplementedException(); - } - - [ObsoleteEx( - Message = "This enum is no longer necessary when implementing a transport", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public enum OutboundRoutingType - { - [ObsoleteEx( - Message = "This enum is no longer necessary when implementing a transport", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - Unicast, - [ObsoleteEx( - Message = "This enum is no longer necessary when implementing a transport", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - Multicast - } -} - -namespace NServiceBus.Transport -{ - using System; - using System.Threading.Tasks; - - [ObsoleteEx( - Message = "This type is no longer necessary when implementing a transport", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public class TransportSubscriptionInfrastructure - { - [ObsoleteEx( - Message = "This type is no longer necessary when implementing a transport", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public TransportSubscriptionInfrastructure(Func subscriptionManagerFactory) - { - throw new NotImplementedException(); - } - } - - [ObsoleteEx( - Message = "This type is no longer necessary when implementing a transport", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public class TransportSendInfrastructure - { - [ObsoleteEx( - Message = "This type is no longer necessary when implementing a transport", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public TransportSendInfrastructure(Func dispatcherFactory, - Func> preStartupCheck) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - ReplacementTypeOrMember = "TransportInfrastructure.Dispatcher", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public Func DispatcherFactory => throw new NotImplementedException(); - - [ObsoleteEx( - Message = "Pre-startup checks have been removed", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public Func> PreStartupCheck => throw new NotImplementedException(); - } -} - -namespace NServiceBus.Transport -{ - using System; - using System.Threading.Tasks; - using Extensibility; - - [ObsoleteEx( - ReplacementTypeOrMember = nameof(ISubscriptionManager), - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public interface IManageSubscriptions - { - [ObsoleteEx( - ReplacementTypeOrMember = "ISubscriptionManager.SubscribeAll", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - Task Subscribe(Type eventType, ContextBag context); - - [ObsoleteEx( - ReplacementTypeOrMember = "ISubscriptionManager.Unsubscribe", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - Task Unsubscribe(Type eventType, ContextBag context); - } -} - -namespace NServiceBus -{ - using System; - using System.Collections.Generic; - using NServiceBus.Transport; - using Routing; - - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8", - ReplacementTypeOrMember = nameof(QueueAddress))] - public struct LogicalAddress - { - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8", - Message = "Directly construct a QueueAddress.")] - public static LogicalAddress CreateRemoteAddress(EndpointInstance endpointInstance) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8", - Message = "Directly construct a QueueAddress with the queueName as the BaseAddress.")] - public static LogicalAddress CreateLocalAddress(string queueName, IReadOnlyDictionary properties) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8", - Message = "Directly construct a QueueAddress with the qualifier.")] - public LogicalAddress CreateQualifiedAddress(string qualifier) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8", - Message = "Directly construct a QueueAddress with the discriminator.")] - public LogicalAddress CreateIndividualizedAddress(string discriminator) - { - throw new NotImplementedException(); - } - - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8", - ReplacementTypeOrMember = "QueueAddress.Qualifier")] - public string Qualifier => throw new NotImplementedException(); - - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8", - ReplacementTypeOrMember = nameof(QueueAddress))] - public EndpointInstance EndpointInstance => throw new NotImplementedException(); - } -} - -namespace NServiceBus -{ - using System; - using Settings; - - public static partial class SettingsExtensions - { - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8", - ReplacementTypeOrMember = "SettingsExtensions.EndpointQueueName")] - public static LogicalAddress LogicalAddress(this ReadOnlySettings settings) - { - throw new NotImplementedException(); - } - } -} - -namespace NServiceBus.Transport -{ - using System; - using System.Collections.Generic; - - public partial class QueueBindings - { - [ObsoleteEx( - Message = "Receiving addresses are automatically registered.", - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public IReadOnlyCollection ReceivingAddresses => throw new NotImplementedException(); - - [ObsoleteEx( - Message = "Receiving addresses are automatically registered.", - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public void BindReceiving(string address) => throw new NotImplementedException(); - } -} - -namespace NServiceBus.DeliveryConstraints -{ - using System; - using NServiceBus.Transport; - - [ObsoleteEx( - ReplacementTypeOrMember = nameof(DispatchProperties), - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public abstract class DeliveryConstraint - { - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - protected DeliveryConstraint() { } - } - - public static class DeliveryConstraintContextExtensions - { - [ObsoleteEx( - ReplacementTypeOrMember = nameof(DispatchProperties), - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public static void AddDeliveryConstraint(this Extensibility.ContextBag context, DeliveryConstraint constraint) => throw new NotImplementedException(); - - [ObsoleteEx( - ReplacementTypeOrMember = nameof(DispatchProperties), - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public static System.Collections.Generic.List GetDeliveryConstraints(this Extensibility.ContextBag context) => throw new NotImplementedException(); - - [ObsoleteEx( - ReplacementTypeOrMember = nameof(DispatchProperties), - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public static void RemoveDeliveryConstraint(this Extensibility.ContextBag context, DeliveryConstraint constraint) => throw new NotImplementedException(); - - [ObsoleteEx( - ReplacementTypeOrMember = nameof(DispatchProperties), - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public static bool TryGetDeliveryConstraint(this Extensibility.ContextBag context, out T constraint) - where T : DeliveryConstraint => throw new NotImplementedException(); - - [ObsoleteEx( - ReplacementTypeOrMember = nameof(DispatchProperties), - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public static bool TryRemoveDeliveryConstraint(this Extensibility.ContextBag context, out T constraint) - where T : DeliveryConstraint => throw new NotImplementedException(); - } -} - -namespace NServiceBus.Transport -{ - using System; - using Settings; - - public static class LogicalAddressExtensions - { - [ObsoleteEx( - ReplacementTypeOrMember = "TransportDefinition.ToTransportAddress", - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public static string GetTransportAddress(this ReadOnlySettings settings, LogicalAddress logicalAddress) => throw new NotImplementedException(); - } -} - -namespace NServiceBus.Pipeline -{ - using System; - using System.ComponentModel; - - /// - /// Provides context for subscription requests. - /// - public partial interface ISubscribeContext - { - /// - /// The type of the event. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - [ObsoleteEx( - ReplacementTypeOrMember = nameof(EventTypes), - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - Type EventType { get; } - } -} - -namespace NServiceBus.Transport -{ - using System; - - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public class StartupCheckResult - { - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public bool Succeeded => throw new NotImplementedException(); - - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public string ErrorMessage => throw new NotImplementedException(); - - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public static StartupCheckResult Failed(string errorMessage) => throw new NotImplementedException(); - - [ObsoleteEx( - RemoveInVersion = "9", - TreatAsErrorFromVersion = "8")] - public static readonly StartupCheckResult Success = new StartupCheckResult(); - } -} - -namespace NServiceBus -{ - using System; - - /// - /// Configuration extensions for routing. - /// - [PreObsolete(Note = "Current obsolete points to TransportExtensions replacement, in the future Replacement member should be EndpointConfiguration.UseTransport")] - public static class RoutingSettingsExtensions - { - [ObsoleteEx( - ReplacementTypeOrMember = "TransportExtensions.Routing()", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static RoutingSettings Routing(this TransportExtensions config) => throw new NotImplementedException(); - } -} - -namespace NServiceBus -{ - using System; - using Pipeline; - using Routing; - using Transport; - - /// - /// Provides extensions for configuring message driven subscriptions. - /// - public static partial class MessageDrivenSubscriptionsConfigExtensions - { - [ObsoleteEx( - ReplacementTypeOrMember = "RoutingSettings.SubscriptionAuthorizer", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void SubscriptionAuthorizer(this TransportExtensions transportExtensions, - Func authorizer) - where T : TransportDefinition, IMessageDrivenSubscriptionTransport - => throw new NotImplementedException(); - [ObsoleteEx( - ReplacementTypeOrMember = "RoutingSettings.DisablePublishing", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void DisablePublishing(this TransportExtensions transportExtensions) - where T : TransportDefinition, IMessageDrivenSubscriptionTransport - => throw new NotImplementedException(); - - } -} - -namespace NServiceBus.Pipeline -{ - public partial interface ITransportReceiveContext - { - /// - /// Allows the pipeline to flag that it has been aborted and the receive operation should be rolled back. - /// - [ObsoleteEx( - Message = "The AbortReceiveOperation method is no longer supported. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - void AbortReceiveOperation(); - } -} - -namespace NServiceBus -{ - using System; - - partial class TransportReceiveContext - { - [ObsoleteEx( - Message = "The AbortReceiveOperation method is no longer supported. See the upgrade guide for more details.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public void AbortReceiveOperation() => throw new NotImplementedException(); - } -} - -namespace NServiceBus.Transport -{ - using System; - using System.Collections.Generic; - using System.Threading; - using NServiceBus.Extensibility; - - public partial class MessageContext - { - [ObsoleteEx( - ReplacementTypeOrMember = "MessageContext(string, Dictionary, ReadonlyMemory, TransportTransaction, string, ContextBag)", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public MessageContext(string messageId, Dictionary headers, byte[] body, TransportTransaction transportTransaction, CancellationTokenSource receiveCancellationTokenSource, ContextBag context) => throw new NotImplementedException(); - - [ObsoleteEx(TreatAsErrorFromVersion = "8", RemoveInVersion = "9")] - public CancellationTokenSource ReceiveCancellationTokenSource => throw new NotImplementedException(); - - [ObsoleteEx(ReplacementTypeOrMember = nameof(NativeMessageId), TreatAsErrorFromVersion = "8", RemoveInVersion = "9")] - public string MessageId { get; } - } -} - -namespace NServiceBus -{ - using System; - using System.Threading.Tasks; - - public partial class CriticalError - { - [ObsoleteEx( - Message = "Use the overload that accepts a delegate with a cancellation token.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public CriticalError(Func onCriticalErrorAction) => throw new NotImplementedException(); - } -} - -namespace NServiceBus -{ - using System; - using System.Threading.Tasks; - - public partial class CriticalErrorContext : ICriticalErrorContext - { - [ObsoleteEx( - Message = "Use the overload that accepts a delegate with a cancellation token.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public CriticalErrorContext(Func stop, string error, Exception exception) => throw new NotImplementedException(); - } -} - -namespace NServiceBus -{ - using System; - using System.Threading.Tasks; - using Configuration.AdvancedExtensibility; - using Faults; - - public partial class DelayedRetriesSettings : ExposeSettings - { - [ObsoleteEx( - Message = "Use the overload that accepts a delegate with a cancellation token.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public DelayedRetriesSettings OnMessageBeingRetried(Func notificationCallback) => throw new NotImplementedException(); - } -} - -namespace NServiceBus -{ - using System; - using System.Threading.Tasks; - - public static partial class DiagnosticSettingsExtensions - { - [ObsoleteEx( - Message = "Use the overload that accepts a delegate with a cancellation token.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void CustomDiagnosticsWriter(this EndpointConfiguration config, Func customDiagnosticsWriter) => throw new NotImplementedException(); - } -} - -namespace NServiceBus -{ - using System; - using System.Threading.Tasks; - using Configuration.AdvancedExtensibility; - using Faults; - - public partial class ImmediateRetriesSettings : ExposeSettings - { - [ObsoleteEx( - Message = "Use the overload that accepts a delegate with a cancellation token.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public ImmediateRetriesSettings OnMessageBeingRetried(Func notificationCallback) => throw new NotImplementedException(); - } -} - -namespace NServiceBus -{ - using System; - using System.Threading.Tasks; - using Pipeline; - - public static partial class ReceivePipelineConfigExtensions - { - [ObsoleteEx( - Message = "Use the overload that accepts a delegate with a cancellation token.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void OnReceivePipelineCompleted(this PipelineSettings pipelineSettings, Func subscription) => throw new NotImplementedException(); - } -} - -namespace NServiceBus -{ - using System; - using System.Threading.Tasks; - using Configuration.AdvancedExtensibility; - using Faults; - - public partial class RetryFailedSettings : ExposeSettings - { - [ObsoleteEx( - Message = "Use the overload that accepts a delegate with a cancellation token.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public RetryFailedSettings OnMessageSentToErrorQueue(Func notificationCallback) => throw new NotImplementedException(); - } -} - -namespace NServiceBus.Transport -{ - using System; - using Settings; - - public partial class HostSettings - { - [ObsoleteEx( - Message = "Use the overload that accepts a delegate with a cancellation token.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public HostSettings(string name, string hostDisplayName, StartupDiagnosticEntries startupDiagnostic, Action criticalErrorAction, bool setupInfrastructure, ReadOnlySettings coreSettings = null) => throw new NotImplementedException(); - } -} - -namespace NServiceBus -{ - using System; - using System.Threading.Tasks; - - public static partial class ConfigureCriticalErrorAction - { - [ObsoleteEx( - Message = "Use the overload that accepts a delegate with a cancellation token.", - TreatAsErrorFromVersion = "8", - RemoveInVersion = "9")] - public static void DefineCriticalErrorAction(this EndpointConfiguration endpointConfiguration, Func onCriticalError) => throw new NotImplementedException(); - } -} - -namespace NServiceBus.Unicast.Subscriptions.MessageDrivenSubscriptions -{ - [ObsoleteEx( - TreatAsErrorFromVersion = "8.0.0", - RemoveInVersion = "9.0.0")] - public interface IInitializableSubscriptionStorage : ISubscriptionStorage - { - void Init(); - } -} - -namespace NServiceBus -{ - [ObsoleteEx( - TreatAsErrorFromVersion = "8.0.0", - RemoveInVersion = "9.0.0", ReplacementTypeOrMember = nameof(MessageIntent))] -#pragma warning disable CA1711 // Identifiers should not have incorrect suffix - public enum MessageIntentEnum { } -#pragma warning restore CA1711 // Identifiers should not have incorrect suffix -} - -namespace NServiceBus.Sagas -{ - [ObsoleteEx( - TreatAsErrorFromVersion = "8.0.0", - RemoveInVersion = "9.0.0", ReplacementTypeOrMember = "ISagaFinder")] -#pragma warning disable PS0024 // A non-interface type should not be prefixed with I - public abstract class IFindSagas { } -#pragma warning restore PS0024 // A non-interface type should not be prefixed with I -} - -namespace NServiceBus.Extensibility -{ - [ObsoleteEx( - TreatAsErrorFromVersion = "8.0.0", - RemoveInVersion = "9.0.0", ReplacementTypeOrMember = nameof(IReadOnlyContextBag))] -#pragma warning disable IDE1006 // Naming Styles - public interface ReadOnlyContextBag { } -#pragma warning restore IDE1006 // Naming Styles -} - -namespace NServiceBus.Persistence -{ - [ObsoleteEx( - TreatAsErrorFromVersion = "8.0.0", - RemoveInVersion = "9.0.0", ReplacementTypeOrMember = nameof(ISynchronizedStorageSession))] -#pragma warning disable IDE1006 // Naming Styles - public interface SynchronizedStorageSession { } -#pragma warning restore IDE1006 // Naming Styles -} - -namespace NServiceBus.Persistence -{ - using System.Threading; - using System.Threading.Tasks; - using Extensibility; - using Outbox; - using Transport; - - [ObsoleteEx( - TreatAsErrorFromVersion = "8.0.0", - RemoveInVersion = "9.0.0", ReplacementTypeOrMember = nameof(ICompletableSynchronizedStorageSession))] -#pragma warning disable IDE1006 // Naming Styles - public interface CompletableSynchronizedStorageSession { } - - [ObsoleteEx( - TreatAsErrorFromVersion = "8.0.0", - RemoveInVersion = "9.0.0", ReplacementTypeOrMember = nameof(ICompletableSynchronizedStorageSession))] - public interface ISynchronizedStorageAdapter - { - Task TryAdapt(IOutboxTransaction transaction, ContextBag context, CancellationToken cancellationToken = default); - - Task TryAdapt(TransportTransaction transportTransaction, ContextBag context, CancellationToken cancellationToken = default); - } - [ObsoleteEx( - TreatAsErrorFromVersion = "8.0.0", - RemoveInVersion = "9.0.0", ReplacementTypeOrMember = nameof(ICompletableSynchronizedStorageSession))] - public interface ISynchronizedStorage - { - Task OpenSession(ContextBag contextBag, CancellationToken cancellationToken = default); - } -#pragma warning restore IDE1006 // Naming Styles -} - -namespace NServiceBus.Outbox -{ - [ObsoleteEx( - TreatAsErrorFromVersion = "8.0.0", - RemoveInVersion = "9.0.0", ReplacementTypeOrMember = nameof(IOutboxTransaction))] -#pragma warning disable IDE1006 // Naming Styles - public interface OutboxTransaction { } -#pragma warning restore IDE1006 // Naming Styles -} - -namespace NServiceBus.Settings -{ - [ObsoleteEx( - TreatAsErrorFromVersion = "8.0.0", - RemoveInVersion = "9.0.0", ReplacementTypeOrMember = nameof(IReadOnlySettings))] -#pragma warning disable IDE1006 // Naming Styles - public interface ReadOnlySettings { } -#pragma warning restore IDE1006 // Naming Styles -} - -namespace NServiceBus -{ - using System; - using DataBus; - - public static partial class UseDataBusExtensions - { - [ObsoleteEx( - Message = "Specifying data bus serializer is mandatory. Use the overload that accepts a data bus serializer type.", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public static DataBusExtensions UseDataBus(this EndpointConfiguration config) where T : DataBusDefinition => throw new NotImplementedException(); - - [ObsoleteEx( - Message = "Specifying a serializer for data bus is mandatory. Use the overload that accepts a data bus serializer type.", - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0")] - public static DataBusExtensions UseDataBus(this EndpointConfiguration config, Type dataBusType) => throw new NotImplementedException(); - } -} -#pragma warning restore 1591 diff --git a/src/NServiceBus.Testing.Fakes/obsoletes-v8.cs b/src/NServiceBus.Testing.Fakes/obsoletes-v8.cs deleted file mode 100644 index 2e1df64214..0000000000 --- a/src/NServiceBus.Testing.Fakes/obsoletes-v8.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace NServiceBus.Testing -{ - using System; - - public partial class TestableTransportReceiveContext// : TestableBehaviorContext, ITransportReceiveContext - { - [Obsolete("The AbortReceiveOperation method is no longer supported. See the upgrade guide for more details. Will be removed in version 9.0.0.", true)] - public bool ReceiveOperationAborted { get; set; } - - [Obsolete("The AbortReceiveOperation method is no longer supported. See the upgrade guide for more details. Will be removed in version 9.0.0.", true)] - public virtual void AbortReceiveOperation() => throw new NotImplementedException(); - } -} \ No newline at end of file From 54408c697cc64fa3e12d5cba4573a1cf506510ee Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Thu, 10 Aug 2023 13:37:34 -0400 Subject: [PATCH 09/51] Move v9 obsoletes --- src/NServiceBus.Core/Audit/IAuditContext.cs | 13 +- .../Features/FeatureConfigurationContext.cs | 11 +- .../ServiceCollectionExtensions.cs | 146 ------------ .../ServiceProviderExtensions.cs | 67 ------ .../Pipeline/ConnectorContextExtensions.cs | 12 - .../ImmediateDispatchOptionExtensions.cs | 16 +- src/NServiceBus.Core/SettingsExtensions.cs | 55 ----- .../Support/RuntimeEnvironment.cs | 19 +- .../Transports/TransportDefinition.cs | 12 +- .../UnitOfWork/IManageUnitsOfWork.cs | 27 --- src/NServiceBus.Core/obsoletes-v9.cs | 214 ++++++++++++++++++ 11 files changed, 222 insertions(+), 370 deletions(-) delete mode 100644 src/NServiceBus.Core/ObjectBuilder/ServiceCollectionExtensions.cs delete mode 100644 src/NServiceBus.Core/ObjectBuilder/ServiceProviderExtensions.cs delete mode 100644 src/NServiceBus.Core/UnitOfWork/IManageUnitsOfWork.cs create mode 100644 src/NServiceBus.Core/obsoletes-v9.cs diff --git a/src/NServiceBus.Core/Audit/IAuditContext.cs b/src/NServiceBus.Core/Audit/IAuditContext.cs index 0758b2ec79..eee6b83e15 100644 --- a/src/NServiceBus.Core/Audit/IAuditContext.cs +++ b/src/NServiceBus.Core/Audit/IAuditContext.cs @@ -8,7 +8,7 @@ /// /// Provide context to behaviors on the audit pipeline. /// - public interface IAuditContext : IBehaviorContext + public partial interface IAuditContext : IBehaviorContext { /// /// The message to be audited. @@ -25,17 +25,6 @@ public interface IAuditContext : IBehaviorContext /// TimeSpan? TimeToBeReceived { get; } - /// - /// Adds information about the current message that should be audited. - /// - /// The audit key. - /// The value. - [ObsoleteEx( - ReplacementTypeOrMember = nameof(AuditMetadata), - TreatAsErrorFromVersion = "9.0", - RemoveInVersion = "10.0")] - void AddAuditData(string key, string value); - /// /// Metadata for the audited message. /// diff --git a/src/NServiceBus.Core/Features/FeatureConfigurationContext.cs b/src/NServiceBus.Core/Features/FeatureConfigurationContext.cs index 09deeca327..b10ee6a4bd 100644 --- a/src/NServiceBus.Core/Features/FeatureConfigurationContext.cs +++ b/src/NServiceBus.Core/Features/FeatureConfigurationContext.cs @@ -10,7 +10,7 @@ /// /// The context available to features when they are activated. /// - public class FeatureConfigurationContext + public partial class FeatureConfigurationContext { internal FeatureConfigurationContext( IReadOnlySettings settings, @@ -33,15 +33,6 @@ internal FeatureConfigurationContext( /// public IReadOnlySettings Settings { get; } - /// - /// Access to the container to allow for registrations. - /// - [ObsoleteEx( - ReplacementTypeOrMember = nameof(Services), - TreatAsErrorFromVersion = "9.0", - RemoveInVersion = "10.0")] - public IServiceCollection Container => Services; - /// /// Access to the to allow additional service registrations. /// diff --git a/src/NServiceBus.Core/ObjectBuilder/ServiceCollectionExtensions.cs b/src/NServiceBus.Core/ObjectBuilder/ServiceCollectionExtensions.cs deleted file mode 100644 index df048eb218..0000000000 --- a/src/NServiceBus.Core/ObjectBuilder/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,146 +0,0 @@ -namespace NServiceBus -{ - using System; - using System.Linq; - using Microsoft.Extensions.DependencyInjection; - - /// - /// Contains extension methods for that were formerly provided by IConfigureComponents />. - /// - [ObsoleteEx( - Message = "Use methods on IServiceCollection instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information.", - TreatAsErrorFromVersion = "9.0", - RemoveInVersion = "10.0")] - public static class ServiceCollectionExtensions - { - /// - /// Configures the given type. Can be used to configure all kinds of properties. - /// - /// The to register the types in. - /// The concrete implementation of the component. - /// Defines lifecycle semantics for the given type. - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceCollection.Add", - TreatAsErrorFromVersion = "9.0", - RemoveInVersion = "10.0")] - public static void ConfigureComponent(this IServiceCollection serviceCollection, Type concreteComponent, DependencyLifecycle dependencyLifecycle) - { - var serviceLifeTime = MapLifeCycle(dependencyLifecycle); - serviceCollection.Add(new ServiceDescriptor(concreteComponent, concreteComponent, serviceLifeTime)); - RegisterInterfaces(concreteComponent, serviceLifeTime, serviceCollection); - } - - /// - /// Configures the given type, allowing to fluently configure properties. - /// - /// The to register the types in. - /// Defines lifecycle semantics for the given type. - [ObsoleteEx( - Message = "Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information.", - TreatAsErrorFromVersion = "9.0", - RemoveInVersion = "10.0")] - public static void ConfigureComponent(this IServiceCollection serviceCollection, DependencyLifecycle dependencyLifecycle) - { - serviceCollection.ConfigureComponent(typeof(T), dependencyLifecycle); - } - - /// - /// Configures the given type, allowing to fluently configure properties. - /// - /// Type to configure. - /// The to register the types in. - /// Factory method that returns the given type. - /// Defines lifecycle semantics for the given type. - [ObsoleteEx( - Message = "Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information.", - TreatAsErrorFromVersion = "9.0", - RemoveInVersion = "10.0")] - public static void ConfigureComponent(this IServiceCollection serviceCollection, Func componentFactory, DependencyLifecycle dependencyLifecycle) - { - serviceCollection.ConfigureComponent(_ => componentFactory(), dependencyLifecycle); - } - - /// - /// Configures the given type, allowing to fluently configure properties. - /// - [ObsoleteEx( - Message = "Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information.", - TreatAsErrorFromVersion = "9.0", - RemoveInVersion = "10.0")] - public static void ConfigureComponent(this IServiceCollection serviceCollection, Func componentFactory, DependencyLifecycle dependencyLifecycle) - { - var componentType = typeof(T); - var serviceLifeTime = MapLifeCycle(dependencyLifecycle); - serviceCollection.Add(new ServiceDescriptor(componentType, p => componentFactory(p), serviceLifeTime)); - RegisterInterfaces(componentType, serviceLifeTime, serviceCollection); - } - - /// - /// Registers the given instance as the singleton that will be returned - /// for the given type. - /// - [ObsoleteEx( - Message = "Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead.", - TreatAsErrorFromVersion = "9.0", - RemoveInVersion = "10.0")] - public static void RegisterSingleton(this IServiceCollection serviceCollection, Type lookupType, object instance) - { - serviceCollection.AddSingleton(lookupType, instance); - } - - /// - /// Registers the given instance as the singleton that will be returned - /// for the given type. - /// - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceCollection.AddSingleton", - TreatAsErrorFromVersion = "9.0", - RemoveInVersion = "10.0")] - public static void RegisterSingleton(this IServiceCollection serviceCollection, T instance) - { - serviceCollection.RegisterSingleton(typeof(T), instance); - } - - /// - /// Indicates if a component of the given type has been configured. - /// - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceCollection.GetEnumerator", - TreatAsErrorFromVersion = "9.0", - RemoveInVersion = "10.0")] - public static bool HasComponent(this IServiceCollection serviceCollection) - { - return serviceCollection.HasComponent(typeof(T)); - } - - /// - /// Indicates if a component of the given type has been configured. - /// - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceCollection.GetEnumerator", - TreatAsErrorFromVersion = "9.0", - RemoveInVersion = "10.0")] - public static bool HasComponent(this IServiceCollection serviceCollection, Type componentType) - { - return serviceCollection.Any(sd => sd.ServiceType == componentType); - } - - static void RegisterInterfaces(Type component, ServiceLifetime lifetime, IServiceCollection serviceCollection) - { - var interfaces = component.GetInterfaces(); - foreach (var serviceType in interfaces) - { - // see https://andrewlock.net/how-to-register-a-service-with-multiple-interfaces-for-in-asp-net-core-di/ - serviceCollection.Add(new ServiceDescriptor(serviceType, sp => sp.GetService(component), lifetime)); - } - } - - static ServiceLifetime MapLifeCycle(DependencyLifecycle dependencyLifecycle) => dependencyLifecycle switch - { - DependencyLifecycle.InstancePerCall => ServiceLifetime.Transient, - DependencyLifecycle.SingleInstance => ServiceLifetime.Singleton, - DependencyLifecycle.InstancePerUnitOfWork => ServiceLifetime.Scoped, - _ => throw new NotSupportedException($"{dependencyLifecycle} is not supported.") - }; - } -} diff --git a/src/NServiceBus.Core/ObjectBuilder/ServiceProviderExtensions.cs b/src/NServiceBus.Core/ObjectBuilder/ServiceProviderExtensions.cs deleted file mode 100644 index b0c1bbe909..0000000000 --- a/src/NServiceBus.Core/ObjectBuilder/ServiceProviderExtensions.cs +++ /dev/null @@ -1,67 +0,0 @@ -namespace NServiceBus.ObjectBuilder -{ - using System; - using System.Collections.Generic; - using Microsoft.Extensions.DependencyInjection; - - /// - /// Contains extension methods for that were formerly provided by IBuilder />. - /// - public static class ServiceProviderExtensions - { - /// - /// Returns an instantiation of the given type. - /// - /// The . - /// The to build. - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceProvider.GetService", - TreatAsErrorFromVersion = "9", - RemoveInVersion = "10")] - public static object Build(this IServiceProvider serviceProvider, Type typeToBuild) => serviceProvider.GetService(typeToBuild); - - /// - /// Returns a child instance of the container to facilitate deterministic disposal - /// of all resources built by the child container. - /// - /// The . - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceProvider.CreateScope", - TreatAsErrorFromVersion = "9", - RemoveInVersion = "10")] - public static IServiceScope CreateChildBuilder(this IServiceProvider serviceProvider) => serviceProvider.CreateScope(); - - /// - /// Creates an instance of the given type, injecting it with all defined dependencies. - /// - /// The . - /// Type to be resolved. - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceProvider.GetService", - TreatAsErrorFromVersion = "9", - RemoveInVersion = "10")] - public static T Build(this IServiceProvider serviceProvider) => serviceProvider.GetService(); - - /// - /// For each type that is compatible with T, an instance is created with all dependencies injected, and yielded to the caller. - /// - /// The . - /// Type to be resolved. - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceProvider.GetServices", - TreatAsErrorFromVersion = "9", - RemoveInVersion = "10")] - public static IEnumerable BuildAll(this IServiceProvider serviceProvider) => serviceProvider.GetServices(); - - /// - /// For each type that is compatible with the given type, an instance is created with all dependencies injected. - /// - /// The . - /// The to build. - [ObsoleteEx( - ReplacementTypeOrMember = "IServiceProvider.GetServices", - TreatAsErrorFromVersion = "9", - RemoveInVersion = "10")] - public static IEnumerable BuildAll(this IServiceProvider serviceProvider, Type typeToBuild) => serviceProvider.GetServices(typeToBuild); - } -} diff --git a/src/NServiceBus.Core/Pipeline/ConnectorContextExtensions.cs b/src/NServiceBus.Core/Pipeline/ConnectorContextExtensions.cs index 83ca018630..8bed4c1267 100644 --- a/src/NServiceBus.Core/Pipeline/ConnectorContextExtensions.cs +++ b/src/NServiceBus.Core/Pipeline/ConnectorContextExtensions.cs @@ -203,18 +203,6 @@ public static IOutgoingPhysicalMessageContext CreateOutgoingPhysicalMessageConte return new OutgoingPhysicalMessageContext(messageBody, routingStrategies, sourceContext); } - /// - /// Creates a based on the current context. - /// - [ObsoleteEx( - TreatAsErrorFromVersion = "9.0", - RemoveInVersion = "10.0", - ReplacementTypeOrMember = "CreateAuditContext(this ForkConnector forkConnector, OutgoingMessage message, string auditAddress, TimeSpan? timeToBeReceived, IIncomingPhysicalMessageContext sourceContext)")] - public static IAuditContext CreateAuditContext(this ForkConnector forkConnector, OutgoingMessage message, string auditAddress, IIncomingPhysicalMessageContext sourceContext) - { - return forkConnector.CreateAuditContext(message, auditAddress, null, sourceContext); - } - /// /// Creates a based on the current context. /// diff --git a/src/NServiceBus.Core/Pipeline/Outgoing/ImmediateDispatchOptionExtensions.cs b/src/NServiceBus.Core/Pipeline/Outgoing/ImmediateDispatchOptionExtensions.cs index 331d66683c..e5c472709c 100644 --- a/src/NServiceBus.Core/Pipeline/Outgoing/ImmediateDispatchOptionExtensions.cs +++ b/src/NServiceBus.Core/Pipeline/Outgoing/ImmediateDispatchOptionExtensions.cs @@ -5,7 +5,7 @@ namespace NServiceBus /// /// Provides ways to request immediate dispatch of messages. /// - public static class ImmediateDispatchOptionExtensions + public static partial class ImmediateDispatchOptionExtensions { /// /// Requests that the message be dispatched to the transport immediately. @@ -23,20 +23,6 @@ public static void RequireImmediateDispatch(this ExtendableOptions options) }); } - /// - /// Returns whether immediate dispatch has been requested by or not. - /// - /// The options being extended. - /// True if immediate dispatch was requested, False otherwise. - [ObsoleteEx( - ReplacementTypeOrMember = nameof(IsImmediateDispatchSet), - RemoveInVersion = "10.0", - TreatAsErrorFromVersion = "9.0")] - public static bool RequiredImmediateDispatch(this ExtendableOptions options) - { - return IsImmediateDispatchSet(options); - } - /// /// Returns whether immediate dispatch has been requested by or not. /// diff --git a/src/NServiceBus.Core/SettingsExtensions.cs b/src/NServiceBus.Core/SettingsExtensions.cs index 636298cd0c..419c8c87ee 100644 --- a/src/NServiceBus.Core/SettingsExtensions.cs +++ b/src/NServiceBus.Core/SettingsExtensions.cs @@ -3,7 +3,6 @@ namespace NServiceBus using System; using System.Collections.Generic; using Settings; - using Transport; /// /// Provides extensions to the settings holder. @@ -28,30 +27,6 @@ public static string EndpointName(this IReadOnlySettings settings) return settings.Get("NServiceBus.Routing.EndpointName"); } - /// - /// Returns the transport specific address of the shared queue name of this endpoint. - /// - [ObsoleteEx( - Message = "Use FeatureConfigurationContext.LocalQueueAddress() to access the endpoint queue address. Inject the ReceiveAddresses class to access the endpoint's receiving transport addresses at runtime. See the NServiceBus version 8 upgrade guide for further details.", - TreatAsErrorFromVersion = "9", - RemoveInVersion = "10")] - public static string LocalAddress(this IReadOnlySettings settings) - { - Guard.ThrowIfNull(settings); - - if (!settings.TryGet(out var receiveConfiguration)) - { - throw new InvalidOperationException("LocalAddress isn't available until the endpoint configuration is complete."); - } - - if (receiveConfiguration.IsSendOnlyEndpoint) - { - throw new InvalidOperationException("LocalAddress isn't available for send only endpoints."); - } - - return settings.Get().ToTransportAddress(receiveConfiguration.LocalQueueAddress); - } - /// /// Returns the shared queue name of this endpoint. /// @@ -71,35 +46,5 @@ public static string EndpointQueueName(this IReadOnlySettings settings) return receiveConfiguration.QueueNameBase; } - - /// - /// Returns the instance-specific queue name of this endpoint. - /// - [ObsoleteEx( - Message = "Use FeatureConfigurationContext.InstanceSpecificQueueAddress() to access the endpoint instance specific queue address. Inject the ReceiveAddresses class to access the endpoint's receiving transport addresses at runtime. See the NServiceBus version 8 upgrade guide for further details.", - TreatAsErrorFromVersion = "9", - RemoveInVersion = "10")] - public static string InstanceSpecificQueue(this IReadOnlySettings settings) - { - Guard.ThrowIfNull(settings); - - if (!settings.TryGet(out var receiveConfiguration)) - { - throw new InvalidOperationException("Instance-specific receive address isn't available until the endpoint configuration is complete."); - } - - if (receiveConfiguration.IsSendOnlyEndpoint) - { - throw new InvalidOperationException("Instance-specific receive address isn't available for send only endpoints."); - } - - if (receiveConfiguration.InstanceSpecificQueueAddress == null) - { - return null; - } - - return settings.Get().ToTransportAddress(receiveConfiguration.InstanceSpecificQueueAddress); - - } } } \ No newline at end of file diff --git a/src/NServiceBus.Core/Support/RuntimeEnvironment.cs b/src/NServiceBus.Core/Support/RuntimeEnvironment.cs index 106757d3ba..0700644788 100644 --- a/src/NServiceBus.Core/Support/RuntimeEnvironment.cs +++ b/src/NServiceBus.Core/Support/RuntimeEnvironment.cs @@ -5,33 +5,22 @@ /// /// Abstracts the runtime environment. /// - public static class RuntimeEnvironment + public static partial class RuntimeEnvironment { static RuntimeEnvironment() { - var machineName = Environment.MachineName; - - MachineNameAction = () => machineName; + MachineName = Environment.MachineName; } /// /// Returns the machine name where this endpoint is currently running. /// - public static string MachineName => MachineNameAction(); - + public static string MachineName { get; private set; } - /// - /// Get the machine name, allows for overrides. - /// - [ObsoleteEx( - ReplacementTypeOrMember = "HostInfoSettings.UsingHostName", - TreatAsErrorFromVersion = "9.0", - RemoveInVersion = "10.0")] - public static Func MachineNameAction { get; set; } internal static void SetMachineName(string machineName) { - MachineNameAction = () => machineName; + MachineName = machineName; } } } \ No newline at end of file diff --git a/src/NServiceBus.Core/Transports/TransportDefinition.cs b/src/NServiceBus.Core/Transports/TransportDefinition.cs index 95a7f2ea5b..c4c0fa1d64 100644 --- a/src/NServiceBus.Core/Transports/TransportDefinition.cs +++ b/src/NServiceBus.Core/Transports/TransportDefinition.cs @@ -9,7 +9,7 @@ namespace NServiceBus.Transport /// /// Defines a transport. /// - public abstract class TransportDefinition + public abstract partial class TransportDefinition { TransportTransactionMode transportTransactionMode; @@ -32,16 +32,6 @@ protected TransportDefinition(TransportTransactionMode defaultTransactionMode, b /// public abstract Task Initialize(HostSettings hostSettings, ReceiveSettings[] receivers, string[] sendingAddresses, CancellationToken cancellationToken = default); - - /// - /// Translates a object into a transport specific queue address-string. - /// - [ObsoleteEx( - Message = "Inject the ITransportAddressResolver type to access the address translation mechanism at runtime. See the NServiceBus version 8 upgrade guide for further details.", - TreatAsErrorFromVersion = "9", - RemoveInVersion = "10")] - public abstract string ToTransportAddress(QueueAddress address); - /// /// Returns a list of all supported transaction modes of this transport. /// diff --git a/src/NServiceBus.Core/UnitOfWork/IManageUnitsOfWork.cs b/src/NServiceBus.Core/UnitOfWork/IManageUnitsOfWork.cs deleted file mode 100644 index cd2e7448a5..0000000000 --- a/src/NServiceBus.Core/UnitOfWork/IManageUnitsOfWork.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace NServiceBus.UnitOfWork -{ - using System; - using System.Diagnostics.CodeAnalysis; - using System.Threading.Tasks; - - /// - /// Interface used by NServiceBus to manage units of work as a part of the - /// message processing pipeline. - /// - [ObsoleteEx(Message = "The unit of work pattern is more straightforward to implement in a pipeline behavior, where the using keyword and try/catch blocks can be used.", ReplacementTypeOrMember = "NServiceBus.Pipeline.Behavior", TreatAsErrorFromVersion = "9", RemoveInVersion = "10")] - [SuppressMessage("Code", "PS0018:A task-returning method should have a CancellationToken parameter unless it has a parameter implementing ICancellableContext", Justification = "Obsolete.")] - public interface IManageUnitsOfWork - { - /// - /// Called before all message handlers and modules. - /// - /// This exception will be thrown if null is returned. Return a Task or mark the method as async. - Task Begin(); - - /// - /// Called after all message handlers and modules, if an error has occurred the exception will be passed. - /// - /// This exception will be thrown if null is returned. Return a Task or mark the method as async. - Task End(Exception ex = null); - } -} \ No newline at end of file diff --git a/src/NServiceBus.Core/obsoletes-v9.cs b/src/NServiceBus.Core/obsoletes-v9.cs new file mode 100644 index 0000000000..657331aa2a --- /dev/null +++ b/src/NServiceBus.Core/obsoletes-v9.cs @@ -0,0 +1,214 @@ +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member + +namespace NServiceBus +{ + using System; + using Microsoft.Extensions.DependencyInjection; + using NServiceBus.Extensibility; + using NServiceBus.Pipeline; + using NServiceBus.Settings; + using NServiceBus.Transport; + + public static partial class ConnectorContextExtensions + { + [ObsoleteEx( + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0", + ReplacementTypeOrMember = "CreateAuditContext(this ForkConnector forkConnector, OutgoingMessage message, string auditAddress, TimeSpan? timeToBeReceived, IIncomingPhysicalMessageContext sourceContext)")] + public static IAuditContext CreateAuditContext(this ForkConnector forkConnector, OutgoingMessage message, string auditAddress, IIncomingPhysicalMessageContext sourceContext) => throw new NotImplementedException(); + } + + public static partial class ImmediateDispatchOptionExtensions + { + [ObsoleteEx( + ReplacementTypeOrMember = nameof(IsImmediateDispatchSet), + RemoveInVersion = "10.0", + TreatAsErrorFromVersion = "9.0")] + public static bool RequiredImmediateDispatch(this ExtendableOptions options) => throw new NotImplementedException(); + } + + [ObsoleteEx( + Message = "Use methods on IServiceCollection instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information.", + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0")] + public static class ServiceCollectionExtensions + { + [ObsoleteEx( + ReplacementTypeOrMember = "IServiceCollection.Add", + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0")] + public static void ConfigureComponent(this IServiceCollection serviceCollection, Type concreteComponent, DependencyLifecycle dependencyLifecycle) => throw new NotImplementedException(); + + [ObsoleteEx( + Message = "Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information.", + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0")] + public static void ConfigureComponent(this IServiceCollection serviceCollection, DependencyLifecycle dependencyLifecycle) => throw new NotImplementedException(); + + [ObsoleteEx( + Message = "Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information.", + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0")] + public static void ConfigureComponent(this IServiceCollection serviceCollection, Func componentFactory, DependencyLifecycle dependencyLifecycle) => throw new NotImplementedException(); + + [ObsoleteEx( + Message = "Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information.", + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0")] + public static void ConfigureComponent(this IServiceCollection serviceCollection, Func componentFactory, DependencyLifecycle dependencyLifecycle) => throw new NotImplementedException(); + + [ObsoleteEx( + Message = "Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead.", + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0")] + public static void RegisterSingleton(this IServiceCollection serviceCollection, Type lookupType, object instance) => throw new NotImplementedException(); + + [ObsoleteEx( + ReplacementTypeOrMember = "IServiceCollection.AddSingleton", + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0")] + public static void RegisterSingleton(this IServiceCollection serviceCollection, T instance) => throw new NotImplementedException(); + + [ObsoleteEx( + ReplacementTypeOrMember = "IServiceCollection.GetEnumerator", + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0")] + public static bool HasComponent(this IServiceCollection serviceCollection) => throw new NotImplementedException(); + + [ObsoleteEx( + ReplacementTypeOrMember = "IServiceCollection.GetEnumerator", + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0")] + public static bool HasComponent(this IServiceCollection serviceCollection, Type componentType) => throw new NotImplementedException(); + } + + public static partial class SettingsExtensions + { + [ObsoleteEx( + Message = "Use FeatureConfigurationContext.LocalQueueAddress() to access the endpoint queue address. Inject the ReceiveAddresses class to access the endpoint's receiving transport addresses at runtime. See the NServiceBus version 8 upgrade guide for further details.", + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public static string LocalAddress(this IReadOnlySettings settings) => throw new NotImplementedException(); + + [ObsoleteEx( + Message = "Use FeatureConfigurationContext.InstanceSpecificQueueAddress() to access the endpoint instance specific queue address. Inject the ReceiveAddresses class to access the endpoint's receiving transport addresses at runtime. See the NServiceBus version 8 upgrade guide for further details.", + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public static string InstanceSpecificQueue(this IReadOnlySettings settings) => throw new NotImplementedException(); + } +} + +namespace NServiceBus.Features +{ + using System; + using Microsoft.Extensions.DependencyInjection; + + public partial class FeatureConfigurationContext + { + [ObsoleteEx( + ReplacementTypeOrMember = nameof(Services), + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0")] + public IServiceCollection Container => throw new NotImplementedException(); + } +} + +namespace NServiceBus.ObjectBuilder +{ + using System; + using System.Collections.Generic; + using Microsoft.Extensions.DependencyInjection; + + [ObsoleteEx( + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public static class ServiceProviderExtensions + { + [ObsoleteEx( + ReplacementTypeOrMember = "IServiceProvider.GetService", + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public static object Build(this IServiceProvider serviceProvider, Type typeToBuild) => throw new NotImplementedException(); + + [ObsoleteEx( + ReplacementTypeOrMember = "IServiceProvider.CreateScope", + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public static IServiceScope CreateChildBuilder(this IServiceProvider serviceProvider) => throw new NotImplementedException(); + + [ObsoleteEx( + ReplacementTypeOrMember = "IServiceProvider.GetService", + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public static T Build(this IServiceProvider serviceProvider) => throw new NotImplementedException(); + + [ObsoleteEx( + ReplacementTypeOrMember = "IServiceProvider.GetServices", + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public static IEnumerable BuildAll(this IServiceProvider serviceProvider) => throw new NotImplementedException(); + + [ObsoleteEx( + ReplacementTypeOrMember = "IServiceProvider.GetServices", + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public static IEnumerable BuildAll(this IServiceProvider serviceProvider, Type typeToBuild) => throw new NotImplementedException(); + } +} + +namespace NServiceBus.Pipeline +{ + public partial interface IAuditContext : IBehaviorContext + { + [ObsoleteEx( + ReplacementTypeOrMember = nameof(AuditMetadata), + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0")] + + void AddAuditData(string key, string value); + } +} + +namespace NServiceBus.Support +{ + using System; + + public static partial class RuntimeEnvironment + { + [ObsoleteEx( + ReplacementTypeOrMember = "HostInfoSettings.UsingHostName", + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0")] + public static Func MachineNameAction { get; set; } + } +} + +namespace NServiceBus.Transport +{ + public abstract partial class TransportDefinition + { + [ObsoleteEx( + Message = "Inject the ITransportAddressResolver type to access the address translation mechanism at runtime. See the NServiceBus version 8 upgrade guide for further details.", + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public abstract string ToTransportAddress(QueueAddress address); + } +} + +namespace NServiceBus.UnitOfWork +{ + using System; + using System.Diagnostics.CodeAnalysis; + using System.Threading.Tasks; + + [ObsoleteEx(Message = "The unit of work pattern is more straightforward to implement in a pipeline behavior, where the using keyword and try/catch blocks can be used.", ReplacementTypeOrMember = "NServiceBus.Pipeline.Behavior", TreatAsErrorFromVersion = "9", RemoveInVersion = "10")] + [SuppressMessage("Code", "PS0018:A task-returning method should have a CancellationToken parameter unless it has a parameter implementing ICancellableContext", Justification = "Obsolete.")] + public interface IManageUnitsOfWork + { + Task Begin(); + + Task End(Exception ex = null); + } +} + +#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member \ No newline at end of file From e18fb52f554baf8bebe48b7a56dc5e2a50a39e1a Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Thu, 10 Aug 2023 13:39:47 -0400 Subject: [PATCH 10/51] Update to .NET 8 dependencies --- src/NServiceBus.Core/NServiceBus.Core.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/NServiceBus.Core/NServiceBus.Core.csproj b/src/NServiceBus.Core/NServiceBus.Core.csproj index 4443474a7b..8a179f639e 100644 --- a/src/NServiceBus.Core/NServiceBus.Core.csproj +++ b/src/NServiceBus.Core/NServiceBus.Core.csproj @@ -8,10 +8,10 @@ - - - - + + + + From 07e69b047ba5234be9a708616c7cbdc865a6c82f Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Thu, 10 Aug 2023 13:41:16 -0400 Subject: [PATCH 11/51] Update Microsoft.NET.Test.Sdk --- .../NServiceBus.AcceptanceTests.csproj | 2 +- .../NServiceBus.ContainerTests.csproj | 4 ++-- .../NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj | 2 +- src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj | 4 ++-- .../NServiceBus.Learning.AcceptanceTests.csproj | 2 +- .../NServiceBus.PersistenceTests.csproj | 4 ++-- .../NServiceBus.TransportTests.csproj | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj b/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj index c7cadd2391..886d8e051c 100644 --- a/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj +++ b/src/NServiceBus.AcceptanceTests/NServiceBus.AcceptanceTests.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/NServiceBus.ContainerTests/NServiceBus.ContainerTests.csproj b/src/NServiceBus.ContainerTests/NServiceBus.ContainerTests.csproj index a4118afe02..19ba103b47 100644 --- a/src/NServiceBus.ContainerTests/NServiceBus.ContainerTests.csproj +++ b/src/NServiceBus.ContainerTests/NServiceBus.ContainerTests.csproj @@ -12,9 +12,9 @@ - + - \ No newline at end of file + diff --git a/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj b/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj index ced7a7b991..2d931b5c74 100644 --- a/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj +++ b/src/NServiceBus.Core.Analyzer.Tests.Roslyn4/NServiceBus.Core.Analyzer.Tests.Roslyn4.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj b/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj index 0cc1f12b69..5db2979dc3 100644 --- a/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj +++ b/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj @@ -13,7 +13,7 @@ - + @@ -25,4 +25,4 @@ - \ No newline at end of file + diff --git a/src/NServiceBus.Learning.AcceptanceTests/NServiceBus.Learning.AcceptanceTests.csproj b/src/NServiceBus.Learning.AcceptanceTests/NServiceBus.Learning.AcceptanceTests.csproj index e4f7f786ee..029e7a0ee1 100644 --- a/src/NServiceBus.Learning.AcceptanceTests/NServiceBus.Learning.AcceptanceTests.csproj +++ b/src/NServiceBus.Learning.AcceptanceTests/NServiceBus.Learning.AcceptanceTests.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/NServiceBus.PersistenceTests/NServiceBus.PersistenceTests.csproj b/src/NServiceBus.PersistenceTests/NServiceBus.PersistenceTests.csproj index 61f84a03fe..238c31ad41 100644 --- a/src/NServiceBus.PersistenceTests/NServiceBus.PersistenceTests.csproj +++ b/src/NServiceBus.PersistenceTests/NServiceBus.PersistenceTests.csproj @@ -12,7 +12,7 @@ - + @@ -38,4 +38,4 @@ - \ No newline at end of file + diff --git a/src/NServiceBus.TransportTests/NServiceBus.TransportTests.csproj b/src/NServiceBus.TransportTests/NServiceBus.TransportTests.csproj index 04e2e5ae5e..7ea4c3f6b4 100644 --- a/src/NServiceBus.TransportTests/NServiceBus.TransportTests.csproj +++ b/src/NServiceBus.TransportTests/NServiceBus.TransportTests.csproj @@ -10,7 +10,7 @@ - + From fb6f99eec627fc5b226c8c155d3ea2e0efbdf260 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Thu, 10 Aug 2023 13:54:47 -0400 Subject: [PATCH 12/51] Update workflows --- .github/workflows/ci.yml | 9 ++++----- .github/workflows/release.yml | 5 +++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69d3599f6c..9bd190fe0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,9 +15,9 @@ jobs: 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: @@ -28,9 +28,8 @@ jobs: - 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 36e9e0d43e..91fbb9b291 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,7 +8,7 @@ env: DOTNET_NOLOGO: true jobs: release: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v3.5.3 @@ -17,7 +17,8 @@ jobs: - 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 From bde058eb982aac3a996b287ddcf3a5e852a63866 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Thu, 10 Aug 2023 14:38:35 -0400 Subject: [PATCH 13/51] Remove init.ps1 --- src/NServiceBus.Core/NServiceBus.Core.csproj | 2 - src/NServiceBus.Core/init.ps1 | 67 -------------------- 2 files changed, 69 deletions(-) delete mode 100644 src/NServiceBus.Core/init.ps1 diff --git a/src/NServiceBus.Core/NServiceBus.Core.csproj b/src/NServiceBus.Core/NServiceBus.Core.csproj index 8a179f639e..f958cb799f 100644 --- a/src/NServiceBus.Core/NServiceBus.Core.csproj +++ b/src/NServiceBus.Core/NServiceBus.Core.csproj @@ -31,8 +31,6 @@ - - diff --git a/src/NServiceBus.Core/init.ps1 b/src/NServiceBus.Core/init.ps1 deleted file mode 100644 index 3029acc3d2..0000000000 --- a/src/NServiceBus.Core/init.ps1 +++ /dev/null @@ -1,67 +0,0 @@ -param($installPath, $toolsPath, $package, $project) - -$packageVersion = 'Unknown' -$noticeEvent = 'noticeEvent' -$jobName = 'analytics' - -# cleanup previous runs -Get-Job | ? { $_.Name -eq $jobName } | Remove-Job -Force -ErrorAction SilentlyContinue - -if ($package) { - $packageVersion = $package.Version -} - -# Define script to run in background job -$jobScriptBlock = { - param($packageVersion, $noticeEvent) - - # Set Tracing on within the Job - Set-PSDebug -Trace 2 - - # Setup event forwarding to foreground - Register-EngineEvent -SourceIdentifier $noticeEvent -Forward - - $nserviceBusKeyPath = 'HKCU:SOFTWARE\NServiceBus' - $platformKeyPath = 'HKCU:SOFTWARE\ParticularSoftware' - - if ((Test-Path $nserviceBusKeyPath) -or (Test-Path $platformKeyPath)) { - New-Event -SourceIdentifier $noticeEvent -Sender "analytics" -MessageData "existing" - } - else { - New-Event -SourceIdentifier $noticeEvent -Sender "analytics" -MessageData "newuser" - - # Set Flag to bypass first time user feedback in Platform Installer - New-Item -Path $platformKeyPath -Force | Out-Null - Set-ItemProperty -Path $platformKeyPath -Name 'NuGetUser' -Value 'true' -Force - - # Post Version to particular.net - $wc = New-Object System.Net.WebClient - try { - $url = 'https://api.particular.net/googleanalytics/reportfirsttimeinstall' - $postData = New-Object System.Collections.Specialized.NameValueCollection - $postData.Add("version", $packageversion) - $wc.UseDefaultCredentials = $true - $wc.UploadValues($url, "post", $postdata) - } - finally { - # Dispose - Remove-Variable -Name wc - } - } -} - -$notice = @" -Reporting first time usage and version information to www.particular.net. -This call does not collect any personal information. For more details, -see the License Agreement and the Privacy Policy available here: https://particular.net/licenseagreement. -"@ - -# Run JobScript -$job = Start-Job -ScriptBlock $jobScriptBlock -Name $jobName -ArgumentList $packageVersion, $noticeEvent - -# Wait for show notice event -$event = Wait-Event -SourceIdentifier $noticeEvent -Timeout 5 -Remove-Event -SourceIdentifier $noticeEvent -ErrorAction SilentlyContinue -if ($event.MessageData -eq "newuser") { - Write-Host $notice -} From 5f55b1112e655f242c79d6b8a0f7a1f4f3606414 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Thu, 10 Aug 2023 15:47:31 -0400 Subject: [PATCH 14/51] Remove references to obsolete stuff --- src/NServiceBus.Core/DataBus/DataBusFileBased.cs | 2 +- .../MessageDrivenSubscriptions.cs | 4 ++-- .../SubscriptionMigrationMode/SubscriptionMigrationMode.cs | 4 ++-- src/NServiceBus.Core/Sagas/Sagas.cs | 4 ++-- src/NServiceBus.Core/Serialization/SerializationFeature.cs | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/NServiceBus.Core/DataBus/DataBusFileBased.cs b/src/NServiceBus.Core/DataBus/DataBusFileBased.cs index 44c8f94526..9fb9de9152 100644 --- a/src/NServiceBus.Core/DataBus/DataBusFileBased.cs +++ b/src/NServiceBus.Core/DataBus/DataBusFileBased.cs @@ -22,7 +22,7 @@ protected internal override void Setup(FeatureConfigurationContext context) } var dataBus = new FileShareDataBusImplementation(basePath); - context.Container.AddSingleton(typeof(IDataBus), dataBus); + context.Services.AddSingleton(typeof(IDataBus), dataBus); } } } \ No newline at end of file diff --git a/src/NServiceBus.Core/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptions.cs b/src/NServiceBus.Core/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptions.cs index d81910c212..142139594f 100644 --- a/src/NServiceBus.Core/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptions.cs +++ b/src/NServiceBus.Core/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptions.cs @@ -79,7 +79,7 @@ protected internal override void Setup(FeatureConfigurationContext context) var authorizer = context.Settings.GetSubscriptionAuthorizer(); authorizer ??= _ => true; - context.Container.AddSingleton(authorizer); + context.Services.AddSingleton(authorizer); context.Pipeline.Register(typeof(SubscriptionReceiverBehavior), "Check for subscription messages and execute the requested behavior to subscribe or unsubscribe."); } else @@ -90,7 +90,7 @@ protected internal override void Setup(FeatureConfigurationContext context) var canReceive = !context.Settings.GetOrDefault("Endpoint.SendOnly"); if (canReceive) { - context.Container.AddSingleton(b => + context.Services.AddSingleton(b => { var transportAddressResolver = b.GetRequiredService(); return new SubscriptionRouter( diff --git a/src/NServiceBus.Core/Routing/SubscriptionMigrationMode/SubscriptionMigrationMode.cs b/src/NServiceBus.Core/Routing/SubscriptionMigrationMode/SubscriptionMigrationMode.cs index ce8aed88f8..76a2584b71 100644 --- a/src/NServiceBus.Core/Routing/SubscriptionMigrationMode/SubscriptionMigrationMode.cs +++ b/src/NServiceBus.Core/Routing/SubscriptionMigrationMode/SubscriptionMigrationMode.cs @@ -46,7 +46,7 @@ protected internal override void Setup(FeatureConfigurationContext context) { var endpointInstances = context.Routing.EndpointInstances; - context.Container.AddSingleton(b => + context.Services.AddSingleton(b => { var transportAddressResolver = b.GetRequiredService(); return new SubscriptionRouter( @@ -76,7 +76,7 @@ protected internal override void Setup(FeatureConfigurationContext context) var authorizer = context.Settings.GetSubscriptionAuthorizer(); authorizer ??= _ => true; - context.Container.AddSingleton(authorizer); + context.Services.AddSingleton(authorizer); context.Pipeline.Register(typeof(SubscriptionReceiverBehavior), "Check for subscription messages and execute the requested behavior to subscribe or unsubscribe."); } else diff --git a/src/NServiceBus.Core/Sagas/Sagas.cs b/src/NServiceBus.Core/Sagas/Sagas.cs index b537adc502..72b46f7ecd 100644 --- a/src/NServiceBus.Core/Sagas/Sagas.cs +++ b/src/NServiceBus.Core/Sagas/Sagas.cs @@ -58,13 +58,13 @@ protected internal override void Setup(FeatureConfigurationContext context) sagaMetaModel.VerifyIfEntitiesAreShared(); } - RegisterCustomFindersInContainer(context.Container, sagaMetaModel); + RegisterCustomFindersInContainer(context.Services, sagaMetaModel); foreach (var t in context.Settings.GetAvailableTypes()) { if (IsSagaNotFoundHandler(t)) { - context.Container.ConfigureComponent(t, DependencyLifecycle.InstancePerCall); + context.Services.ConfigureComponent(t, DependencyLifecycle.InstancePerCall); } } diff --git a/src/NServiceBus.Core/Serialization/SerializationFeature.cs b/src/NServiceBus.Core/Serialization/SerializationFeature.cs index 43bfc61401..ca696ea2f9 100644 --- a/src/NServiceBus.Core/Serialization/SerializationFeature.cs +++ b/src/NServiceBus.Core/Serialization/SerializationFeature.cs @@ -55,9 +55,9 @@ protected internal sealed override void Setup(FeatureConfigurationContext contex context.Pipeline.Register("DeserializeLogicalMessagesConnector", new DeserializeMessageConnector(resolver, logicalMessageFactory, messageMetadataRegistry, mapper, allowMessageTypeInference), "Deserializes the physical message body into logical messages"); context.Pipeline.Register("SerializeMessageConnector", new SerializeMessageConnector(defaultSerializer, messageMetadataRegistry), "Converts a logical message into a physical message"); - context.Container.ConfigureComponent(_ => mapper, DependencyLifecycle.SingleInstance); - context.Container.ConfigureComponent(_ => messageMetadataRegistry, DependencyLifecycle.SingleInstance); - context.Container.ConfigureComponent(_ => logicalMessageFactory, DependencyLifecycle.SingleInstance); + context.Services.ConfigureComponent(_ => mapper, DependencyLifecycle.SingleInstance); + context.Services.ConfigureComponent(_ => messageMetadataRegistry, DependencyLifecycle.SingleInstance); + context.Services.ConfigureComponent(_ => logicalMessageFactory, DependencyLifecycle.SingleInstance); LogFoundMessages(messageMetadataRegistry.GetAllMessages()); From 650967f74d40969fa2dc42868db231b551584cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Mon, 14 Aug 2023 08:39:04 +0200 Subject: [PATCH 15/51] Use new di registration API --- src/NServiceBus.Core/EndpointCreator.cs | 2 +- src/NServiceBus.Core/Hosting/HostingComponent.cs | 6 +++--- src/NServiceBus.Core/Pipeline/RegisterStep.cs | 2 +- src/NServiceBus.Core/Serialization/SerializationFeature.cs | 7 ++++--- src/NServiceBus.Core/Transports/TransportSeam.cs | 3 +-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/NServiceBus.Core/EndpointCreator.cs b/src/NServiceBus.Core/EndpointCreator.cs index 5bcd755f09..f949105f3f 100644 --- a/src/NServiceBus.Core/EndpointCreator.cs +++ b/src/NServiceBus.Core/EndpointCreator.cs @@ -94,7 +94,7 @@ void Configure() sendComponent = SendComponent.Initialize(pipelineSettings, hostingConfiguration, routingComponent, messageMapper); - hostingConfiguration.Services.ConfigureComponent(b => settings.Get(), DependencyLifecycle.SingleInstance); + hostingConfiguration.Services.AddSingleton(_ => settings.Get()); receiveComponent = ReceiveComponent.Configure( receiveConfiguration, diff --git a/src/NServiceBus.Core/Hosting/HostingComponent.cs b/src/NServiceBus.Core/Hosting/HostingComponent.cs index a3f3ca3528..774b926e46 100644 --- a/src/NServiceBus.Core/Hosting/HostingComponent.cs +++ b/src/NServiceBus.Core/Hosting/HostingComponent.cs @@ -17,12 +17,12 @@ partial class HostingComponent public static HostingComponent Initialize(Configuration configuration) { var serviceCollection = configuration.Services; - serviceCollection.ConfigureComponent(() => configuration.HostInformation, DependencyLifecycle.SingleInstance); - serviceCollection.ConfigureComponent(() => configuration.CriticalError, DependencyLifecycle.SingleInstance); + serviceCollection.AddSingleton(_ => configuration.HostInformation); + serviceCollection.AddSingleton(_ => configuration.CriticalError); foreach (var installerType in configuration.AvailableTypes.Where(t => IsINeedToInstallSomething(t))) { - serviceCollection.ConfigureComponent(installerType, DependencyLifecycle.InstancePerCall); + serviceCollection.AddTransient(installerType); } // Apply user registrations last, so that user overrides win. diff --git a/src/NServiceBus.Core/Pipeline/RegisterStep.cs b/src/NServiceBus.Core/Pipeline/RegisterStep.cs index f90f0b61b9..cbdfa37b79 100644 --- a/src/NServiceBus.Core/Pipeline/RegisterStep.cs +++ b/src/NServiceBus.Core/Pipeline/RegisterStep.cs @@ -55,7 +55,7 @@ internal void ApplyContainerRegistration(IServiceCollection container) return; } - container.ConfigureComponent(BehaviorType, DependencyLifecycle.InstancePerCall); + container.AddTransient(BehaviorType); } /// diff --git a/src/NServiceBus.Core/Serialization/SerializationFeature.cs b/src/NServiceBus.Core/Serialization/SerializationFeature.cs index ca696ea2f9..701e94133e 100644 --- a/src/NServiceBus.Core/Serialization/SerializationFeature.cs +++ b/src/NServiceBus.Core/Serialization/SerializationFeature.cs @@ -6,6 +6,7 @@ using Features; using Logging; using MessageInterfaces; + using Microsoft.Extensions.DependencyInjection; using Pipeline; using Serialization; using Settings; @@ -55,9 +56,9 @@ protected internal sealed override void Setup(FeatureConfigurationContext contex context.Pipeline.Register("DeserializeLogicalMessagesConnector", new DeserializeMessageConnector(resolver, logicalMessageFactory, messageMetadataRegistry, mapper, allowMessageTypeInference), "Deserializes the physical message body into logical messages"); context.Pipeline.Register("SerializeMessageConnector", new SerializeMessageConnector(defaultSerializer, messageMetadataRegistry), "Converts a logical message into a physical message"); - context.Services.ConfigureComponent(_ => mapper, DependencyLifecycle.SingleInstance); - context.Services.ConfigureComponent(_ => messageMetadataRegistry, DependencyLifecycle.SingleInstance); - context.Services.ConfigureComponent(_ => logicalMessageFactory, DependencyLifecycle.SingleInstance); + context.Services.AddSingleton(_ => mapper); + context.Services.AddSingleton(_ => messageMetadataRegistry); + context.Services.AddSingleton(_ => logicalMessageFactory); LogFoundMessages(messageMetadataRegistry.GetAllMessages()); diff --git a/src/NServiceBus.Core/Transports/TransportSeam.cs b/src/NServiceBus.Core/Transports/TransportSeam.cs index b4832d4103..0929a7ae17 100644 --- a/src/NServiceBus.Core/Transports/TransportSeam.cs +++ b/src/NServiceBus.Core/Transports/TransportSeam.cs @@ -51,8 +51,7 @@ public static TransportSeam Create(Settings transportSeamSettings, HostingCompon var transportSeam = new TransportSeam(transportDefinition, settings, transportSeamSettings.QueueBindings); - hostingConfiguration.Services.ConfigureComponent(() => - transportSeam.TransportInfrastructure.Dispatcher, DependencyLifecycle.SingleInstance); + hostingConfiguration.Services.AddSingleton(_ => transportSeam.TransportInfrastructure.Dispatcher); hostingConfiguration.Services.AddSingleton(_ => new TransportAddressResolver(transportSeam.TransportInfrastructure)); From d55cc18aef0b7494737404ebe24474594958c0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Mon, 14 Aug 2023 09:13:55 +0200 Subject: [PATCH 16/51] Remove all usages of old DI registration API --- .../When_building_components.cs | 45 +++++++------- ...When_querying_for_registered_components.cs | 16 +++-- .../When_registering_components.cs | 49 +++++++-------- .../When_using_nested_containers.cs | 62 +++++++++---------- src/NServiceBus.Core/DataBus/DataBus.cs | 3 +- .../Pipeline/PipelineComponent.cs | 3 +- .../Receiving/ReceiveComponent.cs | 2 +- src/NServiceBus.Core/Sagas/Sagas.cs | 6 +- 8 files changed, 88 insertions(+), 98 deletions(-) diff --git a/src/NServiceBus.ContainerTests/When_building_components.cs b/src/NServiceBus.ContainerTests/When_building_components.cs index 3dfb314278..c63793fcc6 100644 --- a/src/NServiceBus.ContainerTests/When_building_components.cs +++ b/src/NServiceBus.ContainerTests/When_building_components.cs @@ -1,9 +1,7 @@ -#pragma warning disable CS0618 namespace NServiceBus.ContainerTests { using System; using Microsoft.Extensions.DependencyInjection; - using NServiceBus; using NUnit.Framework; public class When_building_components @@ -19,49 +17,49 @@ public void Singleton_components_should_yield_the_same_instance() } [Test] - public void Singlecall_components_should_yield_unique_instances() + public void Transient_components_should_yield_unique_instances() { var serviceCollection = new ServiceCollection(); InitializeServices(serviceCollection); var serviceProvider = serviceCollection.BuildServiceProvider(); - Assert.AreNotEqual(serviceProvider.GetService(), serviceProvider.GetService()); + Assert.AreNotEqual(serviceProvider.GetService(), serviceProvider.GetService()); } [Test] - public void UoW_components_should_yield_the_same_instance() + public void Scoped_components_should_yield_the_same_instance() { var serviceCollection = new ServiceCollection(); InitializeServices(serviceCollection); var serviceProvider = serviceCollection.BuildServiceProvider(); - var instance1 = serviceProvider.GetService(typeof(InstancePerUoWComponent)); - var instance2 = serviceProvider.GetService(typeof(InstancePerUoWComponent)); + var instance1 = serviceProvider.GetService(typeof(ScopedComponent)); + var instance2 = serviceProvider.GetService(typeof(ScopedComponent)); Assert.AreSame(instance1, instance2); } [Test] - public void Lambda_uow_components_should_yield_the_same_instance() + public void Lambda_scoped_components_should_yield_the_same_instance() { var serviceCollection = new ServiceCollection(); InitializeServices(serviceCollection); var serviceProvider = serviceCollection.BuildServiceProvider(); - var instance1 = serviceProvider.GetService(typeof(LambdaComponentUoW)); - var instance2 = serviceProvider.GetService(typeof(LambdaComponentUoW)); + var instance1 = serviceProvider.GetService(typeof(ScopedLambdaComponent)); + var instance2 = serviceProvider.GetService(typeof(ScopedLambdaComponent)); Assert.AreSame(instance1, instance2); } [Test] - public void Lambda_singlecall_components_should_yield_unique_instances() + public void Lambda_transient_components_should_yield_unique_instances() { var serviceCollection = new ServiceCollection(); InitializeServices(serviceCollection); var serviceProvider = serviceCollection.BuildServiceProvider(); - Assert.AreNotEqual(serviceProvider.GetService(typeof(SingleCallLambdaComponent)), serviceProvider.GetService(typeof(SingleCallLambdaComponent))); + Assert.AreNotEqual(serviceProvider.GetService(typeof(TransientLambdaComponent)), serviceProvider.GetService(typeof(TransientLambdaComponent))); } [Test] @@ -102,13 +100,13 @@ public void Resolving_recursive_types_does_not_stack_overflow() void InitializeServices(IServiceCollection serviceCollection) { - serviceCollection.ConfigureComponent(typeof(SingletonComponent), DependencyLifecycle.SingleInstance); - serviceCollection.ConfigureComponent(typeof(SinglecallComponent), DependencyLifecycle.InstancePerCall); - serviceCollection.ConfigureComponent(typeof(InstancePerUoWComponent), DependencyLifecycle.InstancePerUnitOfWork); - serviceCollection.ConfigureComponent(() => new SingletonLambdaComponent(), DependencyLifecycle.SingleInstance); - serviceCollection.ConfigureComponent(() => new SingleCallLambdaComponent(), DependencyLifecycle.InstancePerCall); - serviceCollection.ConfigureComponent(() => new LambdaComponentUoW(), DependencyLifecycle.InstancePerUnitOfWork); - serviceCollection.ConfigureComponent(() => new RecursiveComponent(), DependencyLifecycle.SingleInstance); + serviceCollection.AddSingleton(typeof(SingletonComponent)); + serviceCollection.AddTransient(typeof(TransientComponent)); + serviceCollection.AddScoped(typeof(ScopedComponent)); + serviceCollection.AddSingleton(_ => new SingletonLambdaComponent()); + serviceCollection.AddTransient(_ => new TransientLambdaComponent()); + serviceCollection.AddScoped(_ => new ScopedLambdaComponent()); + serviceCollection.AddSingleton(_ => new RecursiveComponent()); } public class RecursiveComponent @@ -129,7 +127,7 @@ public class SingletonComponentWithPropertyDependency : ISingletonComponentWithP public SingletonComponent Dependency { get; set; } } - public class SinglecallComponent + public class TransientComponent { } @@ -142,11 +140,11 @@ public class SingletonLambdaComponent { } - public class LambdaComponentUoW + public class ScopedLambdaComponent { } - public class SingleCallLambdaComponent + public class TransientLambdaComponent { } } @@ -182,5 +180,4 @@ public class ConstructorDependency public class SetterDependency { } -} -#pragma warning restore CS0618 \ No newline at end of file +} \ No newline at end of file diff --git a/src/NServiceBus.ContainerTests/When_querying_for_registered_components.cs b/src/NServiceBus.ContainerTests/When_querying_for_registered_components.cs index 617d2cc632..4ba8698846 100644 --- a/src/NServiceBus.ContainerTests/When_querying_for_registered_components.cs +++ b/src/NServiceBus.ContainerTests/When_querying_for_registered_components.cs @@ -1,8 +1,7 @@ -#pragma warning disable CS0618 namespace NServiceBus.ContainerTests { + using System.Linq; using Microsoft.Extensions.DependencyInjection; - using NServiceBus; using NUnit.Framework; [TestFixture] @@ -14,7 +13,7 @@ public void Existing_components_should_return_true() var serviceCollection = new ServiceCollection(); InitializeBuilder(serviceCollection); - Assert.True(serviceCollection.HasComponent(typeof(ExistingComponent))); + Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ExistingComponent))); } [Test] @@ -23,7 +22,7 @@ public void Non_existing_components_should_return_false() var serviceCollection = new ServiceCollection(); InitializeBuilder(serviceCollection); - Assert.False(serviceCollection.HasComponent(typeof(NonExistingComponent))); + Assert.False(serviceCollection.Any(sd => sd.ServiceType == typeof(NonExistingComponent))); } [Test] @@ -32,13 +31,13 @@ public void Builders_should_not_determine_existence_by_building_components() var serviceCollection = new ServiceCollection(); InitializeBuilder(serviceCollection); - Assert.True(serviceCollection.HasComponent(typeof(ExistingComponentWithUnsatisfiedDependency))); + Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ExistingComponentWithUnsatisfiedDependency))); } void InitializeBuilder(IServiceCollection c) { - c.ConfigureComponent(typeof(ExistingComponent), DependencyLifecycle.InstancePerCall); - c.ConfigureComponent(typeof(ExistingComponentWithUnsatisfiedDependency), DependencyLifecycle.InstancePerCall); + c.AddTransient(typeof(ExistingComponent)); + c.AddTransient(typeof(ExistingComponentWithUnsatisfiedDependency)); } public class NonExistingComponent @@ -57,5 +56,4 @@ public ExistingComponentWithUnsatisfiedDependency(NonExistingComponent dependenc } } } -} -#pragma warning restore CS0618 \ No newline at end of file +} \ No newline at end of file diff --git a/src/NServiceBus.ContainerTests/When_registering_components.cs b/src/NServiceBus.ContainerTests/When_registering_components.cs index adc67a4f3c..6edd895281 100644 --- a/src/NServiceBus.ContainerTests/When_registering_components.cs +++ b/src/NServiceBus.ContainerTests/When_registering_components.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS0618 namespace NServiceBus.ContainerTests { using System; @@ -16,8 +15,8 @@ public class When_registering_components public void Multiple_registrations_of_the_same_component_should_be_allowed() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(typeof(DuplicateClass), DependencyLifecycle.InstancePerCall); - serviceCollection.ConfigureComponent(typeof(DuplicateClass), DependencyLifecycle.InstancePerCall); + serviceCollection.AddTransient(typeof(DuplicateClass)); + serviceCollection.AddTransient(typeof(DuplicateClass)); var serviceProvider = serviceCollection.BuildServiceProvider(); Assert.AreEqual(2, serviceProvider.GetServices(typeof(DuplicateClass)).Count()); @@ -27,8 +26,8 @@ public void Multiple_registrations_of_the_same_component_should_be_allowed() public void Should_support_lambdas_that_uses_other_components_registered_later() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(s => ((StaticFactory)s.GetService(typeof(StaticFactory))).Create(), DependencyLifecycle.InstancePerCall); - serviceCollection.ConfigureComponent(() => new StaticFactory(), DependencyLifecycle.SingleInstance); + serviceCollection.AddTransient(s => ((StaticFactory)s.GetService(typeof(StaticFactory))).Create()); + serviceCollection.AddSingleton(_ => new StaticFactory()); var serviceProvider = serviceCollection.BuildServiceProvider(); Assert.NotNull(serviceProvider.GetService(typeof(ComponentCreatedByFactory))); @@ -65,7 +64,7 @@ public void Registering_the_same_singleton_for_different_interfaces_should_be_su var singleton = new SingletonThatImplementsToInterfaces(); serviceCollection.AddSingleton(typeof(ISingleton1), singleton); serviceCollection.AddSingleton(typeof(ISingleton2), singleton); - serviceCollection.ConfigureComponent(typeof(ComponentThatDependsOnMultiSingletons), DependencyLifecycle.InstancePerCall); + serviceCollection.AddTransient(typeof(ComponentThatDependsOnMultiSingletons)); var serviceProvider = serviceCollection.BuildServiceProvider(); var dependency = (ComponentThatDependsOnMultiSingletons)serviceProvider.GetService(typeof(ComponentThatDependsOnMultiSingletons)); @@ -81,7 +80,7 @@ public void Registering_the_same_singleton_for_different_interfaces_should_be_su public void Concrete_classes_should_get_the_same_lifecycle_as_their_interfaces() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(typeof(SingletonComponent), DependencyLifecycle.SingleInstance); + serviceCollection.AddSingleton(typeof(SingletonComponent)); var serviceProvider = serviceCollection.BuildServiceProvider(); Assert.AreSame(serviceProvider.GetService(typeof(SingletonComponent)), serviceProvider.GetService(typeof(ISingletonComponent))); @@ -91,11 +90,10 @@ public void Concrete_classes_should_get_the_same_lifecycle_as_their_interfaces() public void All_implemented_interfaces_should_be_registered() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(typeof(ComponentWithMultipleInterfaces), - DependencyLifecycle.InstancePerCall); - Assert.True(serviceCollection.HasComponent(typeof(ISomeInterface))); - Assert.True(serviceCollection.HasComponent(typeof(ISomeOtherInterface))); - Assert.True(serviceCollection.HasComponent(typeof(IYetAnotherInterface))); + serviceCollection.AddTransient(typeof(ComponentWithMultipleInterfaces)); + Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ISomeInterface))); + Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ISomeOtherInterface))); + Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(IYetAnotherInterface))); var serviceProvider = serviceCollection.BuildServiceProvider(); Assert.AreEqual(1, serviceProvider.GetServices(typeof(IYetAnotherInterface)).Count()); @@ -105,10 +103,10 @@ public void All_implemented_interfaces_should_be_registered() public void All_implemented_interfaces_should_be_registered_for_func() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(() => new ComponentWithMultipleInterfaces(), DependencyLifecycle.InstancePerCall); - Assert.True(serviceCollection.HasComponent(typeof(ISomeInterface))); - Assert.True(serviceCollection.HasComponent(typeof(ISomeOtherInterface))); - Assert.True(serviceCollection.HasComponent(typeof(IYetAnotherInterface))); + serviceCollection.AddTransient(_ => new ComponentWithMultipleInterfaces()); + Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ISomeInterface))); + Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ISomeOtherInterface))); + Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(IYetAnotherInterface))); var serviceProvider = serviceCollection.BuildServiceProvider(); @@ -119,8 +117,8 @@ public void All_implemented_interfaces_should_be_registered_for_func() public void Multiple_implementations_should_be_supported() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(typeof(SomeClass), DependencyLifecycle.InstancePerUnitOfWork); - serviceCollection.ConfigureComponent(typeof(SomeOtherClass), DependencyLifecycle.InstancePerUnitOfWork); + serviceCollection.AddScoped(typeof(SomeClass)); + serviceCollection.AddScoped(typeof(SomeOtherClass)); var serviceProvider = serviceCollection.BuildServiceProvider(); Assert.NotNull(serviceProvider.GetService(typeof(SomeClass))); @@ -153,10 +151,9 @@ public void Given_lookupType_should_be_used_as_service_in_the_registration_when_ public void Generic_interfaces_should_be_registered() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(typeof(ComponentWithGenericInterface), - DependencyLifecycle.InstancePerCall); + serviceCollection.AddTransient(typeof(ComponentWithGenericInterface)); - Assert.True(serviceCollection.HasComponent(typeof(ISomeGenericInterface))); + Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ISomeGenericInterface))); } [Test] @@ -164,11 +161,10 @@ public void Generic_interfaces_should_be_registered() public void System_interfaces_should_not_be_auto_registered() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(typeof(ComponentWithSystemInterface), - DependencyLifecycle.InstancePerCall); + serviceCollection.AddTransient(typeof(ComponentWithSystemInterface)); - Assert.False(serviceCollection.HasComponent(typeof(IGrouping))); - Assert.False(serviceCollection.HasComponent(typeof(IDisposable))); + Assert.False(serviceCollection.Any(sd => sd.ServiceType == typeof(IGrouping))); + Assert.False(serviceCollection.Any(sd => sd.ServiceType == typeof(IDisposable))); } } @@ -269,5 +265,4 @@ public enum SomeEnum { X } -} -#pragma warning restore CS0618 \ No newline at end of file +} \ No newline at end of file diff --git a/src/NServiceBus.ContainerTests/When_using_nested_containers.cs b/src/NServiceBus.ContainerTests/When_using_nested_containers.cs index 2886382099..10c65fdc44 100644 --- a/src/NServiceBus.ContainerTests/When_using_nested_containers.cs +++ b/src/NServiceBus.ContainerTests/When_using_nested_containers.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS0618 namespace NServiceBus.ContainerTests { using System; @@ -8,108 +7,108 @@ namespace NServiceBus.ContainerTests public class When_using_nested_containers { [Test] - public void Instance_per_uow__components_should_be_disposed_when_the_child_container_is_disposed() + public void Scoped__components_should_be_disposed_when_the_child_container_is_disposed() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(typeof(InstancePerUoWComponent), DependencyLifecycle.InstancePerUnitOfWork); + serviceCollection.AddScoped(typeof(ScopedComponent)); var serviceProvider = serviceCollection.BuildServiceProvider(); using (var scope = serviceProvider.CreateScope()) { - scope.ServiceProvider.GetService(typeof(InstancePerUoWComponent)); + scope.ServiceProvider.GetService(typeof(ScopedComponent)); } - Assert.True(InstancePerUoWComponent.DisposeCalled); + Assert.True(ScopedComponent.DisposeCalled); } [Test] - public void Instance_per_uow_components_should_yield_different_instances_between_parent_and_child_containers() + public void Scoped_components_should_yield_different_instances_between_parent_and_child_containers() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(typeof(InstancePerUoWComponent), DependencyLifecycle.InstancePerUnitOfWork); + serviceCollection.AddScoped(typeof(ScopedComponent)); var serviceProvider = serviceCollection.BuildServiceProvider(); - var parentInstance = serviceProvider.GetService(typeof(InstancePerUoWComponent)); + var parentInstance = serviceProvider.GetService(typeof(ScopedComponent)); using (var scope = serviceProvider.CreateScope()) { - var childInstance = scope.ServiceProvider.GetService(typeof(InstancePerUoWComponent)); + var childInstance = scope.ServiceProvider.GetService(typeof(ScopedComponent)); Assert.AreNotSame(parentInstance, childInstance); } } [Test] - public void Instance_per_uow_components_should_yield_different_instances_between_different_instances_of_child_containers() + public void Scoped_components_should_yield_different_instances_between_different_instances_of_child_containers() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(typeof(InstancePerUoWComponent), DependencyLifecycle.InstancePerUnitOfWork); + serviceCollection.AddScoped(typeof(ScopedComponent)); var serviceProvider = serviceCollection.BuildServiceProvider(); object instance1; using (var scope = serviceProvider.CreateScope()) { - instance1 = scope.ServiceProvider.GetService(typeof(InstancePerUoWComponent)); + instance1 = scope.ServiceProvider.GetService(typeof(ScopedComponent)); } object instance2; using (var scope = serviceProvider.CreateScope()) { - instance2 = scope.ServiceProvider.GetService(typeof(InstancePerUoWComponent)); + instance2 = scope.ServiceProvider.GetService(typeof(ScopedComponent)); } Assert.AreNotSame(instance1, instance2); } [Test] - public void Instance_per_call_components_should_not_be_shared_across_child_containers() + public void Transient_components_should_not_be_shared_across_child_containers() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(typeof(InstancePerCallComponent), DependencyLifecycle.InstancePerCall); + serviceCollection.AddTransient(typeof(TransientComponent)); var serviceProvider = serviceCollection.BuildServiceProvider(); object instance1; using (var scope = serviceProvider.CreateScope()) { - instance1 = scope.ServiceProvider.GetService(typeof(InstancePerCallComponent)); + instance1 = scope.ServiceProvider.GetService(typeof(TransientComponent)); } object instance2; using (var scope = serviceProvider.CreateScope()) { - instance2 = scope.ServiceProvider.GetService(typeof(InstancePerCallComponent)); + instance2 = scope.ServiceProvider.GetService(typeof(TransientComponent)); } Assert.AreNotSame(instance1, instance2); } [Test] - public void UoW_components_in_the_parent_container_should_be_singletons_in_the_same_child_container() + public void Scoped_components_in_the_parent_container_should_be_singletons_in_the_same_child_container() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(typeof(InstancePerUoWComponent), DependencyLifecycle.InstancePerUnitOfWork); + serviceCollection.AddScoped(typeof(ScopedComponent)); var serviceProvider = serviceCollection.BuildServiceProvider(); using (var scope = serviceProvider.CreateScope()) { - var instance1 = scope.ServiceProvider.GetService(typeof(InstancePerUoWComponent)); - var instance2 = scope.ServiceProvider.GetService(typeof(InstancePerUoWComponent)); + var instance1 = scope.ServiceProvider.GetService(typeof(ScopedComponent)); + var instance2 = scope.ServiceProvider.GetService(typeof(ScopedComponent)); Assert.AreSame(instance1, instance2, "UoW's should be singleton in child container"); } } [Test] - public void UoW_components_built_on_root_container_should_be_singletons_even_with_child_builder_present() + public void Scoped_components_built_on_root_container_should_be_singletons_even_with_child_builder_present() { var serviceCollection = new ServiceCollection(); - serviceCollection.ConfigureComponent(typeof(InstancePerUoWComponent), DependencyLifecycle.InstancePerUnitOfWork); + serviceCollection.AddScoped(typeof(ScopedComponent)); var serviceProvider = serviceCollection.BuildServiceProvider(); using (serviceProvider.CreateScope()) { } - var instance1 = serviceProvider.GetService(typeof(InstancePerUoWComponent)); - var instance2 = serviceProvider.GetService(typeof(InstancePerUoWComponent)); + var instance1 = serviceProvider.GetService(typeof(ScopedComponent)); + var instance2 = serviceProvider.GetService(typeof(ScopedComponent)); Assert.AreSame(instance1, instance2, "UoW's should be singletons in the root container"); } @@ -119,7 +118,7 @@ public void Should_not_dispose_singletons_when_container_goes_out_of_scope() var serviceCollection = new ServiceCollection(); var singletonInMainContainer = new SingletonComponent(); serviceCollection.AddSingleton(typeof(ISingletonComponent), singletonInMainContainer); - serviceCollection.ConfigureComponent(typeof(ComponentThatDependsOfSingleton), DependencyLifecycle.InstancePerUnitOfWork); + serviceCollection.AddScoped(typeof(ComponentThatDependsOfSingleton)); var serviceProvider = serviceCollection.BuildServiceProvider(); using (var scope = serviceProvider.CreateScope()) @@ -130,13 +129,13 @@ public void Should_not_dispose_singletons_when_container_goes_out_of_scope() } [Test] - public void Should_dispose_all_non_percall_IDisposable_components_in_child_container() + public void Should_dispose_all_non_singleton_IDisposable_components_in_child_container() { var serviceCollection = new ServiceCollection(); DisposableComponent.DisposeCalled = false; AnotherDisposableComponent.DisposeCalled = false; serviceCollection.AddSingleton(typeof(AnotherDisposableComponent), new AnotherDisposableComponent()); - serviceCollection.ConfigureComponent(typeof(DisposableComponent), DependencyLifecycle.InstancePerUnitOfWork); + serviceCollection.AddScoped(typeof(DisposableComponent)); var serviceProvider = serviceCollection.BuildServiceProvider(); @@ -175,14 +174,14 @@ class ComponentThatDependsOfSingleton } } - public class InstancePerCallComponent : IDisposable + public class TransientComponent : IDisposable { public void Dispose() { } } - public class InstancePerUoWComponent : IDisposable + public class ScopedComponent : IDisposable { public void Dispose() { @@ -223,5 +222,4 @@ public void Dispose() DisposeCalled = true; } } -} -#pragma warning restore CS0618 \ No newline at end of file +} \ No newline at end of file diff --git a/src/NServiceBus.Core/DataBus/DataBus.cs b/src/NServiceBus.Core/DataBus/DataBus.cs index 0356ba430d..ec19615c39 100644 --- a/src/NServiceBus.Core/DataBus/DataBus.cs +++ b/src/NServiceBus.Core/DataBus/DataBus.cs @@ -2,6 +2,7 @@ namespace NServiceBus.Features { using System; using System.Collections.Generic; + using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; @@ -29,7 +30,7 @@ static Type GetSelectedFeatureForDataBus(SettingsHolder settings) /// protected internal override void Setup(FeatureConfigurationContext context) { - if (context.Services.HasComponent()) + if (context.Services.Any(sd => sd.ServiceType == typeof(IDataBusSerializer))) { throw new Exception("Providing data bus serializer via dependency injection is no longer supported."); } diff --git a/src/NServiceBus.Core/Pipeline/PipelineComponent.cs b/src/NServiceBus.Core/Pipeline/PipelineComponent.cs index 5ac1c8901b..d519c227e8 100644 --- a/src/NServiceBus.Core/Pipeline/PipelineComponent.cs +++ b/src/NServiceBus.Core/Pipeline/PipelineComponent.cs @@ -1,6 +1,7 @@ namespace NServiceBus { using System; + using Microsoft.Extensions.DependencyInjection; using Pipeline; class PipelineComponent @@ -16,7 +17,7 @@ public static PipelineComponent Initialize(PipelineSettings settings, HostingCom foreach (var registeredBehavior in modifications.Replacements) { - hostingConfiguration.Services.ConfigureComponent(registeredBehavior.BehaviorType, DependencyLifecycle.InstancePerCall); + hostingConfiguration.Services.AddTransient(registeredBehavior.BehaviorType); } foreach (var step in modifications.Additions) diff --git a/src/NServiceBus.Core/Receiving/ReceiveComponent.cs b/src/NServiceBus.Core/Receiving/ReceiveComponent.cs index 30cd8c9757..dd74c1eeb0 100644 --- a/src/NServiceBus.Core/Receiving/ReceiveComponent.cs +++ b/src/NServiceBus.Core/Receiving/ReceiveComponent.cs @@ -259,7 +259,7 @@ static void RegisterMessageHandlers(MessageHandlerRegistry handlerRegistry, List foreach (var t in types.Where(IsMessageHandler)) { - container.ConfigureComponent(t, DependencyLifecycle.InstancePerUnitOfWork); + container.AddScoped(t); handlerRegistry.RegisterHandler(t); } diff --git a/src/NServiceBus.Core/Sagas/Sagas.cs b/src/NServiceBus.Core/Sagas/Sagas.cs index 72b46f7ecd..9507345599 100644 --- a/src/NServiceBus.Core/Sagas/Sagas.cs +++ b/src/NServiceBus.Core/Sagas/Sagas.cs @@ -64,7 +64,7 @@ protected internal override void Setup(FeatureConfigurationContext context) { if (IsSagaNotFoundHandler(t)) { - context.Services.ConfigureComponent(t, DependencyLifecycle.InstancePerCall); + context.Services.AddTransient(t); } } @@ -78,11 +78,11 @@ static void RegisterCustomFindersInContainer(IServiceCollection container, IEnum { foreach (var finder in sagaMetaModel.SelectMany(m => m.Finders)) { - container.ConfigureComponent(finder.Type, DependencyLifecycle.InstancePerCall); + container.AddTransient(finder.Type); if (finder.Properties.TryGetValue("custom-finder-clr-type", out var customFinderType)) { - container.ConfigureComponent((Type)customFinderType, DependencyLifecycle.InstancePerCall); + container.AddTransient((Type)customFinderType); } } } From 80ccc8e648c0e324f0de52f792390e54b0330fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Mon, 14 Aug 2023 09:40:07 +0200 Subject: [PATCH 17/51] Remove asserts for now obsoleted address access methods --- .../When_transport_is_started.cs | 20 ------------------- .../When_transport_is_started_send_only.cs | 7 ------- 2 files changed, 27 deletions(-) diff --git a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started.cs b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started.cs index ec548b5640..e6f8d2c08e 100644 --- a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started.cs +++ b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started.cs @@ -1,13 +1,11 @@ namespace NServiceBus.AcceptanceTests.Core.TransportSeam { - using System; using System.Linq; using System.Threading; using System.Threading.Tasks; using AcceptanceTesting; using EndpointTemplates; using Features; - using NServiceBus.Configuration.AdvancedExtensibility; using NServiceBus.Transport; using NUnit.Framework; @@ -25,9 +23,7 @@ public async Task Should_provide_access_to_addresses_and_address_resolution() Assert.AreEqual("SomeAddress", context.ResolvedAddress); Assert.AreEqual(endpointName, context.ReceiveAddresses.MainReceiveAddress); - Assert.AreEqual(context.LocalAddress, context.ReceiveAddresses.MainReceiveAddress); Assert.AreEqual(endpointName + "-MyInstance", context.ReceiveAddresses.InstanceReceiveAddress); - Assert.AreEqual(context.InstanceSpecificQueue, context.ReceiveAddresses.InstanceReceiveAddress); Assert.AreEqual("MySatellite", context.ReceiveAddresses.SatelliteReceiveAddresses.Single()); Assert.AreEqual(endpointName, context.LocalQueueAddress.ToString()); Assert.AreEqual(endpointName + "-MyInstance", context.InstanceSpecificQueueAddress.ToString()); @@ -37,8 +33,6 @@ class Context : ScenarioContext { public string ResolvedAddress { get; set; } public ReceiveAddresses ReceiveAddresses { get; set; } - public string LocalAddress { get; set; } - public string InstanceSpecificQueue { get; set; } public QueueAddress LocalQueueAddress { get; set; } public QueueAddress InstanceSpecificQueueAddress { get; set; } } @@ -49,13 +43,6 @@ public Endpoint() { EndpointSetup(c => { -#pragma warning disable IDE0079 -#pragma warning disable CS0618 - Assert.Throws(() => c.GetSettings().LocalAddress(), "Should throw since the endpoint isn't configured yet"); - Assert.Throws(() => c.GetSettings().InstanceSpecificQueue(), "Should throw since the endpoint isn't configured yet"); -#pragma warning restore CS0618 -#pragma warning restore IDE0079 - c.EnableFeature(); c.MakeInstanceUniquelyAddressable("MyInstance"); }); @@ -67,13 +54,6 @@ protected override void Setup(FeatureConfigurationContext context) { var testContext = (Context)context.Settings.Get(); -#pragma warning disable IDE0079 -#pragma warning disable CS0618 - testContext.LocalAddress = context.Settings.LocalAddress(); - testContext.InstanceSpecificQueue = context.Settings.InstanceSpecificQueue(); -#pragma warning restore CS0618 -#pragma warning restore IDE0079 - testContext.LocalQueueAddress = context.LocalQueueAddress(); testContext.InstanceSpecificQueueAddress = context.InstanceSpecificQueueAddress(); diff --git a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started_send_only.cs b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started_send_only.cs index 276bc7298f..09bc410301 100644 --- a/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started_send_only.cs +++ b/src/NServiceBus.AcceptanceTests/Core/TransportSeam/When_transport_is_started_send_only.cs @@ -44,13 +44,6 @@ protected override void Setup(FeatureConfigurationContext context) { var testContext = (Context)context.Settings.Get(); -#pragma warning disable IDE0079 -#pragma warning disable CS0618 - Assert.Throws(() => context.Settings.LocalAddress(), "Should throw since the endpoint is send only"); - Assert.Throws(() => context.Settings.InstanceSpecificQueue(), "Should throw since the endpoint is send only"); -#pragma warning restore CS0618 -#pragma warning restore IDE0079 - Assert.Throws(() => context.LocalQueueAddress(), "Should throw since the endpoint is send only"); Assert.Throws(() => context.InstanceSpecificQueueAddress(), "Should throw since the endpoint is send only"); From 60eeb17b4dffeeb5e92bc889ffcda609b271c574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Mon, 14 Aug 2023 09:48:43 +0200 Subject: [PATCH 18/51] IMessageCreator is no longer available in DI --- .../When_replying_with_pre_created_interface.cs | 10 +--------- .../Core/Routing/When_routing_interface_message.cs | 10 +--------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs index 6597d936af..e722ebf246 100644 --- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs +++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs @@ -36,18 +36,10 @@ public Endpoint() public class StartMessageHandler : IHandleMessages { - public StartMessageHandler(IMessageCreator messageCreator) - { - this.messageCreator = messageCreator; - } - public Task Handle(MyRequest message, IMessageHandlerContext context) { - var interfaceMessage = messageCreator.CreateInstance(); - return context.Reply(interfaceMessage); + return context.Reply(_ => { }); } - - IMessageCreator messageCreator; } public class MyMessageHandler : IHandleMessages diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_routing_interface_message.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_routing_interface_message.cs index c00fed2550..c979bf2ce4 100644 --- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_routing_interface_message.cs +++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_routing_interface_message.cs @@ -36,18 +36,10 @@ public Endpoint() public class StartMessageHandler : IHandleMessages { - public StartMessageHandler(IMessageCreator messageCreator) - { - this.messageCreator = messageCreator; - } - public Task Handle(StartMessage message, IMessageHandlerContext context) { - var interfaceMessage = messageCreator.CreateInstance(); - return context.Send(interfaceMessage); + return context.Send(_ => { }); } - - IMessageCreator messageCreator; } public class MyMessageHandler : IHandleMessages From 3ccafbed5eb01f4c79bb6b231c6590f2f821169e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Mon, 14 Aug 2023 09:52:41 +0200 Subject: [PATCH 19/51] Add todo --- .../Routing/When_publishing_pre_created_interface.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_pre_created_interface.cs b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_pre_created_interface.cs index 9c72e0d3e1..d5eaee5c15 100644 --- a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_pre_created_interface.cs +++ b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_pre_created_interface.cs @@ -9,6 +9,7 @@ using NUnit.Framework; using Conventions = AcceptanceTesting.Customization.Conventions; + //TODO: Not sure this test is relevant anymore since IMessageCreator is no longer available in DI public class When_publishing_pre_created_interface : NServiceBusAcceptanceTest { [Test] From e40d899d9150f1b9d4d0fb6791710e429c62a9bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Mon, 14 Aug 2023 09:54:41 +0200 Subject: [PATCH 20/51] Add todo about TransactionManager.ImplicitDistributedTransactions --- .../Tx/When_receiving_with_dtc_enabled.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs b/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs index 213e54348a..c1f6b047df 100644 --- a/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs +++ b/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs @@ -24,6 +24,8 @@ public async Task Should_enlist_the_receive_in_the_dtc_tx() [Test] public void Basic_assumptions_promotable_should_fail_if_durable_already_exists() { + //TODO: Is this what we want to do? (only works on windows) + //TransactionManager.ImplicitDistributedTransactions = true; using (var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { Transaction.Current.EnlistDurable(FakePromotableResourceManager.ResourceManagerId, new FakePromotableResourceManager(), EnlistmentOptions.None); From 5327ba66e7549246ac9116810e7ec300cd59d7aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Mon, 14 Aug 2023 10:02:08 +0200 Subject: [PATCH 21/51] Make sure IMessageCreator is registered --- .../Routing/When_publishing_pre_created_interface.cs | 1 - src/NServiceBus.Core/Serialization/SerializationFeature.cs | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_pre_created_interface.cs b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_pre_created_interface.cs index d5eaee5c15..9c72e0d3e1 100644 --- a/src/NServiceBus.AcceptanceTests/Routing/When_publishing_pre_created_interface.cs +++ b/src/NServiceBus.AcceptanceTests/Routing/When_publishing_pre_created_interface.cs @@ -9,7 +9,6 @@ using NUnit.Framework; using Conventions = AcceptanceTesting.Customization.Conventions; - //TODO: Not sure this test is relevant anymore since IMessageCreator is no longer available in DI public class When_publishing_pre_created_interface : NServiceBusAcceptanceTest { [Test] diff --git a/src/NServiceBus.Core/Serialization/SerializationFeature.cs b/src/NServiceBus.Core/Serialization/SerializationFeature.cs index 701e94133e..3afcd7711f 100644 --- a/src/NServiceBus.Core/Serialization/SerializationFeature.cs +++ b/src/NServiceBus.Core/Serialization/SerializationFeature.cs @@ -57,6 +57,7 @@ protected internal sealed override void Setup(FeatureConfigurationContext contex context.Pipeline.Register("SerializeMessageConnector", new SerializeMessageConnector(defaultSerializer, messageMetadataRegistry), "Converts a logical message into a physical message"); context.Services.AddSingleton(_ => mapper); + context.Services.AddSingleton(sp => sp.GetRequiredService()); context.Services.AddSingleton(_ => messageMetadataRegistry); context.Services.AddSingleton(_ => logicalMessageFactory); From f5eb924412baa673928048c0aa5c251f15a2ed05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Mon, 14 Aug 2023 10:07:13 +0200 Subject: [PATCH 22/51] Go back to IMessageCreator since that is what's being tested --- .../Core/Routing/When_replying_with_pre_created_interface.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs index e722ebf246..0062a741b2 100644 --- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs +++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs @@ -84,4 +84,4 @@ public interface IMyReply : IMessage { } } -} +} \ No newline at end of file From 4fd18fa65b344c5174546c2160a6cf5a80b8fd93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Mon, 14 Aug 2023 10:11:33 +0200 Subject: [PATCH 23/51] Revert test --- .../When_replying_with_pre_created_interface.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs index 0062a741b2..06ef5f4442 100644 --- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs +++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_replying_with_pre_created_interface.cs @@ -36,10 +36,18 @@ public Endpoint() public class StartMessageHandler : IHandleMessages { + public StartMessageHandler(IMessageCreator messageCreator) + { + this.messageCreator = messageCreator; + } + public Task Handle(MyRequest message, IMessageHandlerContext context) { - return context.Reply(_ => { }); + var interfaceMessage = messageCreator.CreateInstance(); + return context.Reply(interfaceMessage); } + + IMessageCreator messageCreator; } public class MyMessageHandler : IHandleMessages From 1f01dd7dcab66c1b978081940324c1a4a4edc278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Mon, 14 Aug 2023 12:30:57 +0200 Subject: [PATCH 24/51] Properly register installers --- src/NServiceBus.Core/Hosting/HostingComponent.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/NServiceBus.Core/Hosting/HostingComponent.cs b/src/NServiceBus.Core/Hosting/HostingComponent.cs index 774b926e46..f5cafd1c07 100644 --- a/src/NServiceBus.Core/Hosting/HostingComponent.cs +++ b/src/NServiceBus.Core/Hosting/HostingComponent.cs @@ -23,6 +23,7 @@ public static HostingComponent Initialize(Configuration configuration) foreach (var installerType in configuration.AvailableTypes.Where(t => IsINeedToInstallSomething(t))) { serviceCollection.AddTransient(installerType); + serviceCollection.AddTransient(sp => (INeedToInstallSomething)sp.GetRequiredService(installerType)); } // Apply user registrations last, so that user overrides win. From 1d002d2bace618787aeeb6b03bcd679a1731e3b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Mon, 14 Aug 2023 13:00:58 +0200 Subject: [PATCH 25/51] Register interfaces --- .../Pipeline/PipelineComponent.cs | 7 +++++++ src/NServiceBus.Core/Pipeline/RegisterStep.cs | 7 +++++++ .../Receiving/ReceiveComponent.cs | 7 +++++++ src/NServiceBus.Core/Sagas/Sagas.cs | 21 +++++++++++++++++-- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/NServiceBus.Core/Pipeline/PipelineComponent.cs b/src/NServiceBus.Core/Pipeline/PipelineComponent.cs index d519c227e8..7f913b7ab7 100644 --- a/src/NServiceBus.Core/Pipeline/PipelineComponent.cs +++ b/src/NServiceBus.Core/Pipeline/PipelineComponent.cs @@ -18,6 +18,13 @@ public static PipelineComponent Initialize(PipelineSettings settings, HostingCom foreach (var registeredBehavior in modifications.Replacements) { hostingConfiguration.Services.AddTransient(registeredBehavior.BehaviorType); + + var interfaces = registeredBehavior.BehaviorType.GetInterfaces(); + + foreach (var serviceType in interfaces) + { + hostingConfiguration.Services.Add(new ServiceDescriptor(serviceType, sp => sp.GetService(registeredBehavior.BehaviorType), ServiceLifetime.Transient)); + } } foreach (var step in modifications.Additions) diff --git a/src/NServiceBus.Core/Pipeline/RegisterStep.cs b/src/NServiceBus.Core/Pipeline/RegisterStep.cs index cbdfa37b79..bf7f1c6efa 100644 --- a/src/NServiceBus.Core/Pipeline/RegisterStep.cs +++ b/src/NServiceBus.Core/Pipeline/RegisterStep.cs @@ -56,6 +56,13 @@ internal void ApplyContainerRegistration(IServiceCollection container) } container.AddTransient(BehaviorType); + + var interfaces = BehaviorType.GetInterfaces(); + + foreach (var serviceType in interfaces) + { + container.Add(new ServiceDescriptor(serviceType, sp => sp.GetService(BehaviorType), ServiceLifetime.Transient)); + } } /// diff --git a/src/NServiceBus.Core/Receiving/ReceiveComponent.cs b/src/NServiceBus.Core/Receiving/ReceiveComponent.cs index dd74c1eeb0..0c89b87d4b 100644 --- a/src/NServiceBus.Core/Receiving/ReceiveComponent.cs +++ b/src/NServiceBus.Core/Receiving/ReceiveComponent.cs @@ -260,6 +260,13 @@ static void RegisterMessageHandlers(MessageHandlerRegistry handlerRegistry, List foreach (var t in types.Where(IsMessageHandler)) { container.AddScoped(t); + var interfaces = t.GetInterfaces(); + + foreach (var serviceType in interfaces) + { + container.Add(new ServiceDescriptor(serviceType, sp => sp.GetService(t), ServiceLifetime.Scoped)); + } + handlerRegistry.RegisterHandler(t); } diff --git a/src/NServiceBus.Core/Sagas/Sagas.cs b/src/NServiceBus.Core/Sagas/Sagas.cs index 9507345599..0dd6ed32cd 100644 --- a/src/NServiceBus.Core/Sagas/Sagas.cs +++ b/src/NServiceBus.Core/Sagas/Sagas.cs @@ -65,6 +65,12 @@ protected internal override void Setup(FeatureConfigurationContext context) if (IsSagaNotFoundHandler(t)) { context.Services.AddTransient(t); + var interfaces = t.GetInterfaces(); + + foreach (var serviceType in interfaces) + { + context.Services.Add(new ServiceDescriptor(serviceType, sp => sp.GetService(t), ServiceLifetime.Transient)); + } } } @@ -80,9 +86,20 @@ static void RegisterCustomFindersInContainer(IServiceCollection container, IEnum { container.AddTransient(finder.Type); - if (finder.Properties.TryGetValue("custom-finder-clr-type", out var customFinderType)) + foreach (var serviceType in finder.Type.GetInterfaces()) { - container.AddTransient((Type)customFinderType); + container.Add(new ServiceDescriptor(serviceType, sp => sp.GetService(finder.Type), ServiceLifetime.Transient)); + } + + if (finder.Properties.TryGetValue("custom-finder-clr-type", out var customFinder)) + { + var customFinderType = (Type)customFinder; + container.AddTransient(customFinderType); + + foreach (var serviceType in customFinderType.GetInterfaces()) + { + container.Add(new ServiceDescriptor(serviceType, sp => sp.GetService(customFinderType), ServiceLifetime.Transient)); + } } } } From bb650ac912289bafbd26f2386acf03afa38756f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Mon, 14 Aug 2023 13:06:46 +0200 Subject: [PATCH 26/51] Approve DI changes --- ...int_is_warmed_up.Make_sure_things_are_in_DI.approved.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_endpoint_is_warmed_up.Make_sure_things_are_in_DI.approved.txt b/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_endpoint_is_warmed_up.Make_sure_things_are_in_DI.approved.txt index d4b38dfeb7..2903abdc89 100644 --- a/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_endpoint_is_warmed_up.Make_sure_things_are_in_DI.approved.txt +++ b/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_endpoint_is_warmed_up.Make_sure_things_are_in_DI.approved.txt @@ -9,14 +9,14 @@ NServiceBus.Unicast.Subscriptions.MessageDrivenSubscriptions.ISubscriptionStorag ----------- Public registrations not used by Core ----------- NServiceBus.CriticalError - Singleton NServiceBus.Hosting.HostInformation - Singleton -NServiceBus.IHandleMessages`1[[NServiceBus.AcceptanceTests.Core.DependencyInjection.When_endpoint_is_warmed_up+SomeMessage, NServiceBus.AcceptanceTests, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null]] - Scoped +NServiceBus.IHandleMessages`1[[NServiceBus.AcceptanceTests.Core.DependencyInjection.When_endpoint_is_warmed_up+SomeMessage, NServiceBus.AcceptanceTests, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null]] - Scoped NServiceBus.IMessageCreator - Singleton NServiceBus.MessageInterfaces.IMessageMapper - Singleton NServiceBus.Notifications - Singleton NServiceBus.Persistence.ISynchronizedStorageSession - Scoped NServiceBus.Pipeline.IBehavior - Transient -NServiceBus.Pipeline.IBehavior`2[[NServiceBus.Pipeline.IIncomingLogicalMessageContext, NServiceBus.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c],[NServiceBus.Pipeline.IIncomingLogicalMessageContext, NServiceBus.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c]] - Transient -NServiceBus.Pipeline.IBehavior`2[[NServiceBus.Pipeline.IIncomingPhysicalMessageContext, NServiceBus.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c],[NServiceBus.Pipeline.IIncomingPhysicalMessageContext, NServiceBus.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c]] - Transient +NServiceBus.Pipeline.IBehavior`2[[NServiceBus.Pipeline.IIncomingLogicalMessageContext, NServiceBus.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c],[NServiceBus.Pipeline.IIncomingLogicalMessageContext, NServiceBus.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c]] - Transient +NServiceBus.Pipeline.IBehavior`2[[NServiceBus.Pipeline.IIncomingPhysicalMessageContext, NServiceBus.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c],[NServiceBus.Pipeline.IIncomingPhysicalMessageContext, NServiceBus.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c]] - Transient NServiceBus.Pipeline.LogicalMessageFactory - Singleton NServiceBus.Settings.IReadOnlySettings - Singleton NServiceBus.Transport.ISubscriptionManager - Singleton From cdb78c31088a03c54f16f95d60121597149204fc Mon Sep 17 00:00:00 2001 From: kentdr Date: Mon, 14 Aug 2023 13:31:23 -0400 Subject: [PATCH 27/51] Revert auto property change in DataBusProperty --- src/NServiceBus.Core/DataBus/DataBusProperty.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/NServiceBus.Core/DataBus/DataBusProperty.cs b/src/NServiceBus.Core/DataBus/DataBusProperty.cs index bb351b957b..1f3ca6329b 100644 --- a/src/NServiceBus.Core/DataBus/DataBusProperty.cs +++ b/src/NServiceBus.Core/DataBus/DataBusProperty.cs @@ -48,7 +48,9 @@ protected DataBusProperty(SerializationInfo info, StreamingContext context) /// /// The value. /// - public T Value { get; private set; } +#pragma warning disable IDE0032 // Use auto property - Value will be serialized into the message body if it is an auto property + public T Value => value; +#pragma warning restore IDE0032 // Use auto property /// /// The property . @@ -71,8 +73,8 @@ protected DataBusProperty(SerializationInfo info, StreamingContext context) /// The value to set. public void SetValue(object valueToSet) { - Value = valueToSet as T; - HasValue = Value != null; + value = valueToSet as T; + HasValue = value != null; } /// @@ -97,5 +99,10 @@ public void GetObjectData(SerializationInfo info, StreamingContext context) info.AddValue("Key", Key); info.AddValue("HasValue", HasValue); } + +#pragma warning disable IDE0032 // Use auto property - value will be serialized into the message body if it is an auto property + T value; +#pragma warning restore IDE0032 // Use auto property } + } \ No newline at end of file From 40ac3f2152677cea084a2fdf449ceaaddbb196d2 Mon Sep 17 00:00:00 2001 From: kentdr Date: Mon, 14 Aug 2023 15:04:51 -0400 Subject: [PATCH 28/51] Remove obsolete call to InstanceSpecificQueue --- .../Core/Routing/When_using_discriminator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_using_discriminator.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_using_discriminator.cs index b048d51a1e..969a2888c9 100644 --- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_using_discriminator.cs +++ b/src/NServiceBus.AcceptanceTests/Core/Routing/When_using_discriminator.cs @@ -46,7 +46,7 @@ public SpyFeature() protected override void Setup(FeatureConfigurationContext context) { - context.Settings.Get().InstanceDescriminatorFromSettingsExtensions = context.Settings.InstanceSpecificQueue(); + context.Settings.Get().InstanceDescriminatorFromSettingsExtensions = context.InstanceSpecificQueueAddress().Discriminator; } } } From fbc3a268351e6423f8946da7d504a1bdf15bf6e3 Mon Sep 17 00:00:00 2001 From: kentdr Date: Mon, 14 Aug 2023 15:42:09 -0400 Subject: [PATCH 29/51] Add windows guard to dtc tests --- .../Tx/When_receiving_with_dtc_enabled.cs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs b/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs index c1f6b047df..6c84a749f5 100644 --- a/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs +++ b/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs @@ -1,5 +1,7 @@ namespace NServiceBus.AcceptanceTests.Tx { + using System; + using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Transactions; using AcceptanceTesting; @@ -21,17 +23,26 @@ public async Task Should_enlist_the_receive_in_the_dtc_tx() Assert.False(context.CanEnlistPromotable, "There should exists a DTC tx"); } + [Test] public void Basic_assumptions_promotable_should_fail_if_durable_already_exists() { - //TODO: Is this what we want to do? (only works on windows) - //TransactionManager.ImplicitDistributedTransactions = true; - using (var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + + if (OperatingSystem.IsWindows()) { - Transaction.Current.EnlistDurable(FakePromotableResourceManager.ResourceManagerId, new FakePromotableResourceManager(), EnlistmentOptions.None); - Assert.False(Transaction.Current.EnlistPromotableSinglePhase(new FakePromotableResourceManager())); + // This test only work on Windows + TransactionManager.ImplicitDistributedTransactions = true; + using (var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + Transaction.Current.EnlistDurable(FakePromotableResourceManager.ResourceManagerId, new FakePromotableResourceManager(), EnlistmentOptions.None); + Assert.False(Transaction.Current.EnlistPromotableSinglePhase(new FakePromotableResourceManager())); - tx.Complete(); + tx.Complete(); + } + } + else + { + Assert.Ignore("Ignoring this test because it requires Windows"); } } From f7768cbd2c9331798ef59470217057db80fccc9b Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Mon, 14 Aug 2023 15:24:43 -0400 Subject: [PATCH 30/51] Clean up MessageDrivenSubscriptions comment and remove reference --- .../AcceptanceTestingSubscriptionPersistence.cs | 4 +--- .../MessageDrivenSubscriptions.cs | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/NServiceBus.AcceptanceTesting/AcceptanceTestingPersistence/SubscriptionStorage/AcceptanceTestingSubscriptionPersistence.cs b/src/NServiceBus.AcceptanceTesting/AcceptanceTestingPersistence/SubscriptionStorage/AcceptanceTestingSubscriptionPersistence.cs index 98f62167dc..416dbf8980 100644 --- a/src/NServiceBus.AcceptanceTesting/AcceptanceTestingPersistence/SubscriptionStorage/AcceptanceTestingSubscriptionPersistence.cs +++ b/src/NServiceBus.AcceptanceTesting/AcceptanceTestingPersistence/SubscriptionStorage/AcceptanceTestingSubscriptionPersistence.cs @@ -8,9 +8,7 @@ class AcceptanceTestingSubscriptionPersistence : Feature { public AcceptanceTestingSubscriptionPersistence() { -#pragma warning disable CS0618 - DependsOn(); -#pragma warning restore CS0618 + DependsOn("MessageDrivenSubscriptions"); } protected internal override void Setup(FeatureConfigurationContext context) diff --git a/src/NServiceBus.Core/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptions.cs b/src/NServiceBus.Core/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptions.cs index 142139594f..df9ee6b977 100644 --- a/src/NServiceBus.Core/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptions.cs +++ b/src/NServiceBus.Core/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptions.cs @@ -8,11 +8,11 @@ namespace NServiceBus.Features /// /// Allows subscribers to register by sending a subscription message to this endpoint. - /// --- - /// The goal is to remove feature classes that implemented functionality far beyond what features are "supposed" to be. - /// Many of those features have been moved into components instead. Now that this class is internal in V8 that - /// refactoring can occur. /// + + // The goal is to remove feature classes that implement functionality far beyond what features are "supposed" to be. + // Many of those features have been moved into components instead. + // The ObsoleteEx attribute is here so that when it's time to 'RemoveInVersion', the class should not be deleted, but made internal. Once it's internal, refactoring can occur. [ObsoleteEx( Message = "It's not recommended to disable the MessageDrivenSubscriptions feature and this option will be removed in future versions. Use 'TransportExtensions.DisablePublishing()' to avoid the need for a subscription storage if this endpoint does not publish events.", RemoveInVersion = "10", From 6d7704a5711ce3d158a044de78274e0f3c8b4e22 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Mon, 14 Aug 2023 17:03:52 -0400 Subject: [PATCH 31/51] Remove unused UnitOfWork stuff --- ...custom_unit_of_work_with_failed_message.cs | 85 ---- ...om_unit_of_work_with_successful_message.cs | 90 ----- ...nit_of_work_with_wrap_handlers_in_scope.cs | 87 ---- .../UnitOfWork/UnitOfWorkBehaviorTests.cs | 375 ------------------ .../Receiving/ReceiveComponent.cs | 2 - .../UnitOfWork/UnitOfWorkBehavior.cs | 90 ----- 6 files changed, 729 deletions(-) delete mode 100644 src/NServiceBus.AcceptanceTests/Core/UnitOfWork/When_using_custom_unit_of_work_with_failed_message.cs delete mode 100644 src/NServiceBus.AcceptanceTests/Core/UnitOfWork/When_using_custom_unit_of_work_with_successful_message.cs delete mode 100644 src/NServiceBus.AcceptanceTests/Core/UnitOfWork/When_using_custom_unit_of_work_with_wrap_handlers_in_scope.cs delete mode 100644 src/NServiceBus.Core.Tests/UnitOfWork/UnitOfWorkBehaviorTests.cs delete mode 100644 src/NServiceBus.Core/UnitOfWork/UnitOfWorkBehavior.cs diff --git a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/When_using_custom_unit_of_work_with_failed_message.cs b/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/When_using_custom_unit_of_work_with_failed_message.cs deleted file mode 100644 index 7c63f93726..0000000000 --- a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/When_using_custom_unit_of_work_with_failed_message.cs +++ /dev/null @@ -1,85 +0,0 @@ -#pragma warning disable CS0618 -namespace NServiceBus.AcceptanceTests.UnitOfWork -{ - using System; - using System.Threading.Tasks; - using AcceptanceTesting; - using EndpointTemplates; - using Microsoft.Extensions.DependencyInjection; - using NServiceBus.UnitOfWork; - using NUnit.Framework; - - public class When_using_custom_unit_of_work_with_failed_message : NServiceBusAcceptanceTest - { - [Test] - public async Task Should_execute_uow_and_provide_exception_details() - { - var context = await Scenario.Define() - .WithEndpoint(g => - { - g.DoNotFailOnErrorMessages(); - g.When(b => b.SendLocal(new MyMessage())); - }) - .Done(c => c.BeginCalled && c.EndCalled) - .Run(); - - Assert.True(context.BeginCalled, "Unit of work should have been executed"); - Assert.True(context.EndCalled, "Unit of work should have been executed"); - Assert.That(context.EndException, Is.InstanceOf().And.Message.Contain("Something went wrong"), "Exception was not provided but should have been"); - } - - public class Context : ScenarioContext - { - public bool Done { get; set; } - public bool BeginCalled { get; set; } - public bool EndCalled { get; set; } - public Exception EndException { get; set; } - } - - public class EndpointWithCustomUnitOfWork : EndpointConfigurationBuilder - { - public EndpointWithCustomUnitOfWork() - { - EndpointSetup((c, r) => - { - c.RegisterComponents(services => services.AddSingleton()); - }); - } - - class CustomUnitOfWork : IManageUnitsOfWork - { - public CustomUnitOfWork(Context testContext) - { - this.testContext = testContext; - } - - public Task Begin() - { - testContext.BeginCalled = true; - return Task.CompletedTask; - } - - public Task End(Exception ex = null) - { - testContext.EndCalled = true; - testContext.EndException = ex; - return Task.CompletedTask; - } - - Context testContext; - } - - class MyMessageHandler : IHandleMessages - { - public Task Handle(MyMessage message, IMessageHandlerContext context) - { - throw new SimulatedException("Something went wrong"); - } - } - } - - public class MyMessage : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/When_using_custom_unit_of_work_with_successful_message.cs b/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/When_using_custom_unit_of_work_with_successful_message.cs deleted file mode 100644 index 683a682bbb..0000000000 --- a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/When_using_custom_unit_of_work_with_successful_message.cs +++ /dev/null @@ -1,90 +0,0 @@ -#pragma warning disable CS0618 -namespace NServiceBus.AcceptanceTests.UnitOfWork -{ - using System; - using System.Threading.Tasks; - using AcceptanceTesting; - using EndpointTemplates; - using Microsoft.Extensions.DependencyInjection; - using NServiceBus.UnitOfWork; - using NUnit.Framework; - - public class When_using_custom_unit_of_work_with_successful_message : NServiceBusAcceptanceTest - { - [Test] - public async Task Should_execute_uow() - { - var context = await Scenario.Define() - .WithEndpoint(g => g.When(b => b.SendLocal(new MyMessage()))) - .Done(c => c.BeginCalled && c.EndCalled) - .Run(); - - Assert.True(context.BeginCalled, "Unit of work should have been executed"); - Assert.True(context.EndCalled, "Unit of work should have been executed"); - Assert.IsNull(context.EndException, "Exception was provided to unit of work but should not have been"); - } - - public class Context : ScenarioContext - { - public bool Done { get; set; } - public bool BeginCalled { get; set; } - public bool EndCalled { get; set; } - public Exception EndException { get; set; } - } - - public class EndpointWithCustomUnitOfWork : EndpointConfigurationBuilder - { - public EndpointWithCustomUnitOfWork() - { - EndpointSetup((c, r) => - { - c.RegisterComponents(services => services.AddSingleton()); - }); - } - - class CustomUnitOfWork : IManageUnitsOfWork - { - public CustomUnitOfWork(Context testContext) - { - this.testContext = testContext; - } - - public Task Begin() - { - testContext.BeginCalled = true; - return Task.CompletedTask; - } - - public Task End(Exception ex = null) - { - testContext.EndCalled = true; - testContext.EndException = ex; - return Task.CompletedTask; - } - - Context testContext; - } - - class MyMessageHandler : IHandleMessages - { - public MyMessageHandler(Context testContext) - { - this.testContext = testContext; - } - - public Task Handle(MyMessage message, IMessageHandlerContext context) - { - testContext.Done = true; - - return Task.CompletedTask; - } - - Context testContext; - } - } - - public class MyMessage : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/When_using_custom_unit_of_work_with_wrap_handlers_in_scope.cs b/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/When_using_custom_unit_of_work_with_wrap_handlers_in_scope.cs deleted file mode 100644 index c3398dcb26..0000000000 --- a/src/NServiceBus.AcceptanceTests/Core/UnitOfWork/When_using_custom_unit_of_work_with_wrap_handlers_in_scope.cs +++ /dev/null @@ -1,87 +0,0 @@ -#pragma warning disable CS0618 -namespace NServiceBus.AcceptanceTests.UnitOfWork -{ - using System; - using System.Linq; - using System.Threading.Tasks; - using System.Transactions; - using AcceptanceTesting; - using EndpointTemplates; - using Microsoft.Extensions.DependencyInjection; - using NServiceBus.UnitOfWork; - using NUnit.Framework; - - public class When_using_custom_unit_of_work_with_wrap_handlers_in_scope : NServiceBusAcceptanceTest - { - [Test] - public async Task Should_fail() - { - var context = await Scenario.Define() - .WithEndpoint(g => - { - g.DoNotFailOnErrorMessages(); - g.When(b => b.SendLocal(new MyMessage())); - }) - .Done(c => c.FailedMessages.Any()) - .Run(); - - Assert.False(context.ShouldNeverBeCalled, "Unit of work should have been executed"); - } - - public class Context : ScenarioContext - { - public bool Done { get; set; } - public bool ShouldNeverBeCalled { get; set; } - } - - public class EndpointWithCustomUnitOfWork : EndpointConfigurationBuilder - { - public EndpointWithCustomUnitOfWork() - { - EndpointSetup((c, r) => - { - c.UnitOfWork().WrapHandlersInATransactionScope(); - - c.RegisterComponents(services => services.AddSingleton()); - }); - } - - class CustomUnitOfWork : IManageUnitsOfWork - { - TransactionScope transactionScope; - public Task Begin() - { - // this only works because we are not using the async state machine - transactionScope = new TransactionScope(TransactionScopeOption.Required, TransactionScopeAsyncFlowOption.Enabled); - return Task.CompletedTask; - } - - public Task End(Exception ex = null) - { - transactionScope.Complete(); - return Task.CompletedTask; - } - } - - class MyMessageHandler : IHandleMessages - { - Context testContext; - - public MyMessageHandler(Context testContext) - { - this.testContext = testContext; - } - - public Task Handle(MyMessage message, IMessageHandlerContext context) - { - testContext.ShouldNeverBeCalled = true; - return Task.CompletedTask; - } - } - } - - public class MyMessage : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.Core.Tests/UnitOfWork/UnitOfWorkBehaviorTests.cs b/src/NServiceBus.Core.Tests/UnitOfWork/UnitOfWorkBehaviorTests.cs deleted file mode 100644 index 28d355cbea..0000000000 --- a/src/NServiceBus.Core.Tests/UnitOfWork/UnitOfWorkBehaviorTests.cs +++ /dev/null @@ -1,375 +0,0 @@ -#pragma warning disable CS0618 -namespace NServiceBus.Unicast.Tests -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Threading.Tasks; - using Microsoft.Extensions.DependencyInjection; - using NUnit.Framework; - using Testing; - using UnitOfWork; - - [TestFixture] - [SuppressMessage("Code", "PS0018:A task-returning method should have a CancellationToken parameter unless it has a parameter implementing ICancellableContext", Justification = "Obsolete")] - public class UnitOfWorkBehaviorTests - { - [Test] - public async Task Should_not_call_Begin_or_End_when_hasUnitsOfWork_is_false() - { - var services = new ServiceCollection(); - - var behavior = new UnitOfWorkBehavior(); - - await InvokeBehavior(services, behavior: behavior); - - var unitOfWork = new UnitOfWork(); - services.AddTransient(sp => unitOfWork); - - await InvokeBehavior(services, behavior: behavior); - - Assert.IsFalse(unitOfWork.BeginCalled); - Assert.IsFalse(unitOfWork.EndCalled); - } - - [Test] - public void When_first_throw_second_is_cleaned_up() - { - var services = new ServiceCollection(); - - var unitOfWorkThatThrowsFromEnd = new UnitOfWorkThatThrowsFromEnd(); - var unitOfWork = new UnitOfWork(); - - services.AddTransient(sp => unitOfWorkThatThrowsFromEnd); - services.AddTransient(sp => unitOfWork); - - //since it is a single exception then it will not be an AggregateException - Assert.That(async () => await InvokeBehavior(services), Throws.InvalidOperationException); - Assert.IsTrue(unitOfWorkThatThrowsFromEnd.BeginCalled); - Assert.IsTrue(unitOfWorkThatThrowsFromEnd.EndCalled); - Assert.IsTrue(unitOfWork.BeginCalled); - Assert.IsTrue(unitOfWork.EndCalled); - } - - [Test] - public void Should_append_end_exception_to_rethrow() - { - var unitOfWork = new UnitOfWorkThatThrowsFromEnd(); - - var services = new ServiceCollection(); - services.AddTransient(sp => unitOfWork); - - //since it is a single exception then it will not be an AggregateException - Assert.That(async () => await InvokeBehavior(services), Throws.InvalidOperationException.And.SameAs(unitOfWork.ExceptionThrownFromEnd)); - } - - [Test] - public void Should_not_invoke_end_if_begin_was_not_invoked() - { - var services = new ServiceCollection(); - - var unitOfWorkThatThrowsFromBegin = new UnitOfWorkThatThrowsFromBegin(); - var unitOfWork = new UnitOfWork(); - - services.AddTransient(sp => unitOfWorkThatThrowsFromBegin); - services.AddTransient(sp => unitOfWork); - - //since it is a single exception then it will not be an AggregateException - Assert.That(async () => await InvokeBehavior(services), Throws.InvalidOperationException); - Assert.False(unitOfWork.EndCalled); - } - - [Test] - public void Should_pass_exceptions_to_the_uow_end() - { - var services = new ServiceCollection(); - - var unitOfWork = new UnitOfWork(); - - services.AddTransient(sp => unitOfWork); - - var ex = new Exception("Handler failed"); - //since it is a single exception then it will not be an AggregateException - Assert.That(async () => await InvokeBehavior(services, ex), Throws.InstanceOf().And.SameAs(ex)); - Assert.AreSame(ex, unitOfWork.ExceptionPassedToEnd); - } - - [Test] - public async Task Should_invoke_ends_in_reverse_order_of_the_begins() - { - var services = new ServiceCollection(); - - var order = new List(); - var firstUnitOfWork = new OrderAwareUnitOfWork("first", order); - var secondUnitOfWork = new OrderAwareUnitOfWork("second", order); - - services.AddTransient(sp => firstUnitOfWork); - services.AddTransient(sp => secondUnitOfWork); - - await InvokeBehavior(services); - - Assert.AreEqual("first", order[0]); - Assert.AreEqual("second", order[1]); - Assert.AreEqual("second", order[2]); - Assert.AreEqual("first", order[3]); - } - - [Test] - public void Should_call_all_end_even_if_one_or_more_of_them_throws() - { - var services = new ServiceCollection(); - - var unitOfWorkThatThrows = new UnitOfWorkThatThrowsFromEnd(); - var unitOfWork = new UnitOfWork(); - - services.AddTransient(sp => unitOfWorkThatThrows); - services.AddTransient(sp => unitOfWork); - - Assert.That(async () => await InvokeBehavior(services), Throws.InvalidOperationException); - Assert.True(unitOfWork.EndCalled); - } - - [Test] - public void Should_invoke_ends_on_all_begins_that_was_called_even_when_begin_throws() - { - var services = new ServiceCollection(); - - var normalUnitOfWork = new UnitOfWork(); - var unitOfWorkThatThrows = new UnitOfWorkThatThrowsFromBegin(); - var unitOfWorkThatIsNeverCalled = new UnitOfWork(); - - services.AddTransient(sp => normalUnitOfWork); - services.AddTransient(sp => unitOfWorkThatThrows); - services.AddTransient(sp => unitOfWorkThatIsNeverCalled); - - Assert.That(async () => await InvokeBehavior(services), Throws.InvalidOperationException); - - Assert.True(normalUnitOfWork.EndCalled); - Assert.True(unitOfWorkThatThrows.EndCalled); - Assert.False(unitOfWorkThatIsNeverCalled.EndCalled); - } - - [Test] - public void Should_throw_friendly_exception_if_IManageUnitsOfWork_Begin_returns_null() - { - var services = new ServiceCollection(); - - services.AddTransient(sp => new UnitOfWorkThatReturnsNullForBegin()); - Assert.That(async () => await InvokeBehavior(services), - Throws.Exception.With.Message.EqualTo("Return a Task or mark the method as async.")); - } - - [Test] - public void Should_throw_friendly_exception_if_IManageUnitsOfWork_End_returns_null() - { - var services = new ServiceCollection(); - services.AddSingleton(sp => new UnitOfWorkThatReturnsNullForEnd()); - - Assert.That(async () => await InvokeBehavior(services), - Throws.Exception.With.Message.EqualTo("Return a Task or mark the method as async.")); - } - - static Task InvokeBehavior(IServiceCollection services, Exception toThrow = null, UnitOfWorkBehavior behavior = null) - { - var runner = behavior ?? new UnitOfWorkBehavior(); - - var context = new TestableIncomingPhysicalMessageContext - { - Services = services - }; - - return runner.Invoke(context, ctx => - { - if (toThrow != null) - { - throw toThrow; - } - - return Task.CompletedTask; - }); - } - - class UnitOfWorkThatThrowsFromEnd : IManageUnitsOfWork - { - public bool BeginCalled; - public bool EndCalled; - public Exception ExceptionThrownFromEnd = new InvalidOperationException(); - - public Task Begin() - { - BeginCalled = true; - return Task.CompletedTask; - } - - public Task End(Exception ex = null) - { - EndCalled = true; - throw ExceptionThrownFromEnd; - } - } - - class UnitOfWorkThatThrowsFromBegin : IManageUnitsOfWork - { - public bool EndCalled; - public Exception ExceptionThrownFromEnd = new InvalidOperationException(); - - public Task Begin() - { - throw ExceptionThrownFromEnd; - } - - public Task End(Exception ex = null) - { - EndCalled = true; - return Task.CompletedTask; - } - } - - class UnitOfWork : IManageUnitsOfWork - { - public bool BeginCalled; - public bool EndCalled; - public Exception ExceptionPassedToEnd; - - public Task Begin() - { - BeginCalled = true; - return Task.CompletedTask; - } - - public Task End(Exception ex = null) - { - ExceptionPassedToEnd = ex; - EndCalled = true; - return Task.CompletedTask; - } - } - - class UnitOfWorkThatReturnsNullForBegin : IManageUnitsOfWork - { - public Task Begin() - { - return null; - } - - public Task End(Exception ex = null) - { - return Task.CompletedTask; - } - } - - class UnitOfWorkThatReturnsNullForEnd : IManageUnitsOfWork - { - public Task Begin() - { - return Task.CompletedTask; - } - - public Task End(Exception ex = null) - { - return null; - } - } - - [Test] - public async Task Verify_order() - { - var services = new ServiceCollection(); - - var unitOfWork1 = new CountingUnitOfWork(); - var unitOfWork2 = new CountingUnitOfWork(); - var unitOfWork3 = new CountingUnitOfWork(); - - services.AddTransient(sp => unitOfWork1); - services.AddTransient(sp => unitOfWork2); - services.AddTransient(sp => unitOfWork3); - - await InvokeBehavior(services); - - Assert.AreEqual(1, unitOfWork1.BeginCallIndex); - Assert.AreEqual(2, unitOfWork2.BeginCallIndex); - Assert.AreEqual(3, unitOfWork3.BeginCallIndex); - Assert.AreEqual(3, unitOfWork1.EndCallIndex); - Assert.AreEqual(2, unitOfWork2.EndCallIndex); - Assert.AreEqual(1, unitOfWork3.EndCallIndex); - } - - class CountingUnitOfWork : IManageUnitsOfWork - { - static int BeginCallCount; - static int EndCallCount; - public int EndCallIndex; - public int BeginCallIndex; - - public Task Begin() - { - BeginCallCount++; - BeginCallIndex = BeginCallCount; - return Task.CompletedTask; - } - - public Task End(Exception ex = null) - { - EndCallCount++; - EndCallIndex = EndCallCount; - return Task.CompletedTask; - } - } - - [Test] - public void Should_pass_exception_to_cleanup() - { - var services = new ServiceCollection(); - - var unitOfWork = new CaptureExceptionPassedToEndUnitOfWork(); - var throwingUoW = new UnitOfWorkThatThrowsFromEnd(); - - services.AddTransient(sp => unitOfWork); - services.AddTransient(sp => throwingUoW); - - //since it is a single exception then it will not be an AggregateException - Assert.That(async () => await InvokeBehavior(services), Throws.InstanceOf().And.SameAs(throwingUoW.ExceptionThrownFromEnd)); - Assert.AreSame(throwingUoW.ExceptionThrownFromEnd, unitOfWork.Exception); - } - - class CaptureExceptionPassedToEndUnitOfWork : IManageUnitsOfWork - { - public Task Begin() - { - return Task.CompletedTask; - } - - public Task End(Exception ex = null) - { - Exception = ex; - return Task.CompletedTask; - } - - public Exception Exception; - } - - class OrderAwareUnitOfWork : IManageUnitsOfWork - { - string name; - List order; - - public OrderAwareUnitOfWork(string name, List order) - { - this.name = name; - this.order = order; - } - - public Task Begin() - { - order.Add(name); - return Task.CompletedTask; - } - - public Task End(Exception ex = null) - { - order.Add(name); - return Task.CompletedTask; - } - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.Core/Receiving/ReceiveComponent.cs b/src/NServiceBus.Core/Receiving/ReceiveComponent.cs index 0c89b87d4b..dfc4d36dbf 100644 --- a/src/NServiceBus.Core/Receiving/ReceiveComponent.cs +++ b/src/NServiceBus.Core/Receiving/ReceiveComponent.cs @@ -71,8 +71,6 @@ public static ReceiveComponent Configure( return new LoadHandlersConnector(b.GetRequiredService()); }, "Gets all the handlers to invoke from the MessageHandler registry based on the message type."); - pipelineSettings.Register("ExecuteUnitOfWork", new UnitOfWorkBehavior(), "Executes the UoW"); - pipelineSettings.Register("InvokeHandlers", new InvokeHandlerTerminator(hostingConfiguration.ActivityFactory), "Calls the IHandleMessages.Handle(T)"); var handlerDiagnostics = new Dictionary>(); diff --git a/src/NServiceBus.Core/UnitOfWork/UnitOfWorkBehavior.cs b/src/NServiceBus.Core/UnitOfWork/UnitOfWorkBehavior.cs deleted file mode 100644 index c8f564ed4e..0000000000 --- a/src/NServiceBus.Core/UnitOfWork/UnitOfWorkBehavior.cs +++ /dev/null @@ -1,90 +0,0 @@ -namespace NServiceBus -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.Extensions.DependencyInjection; - using Pipeline; - using UnitOfWork; - - class UnitOfWorkBehavior : IBehavior - { - public Task Invoke(IIncomingPhysicalMessageContext context, Func next) - { - if (hasUnitsOfWork) - { - return InvokeUnitsOfWork(context, next); - } - - return next(context); - } - - async Task InvokeUnitsOfWork(IIncomingPhysicalMessageContext context, Func next) - { - var unitsOfWork = new Stack(); - - try - { - var hasUow = false; - foreach (var uow in context.Builder.GetServices()) - { - hasUow = true; - unitsOfWork.Push(uow); - await uow.Begin() - .ThrowIfNull() - .ConfigureAwait(false); - } - - hasUnitsOfWork = hasUow; - - await next(context).ConfigureAwait(false); - - while (unitsOfWork.Count > 0) - { - var popped = unitsOfWork.Pop(); - await popped.End() - .ThrowIfNull() - .ConfigureAwait(false); - } - } - catch (MessageDeserializationException) - { - throw; - } - catch (Exception ex) when (!ex.IsCausedBy(context.CancellationToken)) - { - var trailingExceptions = await AppendEndExceptions(unitsOfWork, ex, context.CancellationToken).ConfigureAwait(false); - if (trailingExceptions.Any()) - { - trailingExceptions.Insert(0, ex); - throw new AggregateException(trailingExceptions); - } - throw; - } - } - - static async Task> AppendEndExceptions(Stack unitsOfWork, Exception initialException, CancellationToken cancellationToken) - { - var exceptionsToThrow = new List(); - while (unitsOfWork.Count > 0) - { - var uow = unitsOfWork.Pop(); - try - { - await uow.End(initialException) - .ThrowIfNull() - .ConfigureAwait(false); - } - catch (Exception endException) - { - exceptionsToThrow.Add(endException); - } - } - return exceptionsToThrow; - } - - volatile bool hasUnitsOfWork = true; - } -} \ No newline at end of file From 77a8513c8ca33cd2b2f38a8a964f677c7ecfa5ee Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Mon, 14 Aug 2023 17:20:05 -0400 Subject: [PATCH 32/51] Remove unneeded tests --- .../Core/Routing/When_using_discriminator.cs | 56 ------------------- .../Settings/SettingsExtensionsTests.cs | 26 --------- 2 files changed, 82 deletions(-) delete mode 100644 src/NServiceBus.AcceptanceTests/Core/Routing/When_using_discriminator.cs delete mode 100644 src/NServiceBus.Core.Tests/Settings/SettingsExtensionsTests.cs diff --git a/src/NServiceBus.AcceptanceTests/Core/Routing/When_using_discriminator.cs b/src/NServiceBus.AcceptanceTests/Core/Routing/When_using_discriminator.cs deleted file mode 100644 index 969a2888c9..0000000000 --- a/src/NServiceBus.AcceptanceTests/Core/Routing/When_using_discriminator.cs +++ /dev/null @@ -1,56 +0,0 @@ -// This test can be removed when the InstanceSpecificQueue() extension is being fully obsoleted -#pragma warning disable IDE0079 // Remove unnecessary suppression -#pragma warning disable CS0618 -namespace NServiceBus.AcceptanceTests.Routing -{ - using System.Threading.Tasks; - using AcceptanceTesting; - using EndpointTemplates; - using Features; - using NUnit.Framework; - - [TestFixture] - class When_using_discriminator : NServiceBusAcceptanceTest - { - const string instanceDiscriminator = "instance-42"; - - [Test] - public async Task Should_be_able_to_read_instance_specific_queue_name_using_extension_method() - { - var context = await Scenario.Define() - .WithEndpoint() - .Done(c => c.EndpointsStarted) - .Run(); - - StringAssert.EndsWith(instanceDiscriminator, context.InstanceDescriminatorFromSettingsExtensions); - } - - class Context : ScenarioContext - { - public string InstanceDescriminatorFromSettingsExtensions { get; set; } - } - - class UniquelyAddressableEndpoint : EndpointConfigurationBuilder - { - public UniquelyAddressableEndpoint() - { - EndpointSetup(c => c.MakeInstanceUniquelyAddressable(instanceDiscriminator)); - } - - public class SpyFeature : Feature - { - public SpyFeature() - { - EnableByDefault(); - } - - protected override void Setup(FeatureConfigurationContext context) - { - context.Settings.Get().InstanceDescriminatorFromSettingsExtensions = context.InstanceSpecificQueueAddress().Discriminator; - } - } - } - } -} -#pragma warning restore CS0618 -#pragma warning restore IDE0079 // Remove unnecessary suppression \ No newline at end of file diff --git a/src/NServiceBus.Core.Tests/Settings/SettingsExtensionsTests.cs b/src/NServiceBus.Core.Tests/Settings/SettingsExtensionsTests.cs deleted file mode 100644 index fd739707f6..0000000000 --- a/src/NServiceBus.Core.Tests/Settings/SettingsExtensionsTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Core.TransportSeam -{ - using System; - using Configuration.AdvancedExtensibility; - using NUnit.Framework; - - [TestFixture] - public class SettingsExtensionsTests - { - [Test] - public void Should_throw_if_receive_addresses_are_accessed_before_transport_configuration() - { - var endpointConfiguration = new EndpointConfiguration("MyEndpoint"); - -#pragma warning disable IDE0079 -#pragma warning disable CS0618 - var localAddressEx = Assert.Throws(() => endpointConfiguration.GetSettings().LocalAddress(), "Should throw since the endpoint hasn't been fully configured yet"); - StringAssert.Contains("LocalAddress isn't available until the endpoint configuration is complete.", localAddressEx.Message); - - var instanceAddressEx = Assert.Throws(() => endpointConfiguration.GetSettings().InstanceSpecificQueue(), "Should throw since the endpoint hasn't been fully configured yet"); - StringAssert.Contains("Instance-specific receive address isn't available until the endpoint configuration is complete.", instanceAddressEx.Message); -#pragma warning restore CS0618 -#pragma warning restore IDE0079 - } - } -} \ No newline at end of file From a5e489b72a429a4371bc4535428d35744c88466c Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Mon, 14 Aug 2023 17:52:29 -0400 Subject: [PATCH 33/51] Clean up AddAuditData references --- src/NServiceBus.Core/Audit/AuditContext.cs | 9 +-------- src/NServiceBus.Core/obsoletes-v9.cs | 10 +++++++++- src/NServiceBus.Testing.Fakes/TestableAuditContext.cs | 11 ++--------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/NServiceBus.Core/Audit/AuditContext.cs b/src/NServiceBus.Core/Audit/AuditContext.cs index 3abd961ee7..2459160dd0 100644 --- a/src/NServiceBus.Core/Audit/AuditContext.cs +++ b/src/NServiceBus.Core/Audit/AuditContext.cs @@ -6,7 +6,7 @@ namespace NServiceBus using Pipeline; using Transport; - class AuditContext : BehaviorContext, IAuditContext, IAuditActionContext + partial class AuditContext : BehaviorContext, IAuditContext, IAuditActionContext { public AuditContext(OutgoingMessage message, string auditAddress, TimeSpan? timeToBeReceived, IBehaviorContext parent) : base(parent) @@ -42,13 +42,6 @@ public AuditAction AuditAction auditAction = value; } } - public void AddAuditData(string key, string value) - { - Guard.ThrowIfNullOrEmpty(key); - Guard.ThrowIfNullOrEmpty(value); - - AuditMetadata[key] = value; - } public IAuditActionContext PreventChanges() { diff --git a/src/NServiceBus.Core/obsoletes-v9.cs b/src/NServiceBus.Core/obsoletes-v9.cs index 657331aa2a..384efaded8 100644 --- a/src/NServiceBus.Core/obsoletes-v9.cs +++ b/src/NServiceBus.Core/obsoletes-v9.cs @@ -9,6 +9,15 @@ namespace NServiceBus using NServiceBus.Settings; using NServiceBus.Transport; + partial class AuditContext + { + [ObsoleteEx( + ReplacementTypeOrMember = nameof(AuditMetadata), + TreatAsErrorFromVersion = "9.0", + RemoveInVersion = "10.0")] + public void AddAuditData(string key, string value) => throw new NotImplementedException(); + } + public static partial class ConnectorContextExtensions { [ObsoleteEx( @@ -164,7 +173,6 @@ public partial interface IAuditContext : IBehaviorContext ReplacementTypeOrMember = nameof(AuditMetadata), TreatAsErrorFromVersion = "9.0", RemoveInVersion = "10.0")] - void AddAuditData(string key, string value); } } diff --git a/src/NServiceBus.Testing.Fakes/TestableAuditContext.cs b/src/NServiceBus.Testing.Fakes/TestableAuditContext.cs index 04c93cedcd..5c07792b07 100644 --- a/src/NServiceBus.Testing.Fakes/TestableAuditContext.cs +++ b/src/NServiceBus.Testing.Fakes/TestableAuditContext.cs @@ -38,15 +38,8 @@ public partial class TestableAuditContext : TestableBehaviorContext, IAuditConte IReadOnlyDictionary IAuditActionContext.AuditMetadata => AuditMetadata; - /// - /// Adds information about the current message that should be audited. - /// - /// The audit key. - /// The value. - public void AddAuditData(string key, string value) - { - AuditMetadata.Add(key, value); - } + // This method is being removed from IAuditContext, so this stub method remains until the removal is done in v10 + public void AddAuditData(string key, string value) => throw new NotImplementedException(); /// /// Locks the audit action for further changes. From b407bd3ff997b37e7484e0eb2747824a5681b81f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Tue, 15 Aug 2023 08:01:52 +0200 Subject: [PATCH 34/51] Extract interface registrations to helper --- .../Pipeline/PipelineComponent.cs | 10 ++----- src/NServiceBus.Core/Pipeline/RegisterStep.cs | 12 +++------ .../Receiving/ReceiveComponent.cs | 13 +++------- src/NServiceBus.Core/Sagas/Sagas.cs | 26 ++++--------------- .../ServiceCollectionExtensions.cs | 18 +++++++++++++ 5 files changed, 32 insertions(+), 47 deletions(-) create mode 100644 src/NServiceBus.Core/ServiceCollectionExtensions.cs diff --git a/src/NServiceBus.Core/Pipeline/PipelineComponent.cs b/src/NServiceBus.Core/Pipeline/PipelineComponent.cs index 7f913b7ab7..3ee23a7e47 100644 --- a/src/NServiceBus.Core/Pipeline/PipelineComponent.cs +++ b/src/NServiceBus.Core/Pipeline/PipelineComponent.cs @@ -2,6 +2,7 @@ namespace NServiceBus { using System; using Microsoft.Extensions.DependencyInjection; + using ObjectBuilder; using Pipeline; class PipelineComponent @@ -17,14 +18,7 @@ public static PipelineComponent Initialize(PipelineSettings settings, HostingCom foreach (var registeredBehavior in modifications.Replacements) { - hostingConfiguration.Services.AddTransient(registeredBehavior.BehaviorType); - - var interfaces = registeredBehavior.BehaviorType.GetInterfaces(); - - foreach (var serviceType in interfaces) - { - hostingConfiguration.Services.Add(new ServiceDescriptor(serviceType, sp => sp.GetService(registeredBehavior.BehaviorType), ServiceLifetime.Transient)); - } + hostingConfiguration.Services.AddWithInterfaces(registeredBehavior.BehaviorType, ServiceLifetime.Transient); } foreach (var step in modifications.Additions) diff --git a/src/NServiceBus.Core/Pipeline/RegisterStep.cs b/src/NServiceBus.Core/Pipeline/RegisterStep.cs index bf7f1c6efa..7e968e7158 100644 --- a/src/NServiceBus.Core/Pipeline/RegisterStep.cs +++ b/src/NServiceBus.Core/Pipeline/RegisterStep.cs @@ -4,6 +4,7 @@ namespace NServiceBus.Pipeline using System.Collections.Generic; using System.Diagnostics; using Microsoft.Extensions.DependencyInjection; + using NServiceBus.ObjectBuilder; /// /// Base class to do an advance registration of a step. @@ -48,21 +49,14 @@ protected RegisterStep(string stepId, Type behavior, string description, Func public Type BehaviorType { get; private set; } - internal void ApplyContainerRegistration(IServiceCollection container) + internal void ApplyContainerRegistration(IServiceCollection serviceCollection) { if (factoryMethod != null) { return; } - container.AddTransient(BehaviorType); - - var interfaces = BehaviorType.GetInterfaces(); - - foreach (var serviceType in interfaces) - { - container.Add(new ServiceDescriptor(serviceType, sp => sp.GetService(BehaviorType), ServiceLifetime.Transient)); - } + serviceCollection.AddWithInterfaces(BehaviorType, ServiceLifetime.Transient); } /// diff --git a/src/NServiceBus.Core/Receiving/ReceiveComponent.cs b/src/NServiceBus.Core/Receiving/ReceiveComponent.cs index dfc4d36dbf..8d76c6f363 100644 --- a/src/NServiceBus.Core/Receiving/ReceiveComponent.cs +++ b/src/NServiceBus.Core/Receiving/ReceiveComponent.cs @@ -7,6 +7,7 @@ namespace NServiceBus using System.Threading.Tasks; using Logging; using Microsoft.Extensions.DependencyInjection; + using NServiceBus.ObjectBuilder; using Outbox; using Pipeline; using Transport; @@ -244,7 +245,7 @@ public Task Stop(CancellationToken cancellationToken = default) return Task.WhenAll(receiverStopTasks); } - static void RegisterMessageHandlers(MessageHandlerRegistry handlerRegistry, List orderedTypes, IServiceCollection container, ICollection availableTypes) + static void RegisterMessageHandlers(MessageHandlerRegistry handlerRegistry, List orderedTypes, IServiceCollection serviceCollection, ICollection availableTypes) { var types = new List(availableTypes); @@ -257,18 +258,12 @@ static void RegisterMessageHandlers(MessageHandlerRegistry handlerRegistry, List foreach (var t in types.Where(IsMessageHandler)) { - container.AddScoped(t); - var interfaces = t.GetInterfaces(); - - foreach (var serviceType in interfaces) - { - container.Add(new ServiceDescriptor(serviceType, sp => sp.GetService(t), ServiceLifetime.Scoped)); - } + serviceCollection.AddWithInterfaces(t, ServiceLifetime.Scoped); handlerRegistry.RegisterHandler(t); } - container.AddSingleton(handlerRegistry); + serviceCollection.AddSingleton(handlerRegistry); } public static bool IsMessageHandler(Type type) diff --git a/src/NServiceBus.Core/Sagas/Sagas.cs b/src/NServiceBus.Core/Sagas/Sagas.cs index 0dd6ed32cd..caaad43627 100644 --- a/src/NServiceBus.Core/Sagas/Sagas.cs +++ b/src/NServiceBus.Core/Sagas/Sagas.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.DependencyInjection; + using NServiceBus.ObjectBuilder; using NServiceBus.Sagas; /// @@ -64,13 +65,7 @@ protected internal override void Setup(FeatureConfigurationContext context) { if (IsSagaNotFoundHandler(t)) { - context.Services.AddTransient(t); - var interfaces = t.GetInterfaces(); - - foreach (var serviceType in interfaces) - { - context.Services.Add(new ServiceDescriptor(serviceType, sp => sp.GetService(t), ServiceLifetime.Transient)); - } + context.Services.AddWithInterfaces(t, ServiceLifetime.Transient); } } @@ -84,22 +79,11 @@ static void RegisterCustomFindersInContainer(IServiceCollection container, IEnum { foreach (var finder in sagaMetaModel.SelectMany(m => m.Finders)) { - container.AddTransient(finder.Type); + container.AddWithInterfaces(finder.Type, ServiceLifetime.Transient); - foreach (var serviceType in finder.Type.GetInterfaces()) + if (finder.Properties.TryGetValue("custom-finder-clr-type", out var customFinderType)) { - container.Add(new ServiceDescriptor(serviceType, sp => sp.GetService(finder.Type), ServiceLifetime.Transient)); - } - - if (finder.Properties.TryGetValue("custom-finder-clr-type", out var customFinder)) - { - var customFinderType = (Type)customFinder; - container.AddTransient(customFinderType); - - foreach (var serviceType in customFinderType.GetInterfaces()) - { - container.Add(new ServiceDescriptor(serviceType, sp => sp.GetService(customFinderType), ServiceLifetime.Transient)); - } + container.AddWithInterfaces((Type)customFinderType, ServiceLifetime.Transient); } } } diff --git a/src/NServiceBus.Core/ServiceCollectionExtensions.cs b/src/NServiceBus.Core/ServiceCollectionExtensions.cs new file mode 100644 index 0000000000..698ec72b40 --- /dev/null +++ b/src/NServiceBus.Core/ServiceCollectionExtensions.cs @@ -0,0 +1,18 @@ +namespace NServiceBus.ObjectBuilder +{ + using Microsoft.Extensions.DependencyInjection; + using System; + + static class ServiceCollectionExtensions + { + public static void AddWithInterfaces(this IServiceCollection serviceCollection, Type serviceType, ServiceLifetime serviceLifetime) + { + serviceCollection.Add(new ServiceDescriptor(serviceType, serviceLifetime)); + + foreach (var interfaceType in serviceType.GetInterfaces()) + { + serviceCollection.Add(new ServiceDescriptor(interfaceType, sp => sp.GetService(serviceType), serviceLifetime)); + } + } + } +} From d8f5bf19944b9a94e25d779583007e07d90975e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Tue, 15 Aug 2023 08:06:37 +0200 Subject: [PATCH 35/51] Fix registration bug --- src/NServiceBus.Core/ServiceCollectionExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NServiceBus.Core/ServiceCollectionExtensions.cs b/src/NServiceBus.Core/ServiceCollectionExtensions.cs index 698ec72b40..eeb3437df2 100644 --- a/src/NServiceBus.Core/ServiceCollectionExtensions.cs +++ b/src/NServiceBus.Core/ServiceCollectionExtensions.cs @@ -7,7 +7,7 @@ static class ServiceCollectionExtensions { public static void AddWithInterfaces(this IServiceCollection serviceCollection, Type serviceType, ServiceLifetime serviceLifetime) { - serviceCollection.Add(new ServiceDescriptor(serviceType, serviceLifetime)); + serviceCollection.Add(new ServiceDescriptor(serviceType, serviceType, serviceLifetime)); foreach (var interfaceType in serviceType.GetInterfaces()) { From 6449a9997eaa1670e61771b4f0dc3adac1edc1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Tue, 15 Aug 2023 08:06:46 +0200 Subject: [PATCH 36/51] Fix feature dependency --- .../AcceptanceTestingSubscriptionPersistence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NServiceBus.AcceptanceTesting/AcceptanceTestingPersistence/SubscriptionStorage/AcceptanceTestingSubscriptionPersistence.cs b/src/NServiceBus.AcceptanceTesting/AcceptanceTestingPersistence/SubscriptionStorage/AcceptanceTestingSubscriptionPersistence.cs index 416dbf8980..1dbc0f08b7 100644 --- a/src/NServiceBus.AcceptanceTesting/AcceptanceTestingPersistence/SubscriptionStorage/AcceptanceTestingSubscriptionPersistence.cs +++ b/src/NServiceBus.AcceptanceTesting/AcceptanceTestingPersistence/SubscriptionStorage/AcceptanceTestingSubscriptionPersistence.cs @@ -8,7 +8,7 @@ class AcceptanceTestingSubscriptionPersistence : Feature { public AcceptanceTestingSubscriptionPersistence() { - DependsOn("MessageDrivenSubscriptions"); + DependsOn("NServiceBus.Features.MessageDrivenSubscriptions"); } protected internal override void Setup(FeatureConfigurationContext context) From 91e8b3f16f71f8cadebfd0ec15ebd8572d526895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Tue, 15 Aug 2023 08:22:06 +0200 Subject: [PATCH 37/51] Make relevant container tests use new helper --- .../When_registering_components.cs | 36 ++++--------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/src/NServiceBus.ContainerTests/When_registering_components.cs b/src/NServiceBus.ContainerTests/When_registering_components.cs index 6edd895281..998e713723 100644 --- a/src/NServiceBus.ContainerTests/When_registering_components.cs +++ b/src/NServiceBus.ContainerTests/When_registering_components.cs @@ -6,6 +6,7 @@ namespace NServiceBus.ContainerTests using System.Linq; using Microsoft.Extensions.DependencyInjection; using NServiceBus; + using NServiceBus.ObjectBuilder; using NUnit.Framework; @@ -80,7 +81,7 @@ public void Registering_the_same_singleton_for_different_interfaces_should_be_su public void Concrete_classes_should_get_the_same_lifecycle_as_their_interfaces() { var serviceCollection = new ServiceCollection(); - serviceCollection.AddSingleton(typeof(SingletonComponent)); + serviceCollection.AddWithInterfaces(typeof(SingletonComponent), ServiceLifetime.Singleton); var serviceProvider = serviceCollection.BuildServiceProvider(); Assert.AreSame(serviceProvider.GetService(typeof(SingletonComponent)), serviceProvider.GetService(typeof(ISingletonComponent))); @@ -90,7 +91,7 @@ public void Concrete_classes_should_get_the_same_lifecycle_as_their_interfaces() public void All_implemented_interfaces_should_be_registered() { var serviceCollection = new ServiceCollection(); - serviceCollection.AddTransient(typeof(ComponentWithMultipleInterfaces)); + serviceCollection.AddWithInterfaces(typeof(ComponentWithMultipleInterfaces), ServiceLifetime.Transient); Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ISomeInterface))); Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ISomeOtherInterface))); Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(IYetAnotherInterface))); @@ -99,26 +100,12 @@ public void All_implemented_interfaces_should_be_registered() Assert.AreEqual(1, serviceProvider.GetServices(typeof(IYetAnotherInterface)).Count()); } - [Test] - public void All_implemented_interfaces_should_be_registered_for_func() - { - var serviceCollection = new ServiceCollection(); - serviceCollection.AddTransient(_ => new ComponentWithMultipleInterfaces()); - Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ISomeInterface))); - Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ISomeOtherInterface))); - Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(IYetAnotherInterface))); - - var serviceProvider = serviceCollection.BuildServiceProvider(); - - Assert.AreEqual(1, serviceProvider.GetServices(typeof(IYetAnotherInterface)).Count()); - } - [Test] public void Multiple_implementations_should_be_supported() { var serviceCollection = new ServiceCollection(); - serviceCollection.AddScoped(typeof(SomeClass)); - serviceCollection.AddScoped(typeof(SomeOtherClass)); + serviceCollection.AddWithInterfaces(typeof(SomeClass), ServiceLifetime.Scoped); + serviceCollection.AddWithInterfaces(typeof(SomeOtherClass), ServiceLifetime.Scoped); var serviceProvider = serviceCollection.BuildServiceProvider(); Assert.NotNull(serviceProvider.GetService(typeof(SomeClass))); @@ -151,21 +138,10 @@ public void Given_lookupType_should_be_used_as_service_in_the_registration_when_ public void Generic_interfaces_should_be_registered() { var serviceCollection = new ServiceCollection(); - serviceCollection.AddTransient(typeof(ComponentWithGenericInterface)); + serviceCollection.AddWithInterfaces(typeof(ComponentWithGenericInterface), ServiceLifetime.Transient); Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ISomeGenericInterface))); } - - [Test] - [Ignore("Not sure that we should enforce this")] - public void System_interfaces_should_not_be_auto_registered() - { - var serviceCollection = new ServiceCollection(); - serviceCollection.AddTransient(typeof(ComponentWithSystemInterface)); - - Assert.False(serviceCollection.Any(sd => sd.ServiceType == typeof(IGrouping))); - Assert.False(serviceCollection.Any(sd => sd.ServiceType == typeof(IDisposable))); - } } From 64c97e0f116bb900fd67c915c05bad073e7f05df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Tue, 15 Aug 2023 08:34:59 +0200 Subject: [PATCH 38/51] Complete obsoletion of notifications --- src/NServiceBus.Core/EndpointConfiguration.cs | 8 -------- src/NServiceBus.Core/EndpointCreator.cs | 2 -- src/NServiceBus.Core/Notifications.cs | 11 ----------- src/NServiceBus.Core/obsoletes-v9.cs | 18 ++++++++++++++++++ 4 files changed, 18 insertions(+), 21 deletions(-) delete mode 100644 src/NServiceBus.Core/Notifications.cs diff --git a/src/NServiceBus.Core/EndpointConfiguration.cs b/src/NServiceBus.Core/EndpointConfiguration.cs index 756b67c62e..9919aa9ca3 100644 --- a/src/NServiceBus.Core/EndpointConfiguration.cs +++ b/src/NServiceBus.Core/EndpointConfiguration.cs @@ -39,17 +39,9 @@ public EndpointConfiguration(string endpointName) Settings.Set(new ConsecutiveFailuresConfiguration()); Settings.Set(Pipeline = new PipelineSettings(Settings)); - Notifications = new Notifications(); - Settings.Set(Notifications); - ConventionsBuilder = new ConventionsBuilder(Settings); } - /// - /// Access to the current endpoint . - /// - public Notifications Notifications { get; } - /// /// Access to the pipeline configuration. /// diff --git a/src/NServiceBus.Core/EndpointCreator.cs b/src/NServiceBus.Core/EndpointCreator.cs index f949105f3f..455abe9058 100644 --- a/src/NServiceBus.Core/EndpointCreator.cs +++ b/src/NServiceBus.Core/EndpointCreator.cs @@ -94,8 +94,6 @@ void Configure() sendComponent = SendComponent.Initialize(pipelineSettings, hostingConfiguration, routingComponent, messageMapper); - hostingConfiguration.Services.AddSingleton(_ => settings.Get()); - receiveComponent = ReceiveComponent.Configure( receiveConfiguration, settings.ErrorQueueAddress(), diff --git a/src/NServiceBus.Core/Notifications.cs b/src/NServiceBus.Core/Notifications.cs deleted file mode 100644 index 1c278b3578..0000000000 --- a/src/NServiceBus.Core/Notifications.cs +++ /dev/null @@ -1,11 +0,0 @@ -#nullable enable - -namespace NServiceBus -{ - /// - /// Notifications. - /// - public class Notifications - { - } -} \ No newline at end of file diff --git a/src/NServiceBus.Core/obsoletes-v9.cs b/src/NServiceBus.Core/obsoletes-v9.cs index 384efaded8..97ea382685 100644 --- a/src/NServiceBus.Core/obsoletes-v9.cs +++ b/src/NServiceBus.Core/obsoletes-v9.cs @@ -105,6 +105,24 @@ public static partial class SettingsExtensions RemoveInVersion = "10")] public static string InstanceSpecificQueue(this IReadOnlySettings settings) => throw new NotImplementedException(); } + + [ObsoleteEx( + Message = "Error notification events have been replaced with a Task based API available on the recoverability settings.", + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public class Notifications + { + } + + public partial class EndpointConfiguration + { + + [ObsoleteEx( + Message = "Error notification events have been replaced with a Task based API available on the recoverability settings.", + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public Notifications Notifications { get; } + } } namespace NServiceBus.Features From 7c580d7afe600d8500d06937a23ecff77b70d521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Tue, 15 Aug 2023 08:41:06 +0200 Subject: [PATCH 39/51] Fix ordering of tx scope --- .../TransactionScopes/TransactionScopeUnitOfWorkBehavior.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NServiceBus.Core/UnitOfWork/TransactionScopes/TransactionScopeUnitOfWorkBehavior.cs b/src/NServiceBus.Core/UnitOfWork/TransactionScopes/TransactionScopeUnitOfWorkBehavior.cs index 8281aaba07..5a843ed5e1 100644 --- a/src/NServiceBus.Core/UnitOfWork/TransactionScopes/TransactionScopeUnitOfWorkBehavior.cs +++ b/src/NServiceBus.Core/UnitOfWork/TransactionScopes/TransactionScopeUnitOfWorkBehavior.cs @@ -36,7 +36,6 @@ public Registration(TransactionOptions transactionOptions) : base("HandlerTransa "Makes sure that the handlers gets wrapped in a transaction scope", b => new TransactionScopeUnitOfWorkBehavior(transactionOptions)) { - InsertAfter("ExecuteUnitOfWork"); } } } From 8ec3492e64dbdd81d555fb660cc2533eaa1a5661 Mon Sep 17 00:00:00 2001 From: kentdr Date: Tue, 15 Aug 2023 09:43:53 -0400 Subject: [PATCH 40/51] Update approval files for acceptance tests --- ..._warmed_up.Make_sure_things_are_in_DI.approved.txt | 1 - ...lines_are_built.Should_preserve_order.approved.txt | 11 +++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_endpoint_is_warmed_up.Make_sure_things_are_in_DI.approved.txt b/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_endpoint_is_warmed_up.Make_sure_things_are_in_DI.approved.txt index 2903abdc89..7efa8b8136 100644 --- a/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_endpoint_is_warmed_up.Make_sure_things_are_in_DI.approved.txt +++ b/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_endpoint_is_warmed_up.Make_sure_things_are_in_DI.approved.txt @@ -12,7 +12,6 @@ NServiceBus.Hosting.HostInformation - Singleton NServiceBus.IHandleMessages`1[[NServiceBus.AcceptanceTests.Core.DependencyInjection.When_endpoint_is_warmed_up+SomeMessage, NServiceBus.AcceptanceTests, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null]] - Scoped NServiceBus.IMessageCreator - Singleton NServiceBus.MessageInterfaces.IMessageMapper - Singleton -NServiceBus.Notifications - Singleton NServiceBus.Persistence.ISynchronizedStorageSession - Scoped NServiceBus.Pipeline.IBehavior - Transient NServiceBus.Pipeline.IBehavior`2[[NServiceBus.Pipeline.IIncomingLogicalMessageContext, NServiceBus.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c],[NServiceBus.Pipeline.IIncomingLogicalMessageContext, NServiceBus.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c]] - Transient diff --git a/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_pipelines_are_built.Should_preserve_order.approved.txt b/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_pipelines_are_built.Should_preserve_order.approved.txt index 66cb425418..81ad9dedf9 100644 --- a/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_pipelines_are_built.Should_preserve_order.approved.txt +++ b/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_pipelines_are_built.Should_preserve_order.approved.txt @@ -59,12 +59,11 @@ (IIncomingPhysicalMessageContext context3) => ProcessingStatisticsBehavior.Invoke(context3, (IIncomingPhysicalMessageContext context4) => MutateIncomingTransportMessageBehavior.Invoke(context4, (IIncomingPhysicalMessageContext context5) => SubscriptionReceiverBehavior.Invoke(context5, - (IIncomingPhysicalMessageContext context6) => UnitOfWorkBehavior.Invoke(context6, - (IIncomingPhysicalMessageContext context7) => DeserializeMessageConnector.Invoke(context7, - (IIncomingLogicalMessageContext context8) => MutateIncomingMessageBehavior.Invoke(context8, - (IIncomingLogicalMessageContext context9) => InferredMessageTypeEnricherBehavior.Invoke(context9, - (IIncomingLogicalMessageContext context10) => LoadHandlersConnector.Invoke(context10, - (IInvokeHandlerContext context11) => InvokeHandlerTerminator.Invoke(context11)) + (IIncomingPhysicalMessageContext context6) => DeserializeMessageConnector.Invoke(context6, + (IIncomingLogicalMessageContext context7) => MutateIncomingMessageBehavior.Invoke(context7, + (IIncomingLogicalMessageContext context8) => InferredMessageTypeEnricherBehavior.Invoke(context8, + (IIncomingLogicalMessageContext context9) => LoadHandlersConnector.Invoke(context9, + (IInvokeHandlerContext context10) => InvokeHandlerTerminator.Invoke(context10)) (IRecoverabilityContext context0) => CaptureRecoverabilityActionBehavior.Invoke(context0, (IRecoverabilityContext context1) => RecoverabilityRoutingConnector.Invoke(context1, From 78d3dc6125c3612ab9b56d1de942c313d3e050aa Mon Sep 17 00:00:00 2001 From: kentdr Date: Tue, 15 Aug 2023 11:50:42 -0400 Subject: [PATCH 41/51] Remove exception test with obsolete constructor requirements --- src/NServiceBus.Core.Tests/ExceptionTests.cs | 54 -------------------- 1 file changed, 54 deletions(-) delete mode 100644 src/NServiceBus.Core.Tests/ExceptionTests.cs diff --git a/src/NServiceBus.Core.Tests/ExceptionTests.cs b/src/NServiceBus.Core.Tests/ExceptionTests.cs deleted file mode 100644 index ef921b339f..0000000000 --- a/src/NServiceBus.Core.Tests/ExceptionTests.cs +++ /dev/null @@ -1,54 +0,0 @@ -namespace NServiceBus.Core.Tests -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; - using System.Runtime.Serialization; - using NUnit.Framework; - - [TestFixture] - public class ExceptionTests - { - [Test] - public void VerifyExceptionConventions() - { - foreach (var exceptionType in GetExceptionTypes()) - { - if (exceptionType.GetCustomAttribute() != null) - { - continue; - } - if (!exceptionType.IsPublic) - { - continue; - } - var constructor = exceptionType.GetConstructor(BindingFlags.NonPublic | BindingFlags.CreateInstance | BindingFlags.Instance, null, new[] - { - typeof(SerializationInfo), - typeof(StreamingContext) - }, null); - Assert.IsNotNull(constructor, string.Format("Exception '{0}' should implement 'protected {0}(SerializationInfo info, StreamingContext context){{}}'", exceptionType.Name)); - var serializableAttribute = exceptionType.GetCustomAttributes(typeof(SerializableAttribute), false).FirstOrDefault(); - Assert.IsNotNull(serializableAttribute, $"Exception '{exceptionType.Name}' should have a 'SerializableAttribute'"); - var properties = exceptionType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); - if (properties.Length > 0) - { - var getObjectDataMethod = exceptionType.GetMethod("GetObjectData"); - Assert.IsTrue(getObjectDataMethod.DeclaringType.Name != "Exception", $"Exception '{exceptionType.Name}' has properties and as such should override 'GetObjectData'"); - } - } - } - - static IEnumerable GetExceptionTypes() - { - foreach (var type in typeof(Endpoint).Assembly.GetTypes()) - { - if (typeof(Exception).IsAssignableFrom(type) && type.Namespace.StartsWith("NServiceBus")) - { - yield return type; - } - } - } - } -} \ No newline at end of file From 84c0a3dd5b91ce5615da6f782885997e8d6aa31a Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 15 Aug 2023 12:24:45 -0400 Subject: [PATCH 42/51] Restore NonDurableMessage header value --- src/NServiceBus.Core/Headers.cs | 5 +++++ .../OpenTelemetry/Tracing/ActivityDecorator.cs | 1 + 2 files changed, 6 insertions(+) diff --git a/src/NServiceBus.Core/Headers.cs b/src/NServiceBus.Core/Headers.cs index d7e1c57f27..1cb1e61655 100644 --- a/src/NServiceBus.Core/Headers.cs +++ b/src/NServiceBus.Core/Headers.cs @@ -217,6 +217,11 @@ public static partial class Headers /// public const string MessageIntent = "NServiceBus.MessageIntent"; + /// + /// Indicates that the message was sent as a non-durable message. + /// + public const string NonDurableMessage = "NServiceBus.NonDurableMessage"; + /// /// The time to be received for this message when it was sent the first time. /// When moved to error and audit this header will be preserved to the original TTBR diff --git a/src/NServiceBus.Core/OpenTelemetry/Tracing/ActivityDecorator.cs b/src/NServiceBus.Core/OpenTelemetry/Tracing/ActivityDecorator.cs index 7f06a46c0d..ee2d89190f 100644 --- a/src/NServiceBus.Core/OpenTelemetry/Tracing/ActivityDecorator.cs +++ b/src/NServiceBus.Core/OpenTelemetry/Tracing/ActivityDecorator.cs @@ -54,6 +54,7 @@ public static void PromoteHeadersToTags(Activity activity, Dictionary Date: Tue, 15 Aug 2023 13:45:34 -0400 Subject: [PATCH 43/51] Update PreObsoleteAttribute usage --- .../AcceptanceTestingTransport.cs | 3 --- .../Core/FakeTransport/FakeTransport.cs | 3 --- .../When_using_concurrency_limit.cs | 3 --- .../When_configuring_transport_twice.cs | 4 ---- ...rivenSubscriptionsConfigExtensionsTests.cs | 3 --- src/NServiceBus.Core/PreObsoleteAttribute.cs | 12 ++++++++-- ...earningTransportConfigurationExtensions.cs | 23 +++++++++---------- .../Transports/TransportExtensions.cs | 17 ++++++-------- 8 files changed, 28 insertions(+), 40 deletions(-) diff --git a/src/NServiceBus.AcceptanceTesting/AcceptanceTestingTransport/AcceptanceTestingTransport.cs b/src/NServiceBus.AcceptanceTesting/AcceptanceTestingTransport/AcceptanceTestingTransport.cs index 2eb6e96aa3..703eb84847 100644 --- a/src/NServiceBus.AcceptanceTesting/AcceptanceTestingTransport/AcceptanceTestingTransport.cs +++ b/src/NServiceBus.AcceptanceTesting/AcceptanceTestingTransport/AcceptanceTestingTransport.cs @@ -27,10 +27,7 @@ public override async Task Initialize(HostSettings host return infrastructure; } - [Obsolete("Obsolete marker to make the code compile", false)] -#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member public override string ToTransportAddress(QueueAddress address) -#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member { var baseAddress = address.BaseAddress; ThrowForBadPath(baseAddress, "endpoint name"); diff --git a/src/NServiceBus.AcceptanceTests/Core/FakeTransport/FakeTransport.cs b/src/NServiceBus.AcceptanceTests/Core/FakeTransport/FakeTransport.cs index 6019a6b82d..f662e6dd52 100644 --- a/src/NServiceBus.AcceptanceTests/Core/FakeTransport/FakeTransport.cs +++ b/src/NServiceBus.AcceptanceTests/Core/FakeTransport/FakeTransport.cs @@ -30,10 +30,7 @@ public override Task Initialize(HostSettings hostSettin return Task.FromResult(infrastructure); } - [Obsolete("Obsolete marker to make the code compile", false)] -#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member public override string ToTransportAddress(QueueAddress address) -#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member { return new LearningTransport().ToTransportAddress(address); } diff --git a/src/NServiceBus.AcceptanceTests/Core/FakeTransport/ProcessingOptimizations/When_using_concurrency_limit.cs b/src/NServiceBus.AcceptanceTests/Core/FakeTransport/ProcessingOptimizations/When_using_concurrency_limit.cs index 8c678a3ce4..93d1f5a2b2 100644 --- a/src/NServiceBus.AcceptanceTests/Core/FakeTransport/ProcessingOptimizations/When_using_concurrency_limit.cs +++ b/src/NServiceBus.AcceptanceTests/Core/FakeTransport/ProcessingOptimizations/When_using_concurrency_limit.cs @@ -92,10 +92,7 @@ public override Task Initialize(HostSettings hostSettin return Task.FromResult(new FakeTransportInfrastructure(receivers)); } - [Obsolete("Obsolete marker to make the code compile", false)] -#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member public override string ToTransportAddress(QueueAddress address) -#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member { return address.ToString(); } diff --git a/src/NServiceBus.Core.Tests/Config/When_configuring_transport_twice.cs b/src/NServiceBus.Core.Tests/Config/When_configuring_transport_twice.cs index 6b01232504..df72c58186 100644 --- a/src/NServiceBus.Core.Tests/Config/When_configuring_transport_twice.cs +++ b/src/NServiceBus.Core.Tests/Config/When_configuring_transport_twice.cs @@ -1,6 +1,5 @@ namespace NServiceBus.Core.Tests.Config; -using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -90,10 +89,7 @@ public Task Initialize(PushRuntimeSettings limitations, OnMessage onMessage, OnE public override string ToTransportAddress(QueueAddress address) => address.BaseAddress; } - [Obsolete("Obsolete marker to make the code compile", false)] -#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member public override string ToTransportAddress(QueueAddress address) => address.BaseAddress; -#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member public override IReadOnlyCollection GetSupportedTransactionModes() => new[] { diff --git a/src/NServiceBus.Core.Tests/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptionsConfigExtensionsTests.cs b/src/NServiceBus.Core.Tests/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptionsConfigExtensionsTests.cs index e7901c5479..2f1a581781 100644 --- a/src/NServiceBus.Core.Tests/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptionsConfigExtensionsTests.cs +++ b/src/NServiceBus.Core.Tests/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptionsConfigExtensionsTests.cs @@ -171,10 +171,7 @@ public override Task Initialize(HostSettings hostSettin throw new NotImplementedException(); } - [Obsolete("Obsolete marker to make the code compile", false)] -#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member public override string ToTransportAddress(QueueAddress address) -#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member { throw new NotImplementedException(); } diff --git a/src/NServiceBus.Core/PreObsoleteAttribute.cs b/src/NServiceBus.Core/PreObsoleteAttribute.cs index bfaf7d261a..c36af5b1b3 100644 --- a/src/NServiceBus.Core/PreObsoleteAttribute.cs +++ b/src/NServiceBus.Core/PreObsoleteAttribute.cs @@ -5,12 +5,20 @@ /// /// Meant for staging future obsoletes. Mimics the structure of . /// + [AttributeUsage(AttributeTargets.All)] sealed class PreObsoleteAttribute : Attribute { - public string RemoveInVersion { get; set; } - public string TreatAsErrorFromVersion { get; set; } + public PreObsoleteAttribute(string contextUrl) + { + ContextUrl = contextUrl; + } + + public string ContextUrl { get; } + public string ReplacementTypeOrMember { get; set; } + public string Message { get; set; } + public string Note { get; set; } } } diff --git a/src/NServiceBus.Core/Transports/Learning/LearningTransportConfigurationExtensions.cs b/src/NServiceBus.Core/Transports/Learning/LearningTransportConfigurationExtensions.cs index c2063e3451..e1cdc5e35b 100644 --- a/src/NServiceBus.Core/Transports/Learning/LearningTransportConfigurationExtensions.cs +++ b/src/NServiceBus.Core/Transports/Learning/LearningTransportConfigurationExtensions.cs @@ -3,15 +3,16 @@ /// /// Configuration options for the learning transport. /// + [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", + Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public static class LearningTransportConfigurationExtensions { /// /// Configures NServiceBus to use the given transport. /// - [PreObsolete( - RemoveInVersion = "10", - TreatAsErrorFromVersion = "9", - ReplacementTypeOrMember = "EndpointConfiguration.UseTransport(TransportDefinition)")] + [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", + ReplacementTypeOrMember = "EndpointConfiguration.UseTransport(TransportDefinition)", + Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public static TransportExtensions UseTransport(this EndpointConfiguration config) where T : LearningTransport { @@ -27,10 +28,9 @@ public static TransportExtensions UseTransport(this Endpoi /// /// Configures the location where message files are stored. /// - [PreObsolete( - RemoveInVersion = "10", - TreatAsErrorFromVersion = "9", - ReplacementTypeOrMember = "Use LearningTransport.StorageDirectory")] + [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", + ReplacementTypeOrMember = "Use LearningTransport.StorageDirectory", + Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public static void StorageDirectory(this TransportExtensions transportExtensions, string path) { transportExtensions.Transport.StorageDirectory = path; @@ -39,10 +39,9 @@ public static void StorageDirectory(this TransportExtensions /// /// Allows messages of any size to be sent. /// - [PreObsolete( - RemoveInVersion = "10", - TreatAsErrorFromVersion = "9", - ReplacementTypeOrMember = "Use LearningTransport.RestrictPayloadSize")] + [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", + ReplacementTypeOrMember = "Use LearningTransport.RestrictPayloadSize", + Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public static void NoPayloadSizeRestriction(this TransportExtensions transportExtensions) { transportExtensions.Transport.RestrictPayloadSize = false; diff --git a/src/NServiceBus.Core/Transports/TransportExtensions.cs b/src/NServiceBus.Core/Transports/TransportExtensions.cs index bd75aaf64c..3339fe6585 100644 --- a/src/NServiceBus.Core/Transports/TransportExtensions.cs +++ b/src/NServiceBus.Core/Transports/TransportExtensions.cs @@ -6,10 +6,9 @@ /// This class provides implementers of transports with an extension mechanism for custom settings via extension methods. /// /// The transport definition e.g. , etc. - [PreObsolete( + [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", Message = "Configure the transport via the TransportDefinition instance's properties", - TreatAsErrorFromVersion = "9", - RemoveInVersion = "10")] + Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public class TransportExtensions where T : TransportDefinition { /// @@ -31,19 +30,17 @@ public TransportExtensions(T transport, RoutingSettings routing) /// /// Routing configuration. /// - [PreObsolete( + [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", ReplacementTypeOrMember = "Use EndpointConfiguration.UseTransport() to access routing settings", - TreatAsErrorFromVersion = "9", - RemoveInVersion = "10")] + Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public RoutingSettings Routing() => routing; /// /// Configures the transport to use a specific transaction mode. /// - [PreObsolete( - TreatAsErrorFromVersion = "8.0", - RemoveInVersion = "9.0", - ReplacementTypeOrMember = "TransportDefinition.TransportTransactionMode")] + [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", + ReplacementTypeOrMember = "TransportDefinition.TransportTransactionMode", + Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public TransportExtensions Transactions(TransportTransactionMode transportTransactionMode) { Transport.TransportTransactionMode = transportTransactionMode; From b2419f9e24ab22407725dc389e605a6760f7a1f2 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 15 Aug 2023 15:02:40 -0400 Subject: [PATCH 44/51] Clean up TransportDefinition.ToTransportAddress --- .../AcceptanceTestingTransport.cs | 48 ++----------------- .../Core/FakeTransport/FakeTransport.cs | 8 ++-- .../When_using_concurrency_limit.cs | 8 ++-- .../When_configuring_transport_twice.cs | 6 ++- ...rivenSubscriptionsConfigExtensionsTests.cs | 8 ++-- src/NServiceBus.Core/NServiceBus.Core.csproj | 2 +- .../Transports/Learning/LearningTransport.cs | 29 +---------- src/NServiceBus.Core/obsoletes-v9.cs | 8 ++++ 8 files changed, 32 insertions(+), 85 deletions(-) diff --git a/src/NServiceBus.AcceptanceTesting/AcceptanceTestingTransport/AcceptanceTestingTransport.cs b/src/NServiceBus.AcceptanceTesting/AcceptanceTestingTransport/AcceptanceTestingTransport.cs index 703eb84847..be27ce1957 100644 --- a/src/NServiceBus.AcceptanceTesting/AcceptanceTestingTransport/AcceptanceTestingTransport.cs +++ b/src/NServiceBus.AcceptanceTesting/AcceptanceTestingTransport/AcceptanceTestingTransport.cs @@ -2,7 +2,6 @@ { using System; using System.Collections.Generic; - using System.IO; using System.Threading; using System.Threading.Tasks; using AcceptanceTesting; @@ -27,31 +26,10 @@ public override async Task Initialize(HostSettings host return infrastructure; } - public override string ToTransportAddress(QueueAddress address) - { - var baseAddress = address.BaseAddress; - ThrowForBadPath(baseAddress, "endpoint name"); - - var discriminator = address.Discriminator; - - if (!string.IsNullOrEmpty(discriminator)) - { - ThrowForBadPath(discriminator, "endpoint discriminator"); - - baseAddress += "-" + discriminator; - } - - var qualifier = address.Qualifier; - - if (!string.IsNullOrEmpty(qualifier)) - { - ThrowForBadPath(qualifier, "address qualifier"); - - baseAddress += "-" + qualifier; - } - - return baseAddress; - } + [Obsolete("This should be removed when TransportDefinition.ToTransportAddress is removed in v10.", true)] +#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member + public override string ToTransportAddress(QueueAddress address) => throw new NotImplementedException(); +#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member public override IReadOnlyCollection GetSupportedTransactionModes() { @@ -64,6 +42,7 @@ public override IReadOnlyCollection GetSupportedTransa } string storageLocation; + public string StorageLocation { get => storageLocation; @@ -74,22 +53,5 @@ public string StorageLocation storageLocation = value; } } - - static void ThrowForBadPath(string value, string valueName) - { - var invalidPathChars = Path.GetInvalidPathChars(); - - if (string.IsNullOrEmpty(value)) - { - return; - } - - if (value.IndexOfAny(invalidPathChars) < 0) - { - return; - } - - throw new Exception($"The value for '{valueName}' has illegal path characters. Provided value: {value}. Must not contain any of {string.Join(", ", invalidPathChars)}."); - } } } \ No newline at end of file diff --git a/src/NServiceBus.AcceptanceTests/Core/FakeTransport/FakeTransport.cs b/src/NServiceBus.AcceptanceTests/Core/FakeTransport/FakeTransport.cs index f662e6dd52..a2cf4bad74 100644 --- a/src/NServiceBus.AcceptanceTests/Core/FakeTransport/FakeTransport.cs +++ b/src/NServiceBus.AcceptanceTests/Core/FakeTransport/FakeTransport.cs @@ -30,10 +30,10 @@ public override Task Initialize(HostSettings hostSettin return Task.FromResult(infrastructure); } - public override string ToTransportAddress(QueueAddress address) - { - return new LearningTransport().ToTransportAddress(address); - } + [Obsolete("This should be removed when TransportDefinition.ToTransportAddress is removed in v10.", true)] +#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member + public override string ToTransportAddress(QueueAddress address) => throw new NotImplementedException(); +#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member public override IReadOnlyCollection GetSupportedTransactionModes() { diff --git a/src/NServiceBus.AcceptanceTests/Core/FakeTransport/ProcessingOptimizations/When_using_concurrency_limit.cs b/src/NServiceBus.AcceptanceTests/Core/FakeTransport/ProcessingOptimizations/When_using_concurrency_limit.cs index 93d1f5a2b2..0acc1e4a24 100644 --- a/src/NServiceBus.AcceptanceTests/Core/FakeTransport/ProcessingOptimizations/When_using_concurrency_limit.cs +++ b/src/NServiceBus.AcceptanceTests/Core/FakeTransport/ProcessingOptimizations/When_using_concurrency_limit.cs @@ -92,10 +92,10 @@ public override Task Initialize(HostSettings hostSettin return Task.FromResult(new FakeTransportInfrastructure(receivers)); } - public override string ToTransportAddress(QueueAddress address) - { - return address.ToString(); - } + [Obsolete("This should be removed when TransportDefinition.ToTransportAddress is removed in v10.", true)] +#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member + public override string ToTransportAddress(QueueAddress address) => throw new NotImplementedException(); +#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member public override IReadOnlyCollection GetSupportedTransactionModes() { diff --git a/src/NServiceBus.Core.Tests/Config/When_configuring_transport_twice.cs b/src/NServiceBus.Core.Tests/Config/When_configuring_transport_twice.cs index df72c58186..af3ca249b9 100644 --- a/src/NServiceBus.Core.Tests/Config/When_configuring_transport_twice.cs +++ b/src/NServiceBus.Core.Tests/Config/When_configuring_transport_twice.cs @@ -1,5 +1,6 @@ namespace NServiceBus.Core.Tests.Config; +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -89,7 +90,10 @@ public Task Initialize(PushRuntimeSettings limitations, OnMessage onMessage, OnE public override string ToTransportAddress(QueueAddress address) => address.BaseAddress; } - public override string ToTransportAddress(QueueAddress address) => address.BaseAddress; + [Obsolete("This should be removed when TransportDefinition.ToTransportAddress is removed in v10.", true)] +#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member + public override string ToTransportAddress(QueueAddress address) => throw new NotImplementedException(); +#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member public override IReadOnlyCollection GetSupportedTransactionModes() => new[] { diff --git a/src/NServiceBus.Core.Tests/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptionsConfigExtensionsTests.cs b/src/NServiceBus.Core.Tests/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptionsConfigExtensionsTests.cs index 2f1a581781..0758a6e45a 100644 --- a/src/NServiceBus.Core.Tests/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptionsConfigExtensionsTests.cs +++ b/src/NServiceBus.Core.Tests/Routing/MessageDrivenSubscriptions/MessageDrivenSubscriptionsConfigExtensionsTests.cs @@ -171,10 +171,10 @@ public override Task Initialize(HostSettings hostSettin throw new NotImplementedException(); } - public override string ToTransportAddress(QueueAddress address) - { - throw new NotImplementedException(); - } + [Obsolete("This should be removed when TransportDefinition.ToTransportAddress is removed in v10.", true)] +#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member + public override string ToTransportAddress(QueueAddress address) => throw new NotImplementedException(); +#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member public override IReadOnlyCollection GetSupportedTransactionModes() { diff --git a/src/NServiceBus.Core/NServiceBus.Core.csproj b/src/NServiceBus.Core/NServiceBus.Core.csproj index f958cb799f..374a683a2d 100644 --- a/src/NServiceBus.Core/NServiceBus.Core.csproj +++ b/src/NServiceBus.Core/NServiceBus.Core.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/NServiceBus.Core/Transports/Learning/LearningTransport.cs b/src/NServiceBus.Core/Transports/Learning/LearningTransport.cs index 0016cd017a..6e80d29749 100644 --- a/src/NServiceBus.Core/Transports/Learning/LearningTransport.cs +++ b/src/NServiceBus.Core/Transports/Learning/LearningTransport.cs @@ -8,7 +8,7 @@ /// /// A transport optimized for development and learning use. DO NOT use in production. /// - public class LearningTransport : TransportDefinition + public partial class LearningTransport : TransportDefinition { /// /// Creates a new instance of a learning transport. @@ -35,33 +35,6 @@ public override Task Initialize(HostSettings hostSettin return Task.FromResult(learningTransportInfrastructure); } - /// - public override string ToTransportAddress(QueueAddress queueAddress) - { - var address = queueAddress.BaseAddress; - PathChecker.ThrowForBadPath(address, "endpoint name"); - - var discriminator = queueAddress.Discriminator; - - if (!string.IsNullOrEmpty(discriminator)) - { - PathChecker.ThrowForBadPath(discriminator, "endpoint discriminator"); - - address += "-" + discriminator; - } - - var qualifier = queueAddress.Qualifier; - - if (!string.IsNullOrEmpty(qualifier)) - { - PathChecker.ThrowForBadPath(qualifier, "address qualifier"); - - address += "-" + qualifier; - } - - return address; - } - /// public override IReadOnlyCollection GetSupportedTransactionModes() { diff --git a/src/NServiceBus.Core/obsoletes-v9.cs b/src/NServiceBus.Core/obsoletes-v9.cs index 97ea382685..9459d606c7 100644 --- a/src/NServiceBus.Core/obsoletes-v9.cs +++ b/src/NServiceBus.Core/obsoletes-v9.cs @@ -35,6 +35,14 @@ public static partial class ImmediateDispatchOptionExtensions TreatAsErrorFromVersion = "9.0")] public static bool RequiredImmediateDispatch(this ExtendableOptions options) => throw new NotImplementedException(); } + public partial class LearningTransport + { + [ObsoleteEx( + Message = "Inject the ITransportAddressResolver type to access the address translation mechanism at runtime. See the NServiceBus version 8 upgrade guide for further details.", + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public override string ToTransportAddress(QueueAddress queueAddress) => throw new NotImplementedException(); + } [ObsoleteEx( Message = "Use methods on IServiceCollection instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information.", From 01ee2e1f3ab02240cb6002df24be575bf09c32b3 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 15 Aug 2023 16:00:31 -0400 Subject: [PATCH 45/51] Tweak Notifications obsoletes --- src/NServiceBus.Core/obsoletes-v9.cs | 34 +++++++++++++--------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/NServiceBus.Core/obsoletes-v9.cs b/src/NServiceBus.Core/obsoletes-v9.cs index 9459d606c7..4795a9f950 100644 --- a/src/NServiceBus.Core/obsoletes-v9.cs +++ b/src/NServiceBus.Core/obsoletes-v9.cs @@ -27,6 +27,16 @@ public static partial class ConnectorContextExtensions public static IAuditContext CreateAuditContext(this ForkConnector forkConnector, OutgoingMessage message, string auditAddress, IIncomingPhysicalMessageContext sourceContext) => throw new NotImplementedException(); } + public partial class EndpointConfiguration + { + + [ObsoleteEx( + Message = "Error notification events have been replaced with a Task-based API available on the recoverability settings.", + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public Notifications Notifications { get; } + } + public static partial class ImmediateDispatchOptionExtensions { [ObsoleteEx( @@ -44,6 +54,12 @@ public partial class LearningTransport public override string ToTransportAddress(QueueAddress queueAddress) => throw new NotImplementedException(); } + [ObsoleteEx( + Message = "Error notification events have been replaced with a Task-based API available on the recoverability settings.", + TreatAsErrorFromVersion = "9", + RemoveInVersion = "10")] + public class Notifications { } + [ObsoleteEx( Message = "Use methods on IServiceCollection instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information.", TreatAsErrorFromVersion = "9.0", @@ -113,24 +129,6 @@ public static partial class SettingsExtensions RemoveInVersion = "10")] public static string InstanceSpecificQueue(this IReadOnlySettings settings) => throw new NotImplementedException(); } - - [ObsoleteEx( - Message = "Error notification events have been replaced with a Task based API available on the recoverability settings.", - TreatAsErrorFromVersion = "9", - RemoveInVersion = "10")] - public class Notifications - { - } - - public partial class EndpointConfiguration - { - - [ObsoleteEx( - Message = "Error notification events have been replaced with a Task based API available on the recoverability settings.", - TreatAsErrorFromVersion = "9", - RemoveInVersion = "10")] - public Notifications Notifications { get; } - } } namespace NServiceBus.Features From 7c736e02dad98fae9e45834678ced8bfe0288c47 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 15 Aug 2023 16:22:17 -0400 Subject: [PATCH 46/51] Rename internal class to fix test --- src/NServiceBus.Core/Pipeline/PipelineComponent.cs | 1 - src/NServiceBus.Core/Pipeline/RegisterStep.cs | 1 - src/NServiceBus.Core/Receiving/ReceiveComponent.cs | 1 - src/NServiceBus.Core/Sagas/Sagas.cs | 1 - src/NServiceBus.Core/ServiceCollectionExtensions.cs | 7 ++++--- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/NServiceBus.Core/Pipeline/PipelineComponent.cs b/src/NServiceBus.Core/Pipeline/PipelineComponent.cs index 3ee23a7e47..3749e2abed 100644 --- a/src/NServiceBus.Core/Pipeline/PipelineComponent.cs +++ b/src/NServiceBus.Core/Pipeline/PipelineComponent.cs @@ -2,7 +2,6 @@ namespace NServiceBus { using System; using Microsoft.Extensions.DependencyInjection; - using ObjectBuilder; using Pipeline; class PipelineComponent diff --git a/src/NServiceBus.Core/Pipeline/RegisterStep.cs b/src/NServiceBus.Core/Pipeline/RegisterStep.cs index 7e968e7158..b3015dfdbf 100644 --- a/src/NServiceBus.Core/Pipeline/RegisterStep.cs +++ b/src/NServiceBus.Core/Pipeline/RegisterStep.cs @@ -4,7 +4,6 @@ namespace NServiceBus.Pipeline using System.Collections.Generic; using System.Diagnostics; using Microsoft.Extensions.DependencyInjection; - using NServiceBus.ObjectBuilder; /// /// Base class to do an advance registration of a step. diff --git a/src/NServiceBus.Core/Receiving/ReceiveComponent.cs b/src/NServiceBus.Core/Receiving/ReceiveComponent.cs index 8d76c6f363..7ec0baa10a 100644 --- a/src/NServiceBus.Core/Receiving/ReceiveComponent.cs +++ b/src/NServiceBus.Core/Receiving/ReceiveComponent.cs @@ -7,7 +7,6 @@ namespace NServiceBus using System.Threading.Tasks; using Logging; using Microsoft.Extensions.DependencyInjection; - using NServiceBus.ObjectBuilder; using Outbox; using Pipeline; using Transport; diff --git a/src/NServiceBus.Core/Sagas/Sagas.cs b/src/NServiceBus.Core/Sagas/Sagas.cs index caaad43627..ada1b27ea3 100644 --- a/src/NServiceBus.Core/Sagas/Sagas.cs +++ b/src/NServiceBus.Core/Sagas/Sagas.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.DependencyInjection; - using NServiceBus.ObjectBuilder; using NServiceBus.Sagas; /// diff --git a/src/NServiceBus.Core/ServiceCollectionExtensions.cs b/src/NServiceBus.Core/ServiceCollectionExtensions.cs index eeb3437df2..4af93f30db 100644 --- a/src/NServiceBus.Core/ServiceCollectionExtensions.cs +++ b/src/NServiceBus.Core/ServiceCollectionExtensions.cs @@ -1,9 +1,10 @@ -namespace NServiceBus.ObjectBuilder +namespace NServiceBus { - using Microsoft.Extensions.DependencyInjection; using System; + using Microsoft.Extensions.DependencyInjection; - static class ServiceCollectionExtensions + // Rename this class to ServiceCollectionExtensions when public version is removed from obsoletes. + static class ServiceCollectionExtensionsInternal { public static void AddWithInterfaces(this IServiceCollection serviceCollection, Type serviceType, ServiceLifetime serviceLifetime) { From 41e961b16e8004b0f44eb79ebfcd5b2848b68228 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 15 Aug 2023 16:47:01 -0400 Subject: [PATCH 47/51] Update approval files --- .../API/NullableAnnotations.cs | 5 +- ...IApprovals.ApproveNServiceBus.approved.txt | 807 ++---------------- ...fy_promotable_headers.ignored.approved.txt | 1 - ...y_promotable_headers.promoted.approved.txt | 2 +- ...otations.ApproveNullableTypes.approved.txt | 2 - 5 files changed, 50 insertions(+), 767 deletions(-) diff --git a/src/NServiceBus.Core.Tests/API/NullableAnnotations.cs b/src/NServiceBus.Core.Tests/API/NullableAnnotations.cs index 49434e540b..d1e26cda57 100644 --- a/src/NServiceBus.Core.Tests/API/NullableAnnotations.cs +++ b/src/NServiceBus.Core.Tests/API/NullableAnnotations.cs @@ -9,13 +9,10 @@ using NUnit.Framework; using Particular.Approvals; - - [TestFixture] public class NullableAnnotations { - // Only available with net6.0+, implementation for net472 not worth it - NullabilityInfoContext nullContext = new NullabilityInfoContext(); + readonly NullabilityInfoContext nullContext = new(); [Test] public void ApproveNullableTypes() diff --git a/src/NServiceBus.Core.Tests/ApprovalFiles/APIApprovals.ApproveNServiceBus.approved.txt b/src/NServiceBus.Core.Tests/ApprovalFiles/APIApprovals.ApproveNServiceBus.approved.txt index 12bd14ee08..4a6cd6e26d 100644 --- a/src/NServiceBus.Core.Tests/ApprovalFiles/APIApprovals.ApproveNServiceBus.approved.txt +++ b/src/NServiceBus.Core.Tests/ApprovalFiles/APIApprovals.ApproveNServiceBus.approved.txt @@ -49,25 +49,12 @@ namespace NServiceBus public static void DoNotEnforceBestPractices(this NServiceBus.Pipeline.IUnsubscribeContext context) { } public static bool IgnoredBestPractices(this NServiceBus.Extensibility.ExtendableOptions options) { } } - [System.Obsolete("The timeout manager has been removed in favor of native delayed delivery support " + - "provided by transports. See the upgrade guide for more details. Will be removed " + - "in version 9.0.0.", true)] - public static class ConfigurationTimeoutExtensions - { - [System.Obsolete("The timeout manager has been removed. See the upgrade guide for more details. The" + - " member currently throws a NotImplementedException. Will be removed in version 9" + - ".0.0.", true)] - public static void TimeToWaitBeforeTriggeringCriticalErrorOnTimeoutOutages(this NServiceBus.EndpointConfiguration config, System.TimeSpan timeToWait) { } - } public static class ConfigureAudit { public static void AuditProcessedMessagesTo(this NServiceBus.EndpointConfiguration config, string auditQueue, System.TimeSpan? timeToBeReceived = default) { } } public static class ConfigureCriticalErrorAction { - [System.Obsolete("Use the overload that accepts a delegate with a cancellation token. The member cu" + - "rrently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public static void DefineCriticalErrorAction(this NServiceBus.EndpointConfiguration endpointConfiguration, System.Func onCriticalError) { } public static void DefineCriticalErrorAction(this NServiceBus.EndpointConfiguration endpointConfiguration, System.Func onCriticalError) { } } public static class ConfigureError @@ -78,12 +65,6 @@ namespace NServiceBus { public static NServiceBus.DataBus.DataBusExtensions BasePath(this NServiceBus.DataBus.DataBusExtensions config, string basePath) { } } - [System.Obsolete("Will be removed in version 9.0.0.", true)] - public static class ConfigureForwarding - { - [System.Obsolete(@"Message forwarding is no longer supported natively by NServiceBus. For auditing messages, use endpointConfiguration.AuditProcessedMessagesTo(address). If true message forwarding capabilities are needed, use a custom pipeline behavior, an example of which can be found in the documentation. The member currently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public static void ForwardReceivedMessagesTo(this NServiceBus.EndpointConfiguration config, string address) { } - } public static class ConfigureLicenseExtensions { public static void License(this NServiceBus.EndpointConfiguration config, string licenseText) { } @@ -93,31 +74,14 @@ namespace NServiceBus { public static void PurgeOnStartup(this NServiceBus.EndpointConfiguration config, bool value) { } } - [System.Obsolete("Transport infrastructure setup control is not based on the installer configuratio" + - "n. Will be removed in version 9.0.0.", true)] - public static class ConfigureQueueCreation - { - [System.Obsolete("Transport infrastructure setup control is not based on the installer configuratio" + - "n. The member currently throws a NotImplementedException. Will be removed in ver" + - "sion 9.0.0.", true)] - public static bool CreateQueues(this NServiceBus.Settings.ReadOnlySettings settings) { } - [System.Obsolete("Transport infrastructure setup control is not based on the installer configuratio" + - "n. The member currently throws a NotImplementedException. Will be removed in ver" + - "sion 9.0.0.", true)] - public static void DoNotCreateQueues(this NServiceBus.EndpointConfiguration config) { } - } public static class ConnectorContextExtensions { - [System.Obsolete(@"Use `CreateAuditContext(this ForkConnector forkConnector, OutgoingMessage message, string auditAddress, TimeSpan? timeToBeReceived, IIncomingPhysicalMessageContext sourceContext)` instead. Will be treated as an error from version 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete(@"Use `CreateAuditContext(this ForkConnector forkConnector, OutgoingMessage message, string auditAddress, TimeSpan? timeToBeReceived, IIncomingPhysicalMessageContext sourceContext)` instead. The member currently throws a NotImplementedException. Will be removed in version 10.0.0.", true)] public static NServiceBus.Pipeline.IAuditContext CreateAuditContext(this NServiceBus.Pipeline.ForkConnector forkConnector, NServiceBus.Transport.OutgoingMessage message, string auditAddress, NServiceBus.Pipeline.IIncomingPhysicalMessageContext sourceContext) { } public static NServiceBus.Pipeline.IAuditContext CreateAuditContext(this NServiceBus.Pipeline.ForkConnector forkConnector, NServiceBus.Transport.OutgoingMessage message, string auditAddress, System.TimeSpan? timeToBeReceived, NServiceBus.Pipeline.IIncomingPhysicalMessageContext sourceContext) { } public static NServiceBus.Pipeline.IBatchDispatchContext CreateBatchDispatchContext(this NServiceBus.Pipeline.StageForkConnector stageForkConnector, System.Collections.Generic.IReadOnlyCollection transportOperations, NServiceBus.Pipeline.IIncomingPhysicalMessageContext sourceContext) { } public static NServiceBus.Pipeline.IDispatchContext CreateDispatchContext(this NServiceBus.Pipeline.StageConnector stageConnector, System.Collections.Generic.IReadOnlyCollection transportOperations, NServiceBus.Pipeline.IBatchDispatchContext sourceContext) { } public static NServiceBus.Pipeline.IDispatchContext CreateDispatchContext(this NServiceBus.Pipeline.StageConnector stageConnector, System.Collections.Generic.IReadOnlyCollection transportOperations, NServiceBus.Pipeline.IRoutingContext sourceContext) { } - [System.Obsolete("Message forwarding is no longer supported, but can be implemented as a custom pip" + - "eline behavior. The member currently throws a NotImplementedException. Will be r" + - "emoved in version 9.0.0.", true)] - public static NServiceBus.Pipeline.IForwardingContext CreateForwardingContext(this NServiceBus.Pipeline.ForkConnector forwardingContext, NServiceBus.Transport.OutgoingMessage message, string forwardingAddress, NServiceBus.Pipeline.IIncomingPhysicalMessageContext sourceContext) { } public static NServiceBus.Pipeline.IIncomingLogicalMessageContext CreateIncomingLogicalMessageContext(this NServiceBus.Pipeline.StageConnector stageConnector, NServiceBus.Pipeline.LogicalMessage logicalMessage, NServiceBus.Pipeline.IIncomingPhysicalMessageContext sourceContext) { } public static NServiceBus.Pipeline.IIncomingPhysicalMessageContext CreateIncomingPhysicalMessageContext(this NServiceBus.Pipeline.StageConnector stageConnector, NServiceBus.Transport.IncomingMessage incomingMessage, NServiceBus.Pipeline.ITransportReceiveContext sourceContext) { } public static NServiceBus.Pipeline.IIncomingPhysicalMessageContext CreateIncomingPhysicalMessageContext(this NServiceBus.Pipeline.StageForkConnector stageForkConnector, NServiceBus.Transport.IncomingMessage incomingMessage, NServiceBus.Pipeline.ITransportReceiveContext sourceContext) { } @@ -128,7 +92,6 @@ namespace NServiceBus public static NServiceBus.Pipeline.IOutgoingPhysicalMessageContext CreateOutgoingPhysicalMessageContext(this NServiceBus.Pipeline.StageConnector stageConnector, System.ReadOnlyMemory messageBody, System.Collections.Generic.IReadOnlyCollection routingStrategies, NServiceBus.Pipeline.IOutgoingLogicalMessageContext sourceContext) { } public static NServiceBus.Pipeline.IRoutingContext CreateRoutingContext(this NServiceBus.Pipeline.ForkConnector forkConnector, NServiceBus.Transport.OutgoingMessage outgoingMessage, string localAddress, NServiceBus.Pipeline.ITransportReceiveContext sourceContext) { } public static NServiceBus.Pipeline.IRoutingContext CreateRoutingContext(this NServiceBus.Pipeline.StageConnector stageConnector, NServiceBus.Transport.OutgoingMessage outgoingMessage, NServiceBus.Routing.RoutingStrategy routingStrategy, NServiceBus.Pipeline.IAuditContext sourceContext) { } - public static NServiceBus.Pipeline.IRoutingContext CreateRoutingContext(this NServiceBus.Pipeline.StageConnector stageConnector, NServiceBus.Transport.OutgoingMessage outgoingMessage, NServiceBus.Routing.RoutingStrategy routingStrategy, NServiceBus.Pipeline.IForwardingContext sourceContext) { } public static NServiceBus.Pipeline.IRoutingContext CreateRoutingContext(this NServiceBus.Pipeline.StageConnector stageConnector, NServiceBus.Transport.OutgoingMessage outgoingMessage, System.Collections.Generic.IReadOnlyCollection routingStrategies, NServiceBus.Pipeline.IOutgoingPhysicalMessageContext sourceContext) { } } public abstract class ContainSagaData : NServiceBus.IContainSagaData @@ -186,24 +149,17 @@ namespace NServiceBus } public class CriticalError { - [System.Obsolete("Use the overload that accepts a delegate with a cancellation token. The member cu" + - "rrently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public CriticalError(System.Func onCriticalErrorAction) { } public CriticalError(System.Func onCriticalErrorAction) { } public virtual void Raise(string errorMessage, System.Exception exception, System.Threading.CancellationToken cancellationToken = default) { } } public class CriticalErrorContext : NServiceBus.ICriticalErrorContext { - [System.Obsolete("Use the overload that accepts a delegate with a cancellation token. The member cu" + - "rrently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public CriticalErrorContext(System.Func stop, string error, System.Exception exception) { } public CriticalErrorContext(System.Func stop, string error, System.Exception exception) { } public string Error { get; } public System.Exception Exception { get; } public System.Func Stop { get; } } - [System.Serializable] - public class DataBusProperty : NServiceBus.IDataBusProperty, System.Runtime.Serialization.ISerializable + public class DataBusProperty : NServiceBus.IDataBusProperty where T : class { public DataBusProperty() { } @@ -217,22 +173,6 @@ namespace NServiceBus public object GetValue() { } public void SetValue(object valueToSet) { } } - [System.Obsolete("Public APIs no longer use DateTime but DateTimeOffset. See the upgrade guide for " + - "more details. Use `NServiceBus.DateTimeOffsetExtensions` instead. Will be remove" + - "d in version 9.0.0.", true)] - public static class DateTimeExtensions - { - [System.Obsolete("Public APIs no longer use DateTime but DateTimeOffset. See the upgrade guide for " + - "more details. Use `NServiceBus.DateTimeOffsetHelper.ToDateTimeOffset` instead. T" + - "he member currently throws a NotImplementedException. Will be removed in version" + - " 9.0.0.", true)] - public static System.DateTime ToUtcDateTime(string wireFormattedString) { } - [System.Obsolete("Public APIs no longer use DateTime but DateTimeOffset. See the upgrade guide for " + - "more details. Use `NServiceBus.DateTimeOffsetHelper.ToWireFormattedString` inste" + - "ad. The member currently throws a NotImplementedException. Will be removed in ve" + - "rsion 9.0.0.", true)] - public static string ToWireFormattedString(System.DateTime dateTime) { } - } public static class DateTimeOffsetHelper { public static System.DateTimeOffset ToDateTimeOffset(string wireFormattedString) { } @@ -258,9 +198,6 @@ namespace NServiceBus public class DelayedRetriesSettings : NServiceBus.Configuration.AdvancedExtensibility.ExposeSettings { public NServiceBus.DelayedRetriesSettings NumberOfRetries(int numberOfRetries) { } - [System.Obsolete("Use the overload that accepts a delegate with a cancellation token. The member cu" + - "rrently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public NServiceBus.DelayedRetriesSettings OnMessageBeingRetried(System.Func notificationCallback) { } public NServiceBus.DelayedRetriesSettings OnMessageBeingRetried(System.Func notificationCallback) { } public NServiceBus.DelayedRetriesSettings TimeIncrease(System.TimeSpan timeIncrease) { } } @@ -280,9 +217,6 @@ namespace NServiceBus public static class DiagnosticSettingsExtensions { public static void AddStartupDiagnosticsSection(this NServiceBus.Settings.IReadOnlySettings settings, string sectionName, object section) { } - [System.Obsolete("Use the overload that accepts a delegate with a cancellation token. The member cu" + - "rrently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public static void CustomDiagnosticsWriter(this NServiceBus.EndpointConfiguration config, System.Func customDiagnosticsWriter) { } public static void CustomDiagnosticsWriter(this NServiceBus.EndpointConfiguration config, System.Func customDiagnosticsWriter) { } public static void SetDiagnosticsPath(this NServiceBus.EndpointConfiguration config, string path) { } } @@ -303,32 +237,6 @@ namespace NServiceBus Send = 0, Publish = 1, } - [System.Obsolete("Non-durable delivery support has been moved to the transports that can support it" + - ". See the upgrade guide for more details. Will be removed in version 9.0.0.", true)] - public static class DurableMessagesConfig - { - [System.Obsolete("Non-durable delivery support has been moved to the transports that can support it" + - ". See the upgrade guide for more details. The member currently throws a NotImple" + - "mentedException. Will be removed in version 9.0.0.", true)] - public static void DisableDurableMessages(this NServiceBus.EndpointConfiguration config) { } - [System.Obsolete("Non-durable delivery support has been moved to the transports that can support it" + - ". See the upgrade guide for more details. The member currently throws a NotImple" + - "mentedException. Will be removed in version 9.0.0.", true)] - public static bool DurableMessagesEnabled(this NServiceBus.Settings.ReadOnlySettings settings) { } - [System.Obsolete("Non-durable delivery support has been moved to the transports that can support it" + - ". See the upgrade guide for more details. The member currently throws a NotImple" + - "mentedException. Will be removed in version 9.0.0.", true)] - public static void EnableDurableMessages(this NServiceBus.EndpointConfiguration config) { } - } - [System.Obsolete("Non-durable delivery support has been moved to the transports that can support it" + - ". See the upgrade guide for more details. Will be removed in version 9.0.0.", true)] - public static class DurableMessagesConventionExtensions - { - [System.Obsolete("Non-durable delivery support has been moved to the transports that can support it" + - ". See the upgrade guide for more details. The member currently throws a NotImple" + - "mentedException. Will be removed in version 9.0.0.", true)] - public static NServiceBus.ConventionsBuilder DefiningExpressMessagesAs(this NServiceBus.ConventionsBuilder builder, System.Func definesExpressMessageType) { } - } public static class Endpoint { public static System.Threading.Tasks.Task Create(NServiceBus.EndpointConfiguration configuration, System.Threading.CancellationToken cancellationToken = default) { } @@ -337,24 +245,13 @@ namespace NServiceBus public class EndpointConfiguration : NServiceBus.Configuration.AdvancedExtensibility.ExposeSettings { public EndpointConfiguration(string endpointName) { } + [System.Obsolete("Error notification events have been replaced with a Task-based API available on t" + + "he recoverability settings. Will be removed in version 10.0.0.", true)] public NServiceBus.Notifications Notifications { get; } public NServiceBus.Pipeline.PipelineSettings Pipeline { get; } public NServiceBus.ConventionsBuilder Conventions() { } public void RegisterComponents(System.Action registration) { } public void SendOnly() { } - [System.Obsolete("Use the externally managed container mode to integrate with third party dependenc" + - "y injection containers. The member currently throws a NotImplementedException. W" + - "ill be removed in version 9.0.0.", true)] - public void UseContainer(NServiceBus.ObjectBuilder.Common.IContainer builder) { } - [System.Obsolete("Use the externally managed container mode to integrate with third party dependenc" + - "y injection containers. The member currently throws a NotImplementedException. W" + - "ill be removed in version 9.0.0.", true)] - public void UseContainer(System.Type definitionType) { } - [System.Obsolete("Use the externally managed container mode to integrate with third party dependenc" + - "y injection containers. The member currently throws a NotImplementedException. W" + - "ill be removed in version 9.0.0.", true)] - public void UseContainer(System.Action customizations = null) - where T : NServiceBus.Container.ContainerDefinition, new () { } public NServiceBus.RoutingSettings UseTransport(TTransport transportDefinition) where TTransport : NServiceBus.Transport.TransportDefinition { } } @@ -381,13 +278,6 @@ namespace NServiceBus public static string ErrorQueueAddress(this NServiceBus.Settings.IReadOnlySettings settings) { } public static bool TryGetExplicitlyConfiguredErrorQueueAddress(this NServiceBus.Settings.IReadOnlySettings settings, out string errorQueue) { } } - [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface | System.AttributeTargets.All)] - [System.Obsolete("Non-durable delivery support has been moved to the transports that can support it" + - ". See the upgrade guide for more details. Will be removed in version 9.0.0.", true)] - public sealed class ExpressAttribute : System.Attribute - { - public ExpressAttribute() { } - } public class FailedConfig { public FailedConfig(string errorQueue, System.Collections.Generic.HashSet unrecoverableExceptionTypes) { } @@ -420,8 +310,6 @@ namespace NServiceBus public const string DiagnosticsTraceState = "tracestate"; public const string EnclosedMessageTypes = "NServiceBus.EnclosedMessageTypes"; public const string HasLicenseExpired = "$.diagnostics.license.expired"; - [System.Obsolete("Not intended for public usage. Will be removed in version 9.0.0.", true)] - public const string HeaderName = "Header"; public const string HostDisplayName = "$.diagnostics.hostdisplayname"; public const string HostId = "$.diagnostics.hostid"; public const string HttpFrom = "NServiceBus.From"; @@ -432,8 +320,6 @@ namespace NServiceBus public const string MessageId = "NServiceBus.MessageId"; public const string MessageIntent = "NServiceBus.MessageIntent"; public const string NServiceBusVersion = "NServiceBus.Version"; - [System.Obsolete("Non-durable delivery support has been moved to the transports that can support it" + - ". See the upgrade guide for more details. Will be removed in version 9.0.0.", true)] public const string NonDurableMessage = "NServiceBus.NonDurableMessage"; public const string OriginatingAddress = "NServiceBus.OriginatingAddress"; public const string OriginatingEndpoint = "NServiceBus.OriginatingEndpoint"; @@ -601,16 +487,13 @@ namespace NServiceBus { public static bool IsImmediateDispatchSet(this NServiceBus.Extensibility.ExtendableOptions options) { } public static void RequireImmediateDispatch(this NServiceBus.Extensibility.ExtendableOptions options) { } - [System.Obsolete("Use `IsImmediateDispatchSet` instead. Will be treated as an error from version 9." + - "0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete("Use `IsImmediateDispatchSet` instead. The member currently throws a NotImplemente" + + "dException. Will be removed in version 10.0.0.", true)] public static bool RequiredImmediateDispatch(this NServiceBus.Extensibility.ExtendableOptions options) { } } public class ImmediateRetriesSettings : NServiceBus.Configuration.AdvancedExtensibility.ExposeSettings { public void NumberOfRetries(int numberOfRetries) { } - [System.Obsolete("Use the overload that accepts a delegate with a cancellation token. The member cu" + - "rrently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public NServiceBus.ImmediateRetriesSettings OnMessageBeingRetried(System.Func notificationCallback) { } public NServiceBus.ImmediateRetriesSettings OnMessageBeingRetried(System.Func notificationCallback) { } } public class ImmediateRetry : NServiceBus.RecoverabilityAction @@ -619,60 +502,6 @@ namespace NServiceBus public override NServiceBus.Transport.ErrorHandleResult ErrorHandleResult { get; } public override System.Collections.Generic.IReadOnlyCollection GetRoutingContexts(NServiceBus.Pipeline.IRecoverabilityActionContext context) { } } - [System.Obsolete("Gateway persistence has been moved to the NServiceBus.Gateway dedicated package. " + - "Will be removed in version 9.0.0.", true)] - public static class InMemoryGatewayPersistenceConfigurationExtensions - { - [System.Obsolete("Gateway persistence has been moved to the NServiceBus.Gateway dedicated package. " + - "The member currently throws a NotImplementedException. Will be removed in versio" + - "n 9.0.0.", true)] - public static void GatewayDeduplicationCacheSize(this NServiceBus.PersistenceExtensions persistenceExtensions, int maxSize) { } - } - [System.Obsolete("The InMemoryPersistence has been moved to a dedicated Nuget Package called NServi" + - "ceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence. Will" + - " be removed in version 9.0.0.", true)] - public class InMemoryOutboxPersistence - { - public InMemoryOutboxPersistence() { } - } - [System.Obsolete("The InMemoryPersistence has been moved to a dedicated Nuget Package called NServi" + - "ceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence. Will" + - " be removed in version 9.0.0.", true)] - public static class InMemoryOutboxSettingsExtensions - { - [System.Obsolete("The InMemoryPersistence has been moved to a dedicated Nuget Package called NServi" + - "ceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence. Will" + - " be removed in version 9.0.0.", true)] - public static NServiceBus.Outbox.OutboxSettings TimeToKeepDeduplicationData(this NServiceBus.Outbox.OutboxSettings settings, System.TimeSpan time) { } - } - [System.Obsolete("The InMemoryPersistence has been moved to a dedicated Nuget Package called NServi" + - "ceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence. Will" + - " be removed in version 9.0.0.", true)] - public class InMemoryPersistence : NServiceBus.Persistence.PersistenceDefinition - { - public InMemoryPersistence() { } - } - [System.Obsolete("The InMemoryPersistence has been moved to a dedicated Nuget Package called NServi" + - "ceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence. Will" + - " be removed in version 9.0.0.", true)] - public class InMemorySagaPersistence - { - public InMemorySagaPersistence() { } - } - [System.Obsolete("The InMemoryPersistence has been moved to a dedicated Nuget Package called NServi" + - "ceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence. Will" + - " be removed in version 9.0.0.", true)] - public class InMemorySubscriptionPersistence - { - public InMemorySubscriptionPersistence() { } - } - [System.Obsolete("The InMemoryPersistence has been moved to a dedicated Nuget Package called NServi" + - "ceBus.Persistence.NonDurable and has been renamed to NonDurablePersistence. Will" + - " be removed in version 9.0.0.", true)] - public class InMemoryTimeoutPersistence - { - public InMemoryTimeoutPersistence() { } - } public static class InstallConfigExtensions { public static void EnableInstallers(this NServiceBus.EndpointConfiguration config, string username = null) { } @@ -689,16 +518,14 @@ namespace NServiceBus public string StorageDirectory { get; set; } public override System.Collections.Generic.IReadOnlyCollection GetSupportedTransactionModes() { } public override System.Threading.Tasks.Task Initialize(NServiceBus.Transport.HostSettings hostSettings, NServiceBus.Transport.ReceiveSettings[] receivers, string[] sendingAddresses, System.Threading.CancellationToken cancellationToken = default) { } + [System.Obsolete("Inject the ITransportAddressResolver type to access the address translation mecha" + + "nism at runtime. See the NServiceBus version 8 upgrade guide for further details" + + ". The member currently throws a NotImplementedException. Will be removed in vers" + + "ion 10.0.0.", true)] public override string ToTransportAddress(NServiceBus.Transport.QueueAddress queueAddress) { } } public static class LearningTransportConfigurationExtensions { - [System.Obsolete("The learning transport does not support a connection string. The member currently" + - " throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public static NServiceBus.TransportExtensions ConnectionString(this NServiceBus.TransportExtensions transport, System.Func connectionString) { } - [System.Obsolete("The learning transport does not support a connection string. The member currently" + - " throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public static NServiceBus.TransportExtensions ConnectionString(this NServiceBus.TransportExtensions transport, string connectionString) { } public static void NoPayloadSizeRestriction(this NServiceBus.TransportExtensions transportExtensions) { } public static void StorageDirectory(this NServiceBus.TransportExtensions transportExtensions, string path) { } public static NServiceBus.TransportExtensions UseTransport(this NServiceBus.EndpointConfiguration config) @@ -709,48 +536,19 @@ namespace NServiceBus public static void ExecuteTheseHandlersFirst(this NServiceBus.EndpointConfiguration config, System.Collections.Generic.IEnumerable handlerTypes) { } public static void ExecuteTheseHandlersFirst(this NServiceBus.EndpointConfiguration config, params System.Type[] handlerTypes) { } } - [System.Obsolete("Use `QueueAddress` instead. Will be removed in version 9.0.0.", true)] - public struct LogicalAddress - { - [System.Obsolete("Use `QueueAddress` instead. The member currently throws a NotImplementedException" + - ". Will be removed in version 9.0.0.", true)] - public NServiceBus.Routing.EndpointInstance EndpointInstance { get; } - [System.Obsolete("Use `QueueAddress.Qualifier` instead. The member currently throws a NotImplemente" + - "dException. Will be removed in version 9.0.0.", true)] - public string Qualifier { get; } - [System.Obsolete("Directly construct a QueueAddress with the discriminator. The member currently th" + - "rows a NotImplementedException. Will be removed in version 9.0.0.", true)] - public NServiceBus.LogicalAddress CreateIndividualizedAddress(string discriminator) { } - [System.Obsolete("Directly construct a QueueAddress with the qualifier. The member currently throws" + - " a NotImplementedException. Will be removed in version 9.0.0.", true)] - public NServiceBus.LogicalAddress CreateQualifiedAddress(string qualifier) { } - [System.Obsolete("Directly construct a QueueAddress with the queueName as the BaseAddress. The memb" + - "er currently throws a NotImplementedException. Will be removed in version 9.0.0." + - "", true)] - public static NServiceBus.LogicalAddress CreateLocalAddress(string queueName, System.Collections.Generic.IReadOnlyDictionary properties) { } - [System.Obsolete("Directly construct a QueueAddress. The member currently throws a NotImplementedEx" + - "ception. Will be removed in version 9.0.0.", true)] - public static NServiceBus.LogicalAddress CreateRemoteAddress(NServiceBus.Routing.EndpointInstance endpointInstance) { } - } public static class MessageCausationConfigurationExtensions { public static void CustomConversationIdStrategy(this NServiceBus.EndpointConfiguration endpointConfiguration, System.Func customStrategy) { } } - [System.Serializable] public class MessageDeserializationException : System.Runtime.Serialization.SerializationException { public MessageDeserializationException(string message) { } - protected MessageDeserializationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public MessageDeserializationException(string messageId, System.Exception innerException) { } } public static class MessageDrivenSubscriptionsConfigExtensions { public static void DisablePublishing(this NServiceBus.RoutingSettings routingSettings) where T : NServiceBus.Transport.TransportDefinition, NServiceBus.Routing.IMessageDrivenSubscriptionTransport { } - [System.Obsolete("Use `RoutingSettings.DisablePublishing` instead. The member currently throws a" + - " NotImplementedException. Will be removed in version 9.0.0.", true)] - public static void DisablePublishing(this NServiceBus.TransportExtensions transportExtensions) - where T : NServiceBus.Transport.TransportDefinition, NServiceBus.Routing.IMessageDrivenSubscriptionTransport { } public static void RegisterPublisher(this NServiceBus.RoutingSettings routingSettings, System.Reflection.Assembly assembly, string publisherEndpoint) where T : NServiceBus.Transport.TransportDefinition, NServiceBus.Routing.IMessageDrivenSubscriptionTransport { } public static void RegisterPublisher(this NServiceBus.RoutingSettings routingSettings, System.Type eventType, string publisherEndpoint) @@ -759,10 +557,6 @@ namespace NServiceBus where T : NServiceBus.Transport.TransportDefinition, NServiceBus.Routing.IMessageDrivenSubscriptionTransport { } public static void SubscriptionAuthorizer(this NServiceBus.RoutingSettings routingSettings, System.Func authorizer) where T : NServiceBus.Transport.TransportDefinition, NServiceBus.Routing.IMessageDrivenSubscriptionTransport { } - [System.Obsolete("Use `RoutingSettings.SubscriptionAuthorizer` instead. The member currently thr" + - "ows a NotImplementedException. Will be removed in version 9.0.0.", true)] - public static void SubscriptionAuthorizer(this NServiceBus.TransportExtensions transportExtensions, System.Func authorizer) - where T : NServiceBus.Transport.TransportDefinition, NServiceBus.Routing.IMessageDrivenSubscriptionTransport { } } public static class MessageIdExtensions { @@ -777,8 +571,6 @@ namespace NServiceBus Unsubscribe = 4, Reply = 5, } - [System.Obsolete("Use `MessageIntent` instead. Will be removed in version 9.0.0.", true)] - public enum MessageIntentEnum { } public static class MessageProcessingContextExtensions { public static System.Threading.Tasks.Task Reply(this NServiceBus.IMessageProcessingContext context, object message) { } @@ -819,16 +611,11 @@ namespace NServiceBus public bool IsEventType(System.Type type) { } public bool IsMessageType(System.Type type) { } } - [System.Obsolete("Non-durable delivery support has been moved to the transports that can support it" + - ". See the upgrade guide for more details. Will be removed in version 9.0.0.", true)] - public class NonDurableDelivery - { - public NonDurableDelivery() { } - } + [System.Obsolete("Error notification events have been replaced with a Task-based API available on t" + + "he recoverability settings. Will be removed in version 10.0.0.", true)] public class Notifications { public Notifications() { } - public NServiceBus.Faults.ErrorsNotifications Errors { get; } } public delegate System.Threading.Tasks.Task OnSatelliteMessage(System.IServiceProvider serviceProvider, NServiceBus.Transport.MessageContext messageContext, System.Threading.CancellationToken cancellationToken = default); public static class OpenTelemetryConfigurationExtensions @@ -916,9 +703,6 @@ namespace NServiceBus } public static class ReceivePipelineConfigExtensions { - [System.Obsolete("Use the overload that accepts a delegate with a cancellation token. The member cu" + - "rrently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public static void OnReceivePipelineCompleted(this NServiceBus.Pipeline.PipelineSettings pipelineSettings, System.Func subscription) { } public static void OnReceivePipelineCompleted(this NServiceBus.Pipeline.PipelineSettings pipelineSettings, System.Func subscription) { } } public static class ReceiveSettingsExtensions @@ -969,9 +753,6 @@ namespace NServiceBus public class RetryFailedSettings : NServiceBus.Configuration.AdvancedExtensibility.ExposeSettings { public NServiceBus.RetryFailedSettings HeaderCustomization(System.Action> customization) { } - [System.Obsolete("Use the overload that accepts a delegate with a cancellation token. The member cu" + - "rrently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public NServiceBus.RetryFailedSettings OnMessageSentToErrorQueue(System.Func notificationCallback) { } public NServiceBus.RetryFailedSettings OnMessageSentToErrorQueue(System.Func notificationCallback) { } } public static class RoutingFeatureSettingsExtensions @@ -1011,12 +792,6 @@ namespace NServiceBus public void RouteToEndpoint(System.Type messageType, string destination) { } public void RouteToEndpoint(System.Reflection.Assembly assembly, string @namespace, string destination) { } } - public static class RoutingSettingsExtensions - { - [System.Obsolete("Use `TransportExtensions.Routing()` instead. The member currently throws a Not" + - "ImplementedException. Will be removed in version 9.0.0.", true)] - public static NServiceBus.RoutingSettings Routing(this NServiceBus.TransportExtensions config) { } - } public class RoutingSettings : NServiceBus.RoutingSettings where T : NServiceBus.Transport.TransportDefinition { @@ -1056,16 +831,6 @@ namespace NServiceBus { public static NServiceBus.Sagas.SagaSettings Sagas(this NServiceBus.EndpointConfiguration config) { } } - [System.Obsolete("The built-in scheduler is no longer supported, see our upgrade guide for details " + - "on how to migrate to plain .NET Timers. Will be removed in version 9.0.0.", true)] - public static class ScheduleExtensions - { - public static System.Threading.Tasks.Task ScheduleEvery(this NServiceBus.IMessageSession session, System.TimeSpan timeSpan, System.Func task) { } - public static System.Threading.Tasks.Task ScheduleEvery(this NServiceBus.IMessageSession session, System.TimeSpan timeSpan, string name, System.Func task) { } - } - [System.Obsolete("The built-in scheduler is no longer supported, see our upgrade guide for details " + - "on how to migrate to plain .NET Timers. Will be removed in version 9.0.0.", true)] - public class ScheduledTask { } public class SendOptions : NServiceBus.Extensibility.ExtendableOptions { public SendOptions() { } @@ -1095,30 +860,30 @@ namespace NServiceBus } [System.Obsolete("Use methods on IServiceCollection instead. Note that interfaces are not registere" + "d implicitly. See the NServiceBus 7 to 8 upgrade guide for more information. Wil" + - "l be treated as an error from version 9.0.0. Will be removed in version 10.0.0.", false)] + "l be removed in version 10.0.0.", true)] public static class ServiceCollectionExtensions { - [System.Obsolete("Use `IServiceCollection.Add` instead. Will be treated as an error from version 9." + - "0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete("Use `IServiceCollection.Add` instead. The member currently throws a NotImplemente" + + "dException. Will be removed in version 10.0.0.", true)] public static void ConfigureComponent(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, System.Type concreteComponent, NServiceBus.DependencyLifecycle dependencyLifecycle) { } - [System.Obsolete(@"Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information. Will be treated as an error from version 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete(@"Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information. The member currently throws a NotImplementedException. Will be removed in version 10.0.0.", true)] public static void ConfigureComponent(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, NServiceBus.DependencyLifecycle dependencyLifecycle) { } - [System.Obsolete(@"Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information. Will be treated as an error from version 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete(@"Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information. The member currently throws a NotImplementedException. Will be removed in version 10.0.0.", true)] public static void ConfigureComponent(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, System.Func componentFactory, NServiceBus.DependencyLifecycle dependencyLifecycle) { } - [System.Obsolete(@"Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information. Will be treated as an error from version 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete(@"Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollection.AddTransient` or `IServiceCollection.AddScoped` instead. Note that interfaces are not registered implicitly. See the NServiceBus 7 to 8 upgrade guide for more information. The member currently throws a NotImplementedException. Will be removed in version 10.0.0.", true)] public static void ConfigureComponent(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, System.Func componentFactory, NServiceBus.DependencyLifecycle dependencyLifecycle) { } - [System.Obsolete("Use `IServiceCollection.GetEnumerator` instead. Will be treated as an error from " + - "version 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete("Use `IServiceCollection.GetEnumerator` instead. The member currently throws a Not" + + "ImplementedException. Will be removed in version 10.0.0.", true)] public static bool HasComponent(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, System.Type componentType) { } - [System.Obsolete("Use `IServiceCollection.GetEnumerator` instead. Will be treated as an error from " + - "version 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete("Use `IServiceCollection.GetEnumerator` instead. The member currently throws a Not" + + "ImplementedException. Will be removed in version 10.0.0.", true)] public static bool HasComponent(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection) { } [System.Obsolete("Use `IServiceCollection.Add`, `IServiceCollection.AddSingleton`, `IServiceCollect" + - "ion.AddTransient` or `IServiceCollection.AddScoped` instead. Will be treated as " + - "an error from version 9.0.0. Will be removed in version 10.0.0.", false)] + "ion.AddTransient` or `IServiceCollection.AddScoped` instead. The member currentl" + + "y throws a NotImplementedException. Will be removed in version 10.0.0.", true)] public static void RegisterSingleton(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, System.Type lookupType, object instance) { } - [System.Obsolete("Use `IServiceCollection.AddSingleton` instead. Will be treated as an error from v" + - "ersion 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete("Use `IServiceCollection.AddSingleton` instead. The member currently throws a NotI" + + "mplementedException. Will be removed in version 10.0.0.", true)] public static void RegisterSingleton(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, T instance) { } } public static class SettingsExtensions @@ -1126,13 +891,10 @@ namespace NServiceBus public static string EndpointName(this NServiceBus.Settings.IReadOnlySettings settings) { } public static string EndpointQueueName(this NServiceBus.Settings.IReadOnlySettings settings) { } public static System.Collections.Generic.IList GetAvailableTypes(this NServiceBus.Settings.IReadOnlySettings settings) { } - [System.Obsolete(@"Use FeatureConfigurationContext.InstanceSpecificQueueAddress() to access the endpoint instance specific queue address. Inject the ReceiveAddresses class to access the endpoint's receiving transport addresses at runtime. See the NServiceBus version 8 upgrade guide for further details. Will be treated as an error from version 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete(@"Use FeatureConfigurationContext.InstanceSpecificQueueAddress() to access the endpoint instance specific queue address. Inject the ReceiveAddresses class to access the endpoint's receiving transport addresses at runtime. See the NServiceBus version 8 upgrade guide for further details. The member currently throws a NotImplementedException. Will be removed in version 10.0.0.", true)] public static string InstanceSpecificQueue(this NServiceBus.Settings.IReadOnlySettings settings) { } - [System.Obsolete(@"Use FeatureConfigurationContext.LocalQueueAddress() to access the endpoint queue address. Inject the ReceiveAddresses class to access the endpoint's receiving transport addresses at runtime. See the NServiceBus version 8 upgrade guide for further details. Will be treated as an error from version 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete(@"Use FeatureConfigurationContext.LocalQueueAddress() to access the endpoint queue address. Inject the ReceiveAddresses class to access the endpoint's receiving transport addresses at runtime. See the NServiceBus version 8 upgrade guide for further details. The member currently throws a NotImplementedException. Will be removed in version 10.0.0.", true)] public static string LocalAddress(this NServiceBus.Settings.IReadOnlySettings settings) { } - [System.Obsolete("Use `SettingsExtensions.EndpointQueueName` instead. The member currently throws a" + - " NotImplementedException. Will be removed in version 9.0.0.", true)] - public static NServiceBus.LogicalAddress LogicalAddress(this NServiceBus.Settings.ReadOnlySettings settings) { } } public class StartupDiagnosticEntries { @@ -1152,16 +914,9 @@ namespace NServiceBus public abstract class StorageType { public override string ToString() { } - [System.Obsolete("Gateway persistence has been moved to the NServiceBus.Gateway dedicated package. " + - "Will be removed in version 9.0.0.", true)] - public sealed class GatewayDeduplication { } public sealed class Outbox : NServiceBus.StorageType { } public sealed class Sagas : NServiceBus.StorageType { } public sealed class Subscriptions : NServiceBus.StorageType { } - [System.Obsolete("The timeout manager has been removed in favor of native delayed delivery support " + - "provided by transports. See the upgrade guide for more details. Will be removed " + - "in version 9.0.0.", true)] - public sealed class Timeouts { } } public class SubscribeOptions : NServiceBus.Extensibility.ExtendableOptions { @@ -1202,58 +957,17 @@ namespace NServiceBus { public static NServiceBus.ConventionsBuilder DefiningTimeToBeReceivedAs(this NServiceBus.ConventionsBuilder builder, System.Func retrieveTimeToBeReceived) { } } - public class TimeoutManagerConfiguration { } - [System.Obsolete("The timeout manager has been removed. See the upgrade guide for more details. Wil" + - "l be removed in version 9.0.0.", true)] - public static class TimeoutManagerConfigurationExtensions - { - [System.Obsolete("The timeout manager has been removed in favor of native delayed delivery support " + - "provided by transports. See the upgrade guide for more details. The member curre" + - "ntly throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public static void LimitMessageProcessingConcurrencyTo(this NServiceBus.TimeoutManagerConfiguration timeoutManagerConfiguration, int maxConcurrency) { } - [System.Obsolete("The timeout manager has been removed in favor of native delayed delivery support " + - "provided by transports. See the upgrade guide for more details. The member curre" + - "ntly throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public static NServiceBus.TimeoutManagerConfiguration TimeoutManager(this NServiceBus.EndpointConfiguration endpointConfiguration) { } - } public class ToSagaExpression where TSagaData : class, NServiceBus.IContainSagaData { public ToSagaExpression(NServiceBus.IConfigureHowToFindSagaWithMessage sagaMessageFindingConfiguration, System.Linq.Expressions.Expression> messageProperty) { } public void ToSaga(System.Linq.Expressions.Expression> sagaEntityProperty) { } } - [System.Obsolete("Configure the transport via the TransportDefinition instance\'s properties. Will b" + - "e removed in version 9.0.0.", true)] - public class TransportExtensions - { - [System.Obsolete("Configure the transport via the TransportDefinition instance\'s properties. Will b" + - "e removed in version 9.0.0.", true)] - public TransportExtensions(NServiceBus.Settings.SettingsHolder settings) { } - [System.Obsolete("Setting connection string at the endpoint level is no longer supported. Transport" + - " specific configuration options should be used instead. The member currently thr" + - "ows a NotImplementedException. Will be removed in version 9.0.0.", true)] - public NServiceBus.TransportExtensions ConnectionString(System.Func connectionString) { } - [System.Obsolete("Setting connection string at the endpoint level is no longer supported. Transport" + - " specific configuration options should be used instead. The member currently thr" + - "ows a NotImplementedException. Will be removed in version 9.0.0.", true)] - public NServiceBus.TransportExtensions ConnectionString(string connectionString) { } - [System.Obsolete(@"The ability to used named connection strings has been removed. Instead, load the connection string in your code and pass the value to TransportExtensions.ConnectionString(connectionString). Use `ConnectionString(connectionString)` instead. The member currently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public NServiceBus.TransportExtensions ConnectionStringName(string name) { } - [System.Obsolete("Use `TransportDefinition.TransportTransactionMode` instead. The member currently " + - "throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public NServiceBus.TransportExtensions Transactions(NServiceBus.TransportTransactionMode transportTransactionMode) { } - } public class TransportExtensions where T : NServiceBus.Transport.TransportDefinition { - [System.Obsolete(@"TransportExtensions does not use a SettingsHolder. Get an instance from endpointConfiguration.UseTransport(), or configure the transport directly via the TransportDefinition instance's properties. The member currently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public TransportExtensions(NServiceBus.Settings.SettingsHolder settings) { } public TransportExtensions(T transport, NServiceBus.RoutingSettings routing) { } public T Transport { get; } - [System.Obsolete("Loading named connection strings is no longer supported. Use `ConnectionString(co" + - "nnectionString)` instead. The member currently throws a NotImplementedException." + - " Will be removed in version 9.0.0.", true)] - public NServiceBus.TransportExtensions ConnectionStringName(string name) { } public NServiceBus.RoutingSettings Routing() { } public NServiceBus.TransportExtensions Transactions(NServiceBus.TransportTransactionMode transportTransactionMode) { } } @@ -1278,30 +992,13 @@ namespace NServiceBus } public static class UseDataBusExtensions { - [System.Obsolete("Specifying a serializer for data bus is mandatory. Use the overload that accepts " + - "a data bus serializer type. The member currently throws a NotImplementedExceptio" + - "n. Will be removed in version 9.0.0.", true)] - public static NServiceBus.DataBus.DataBusExtensions UseDataBus(this NServiceBus.EndpointConfiguration config, System.Type dataBusType) { } public static NServiceBus.DataBus.DataBusExtensions UseDataBus(this NServiceBus.EndpointConfiguration config, System.Func dataBusFactory, NServiceBus.DataBus.IDataBusSerializer dataBusSerializer) { } - [System.Obsolete("Specifying data bus serializer is mandatory. Use the overload that accepts a data" + - " bus serializer type. The member currently throws a NotImplementedException. Wil" + - "l be removed in version 9.0.0.", true)] - public static NServiceBus.DataBus.DataBusExtensions UseDataBus(this NServiceBus.EndpointConfiguration config) - where T : NServiceBus.DataBus.DataBusDefinition { } public static NServiceBus.DataBus.DataBusExtensions UseDataBus(this NServiceBus.EndpointConfiguration config, NServiceBus.DataBus.IDataBusSerializer dataBusSerializer) where TDataBusDefinition : NServiceBus.DataBus.DataBusDefinition, new () { } public static NServiceBus.DataBus.DataBusExtensions UseDataBus(this NServiceBus.EndpointConfiguration config) where TDataBusDefinition : NServiceBus.DataBus.DataBusDefinition, new () where TDataBusSerializer : NServiceBus.DataBus.IDataBusSerializer, new () { } } - [System.Obsolete("Use `EndpointConfiguration.UseTransport(TransportDefinition)` instead. Will be re" + - "moved in version 9.0.0.", true)] - public static class UseTransportExtensions - { - [System.Obsolete("Use `EndpointConfiguration.UseTransport(TransportDefinition)` instead. The member" + - " currently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public static NServiceBus.TransportExtensions UseTransport(this NServiceBus.EndpointConfiguration endpointConfiguration, System.Type transportDefinitionType) { } - } public static class XmlSerializationExtensions { public static NServiceBus.Serialization.SerializationExtensions DontWrapRawXml(this NServiceBus.Serialization.SerializationExtensions config) { } @@ -1354,20 +1051,6 @@ namespace NServiceBus.ConsistencyGuarantees public static NServiceBus.TransportTransactionMode GetRequiredTransactionModeForReceives(this NServiceBus.Settings.IReadOnlySettings settings) { } } } -namespace NServiceBus.Container -{ - [System.Obsolete("The NServiceBus dependency injection container API has been deprecated. Use the e" + - "xternally managed container mode to use custom containers. Will be removed in ve" + - "rsion 9.0.0.", true)] - public class ContainerCustomizations { } - [System.Obsolete("The NServiceBus dependency injection container API has been deprecated. Use the e" + - "xternally managed container mode to use custom containers. Will be removed in ve" + - "rsion 9.0.0.", true)] - public abstract class ContainerDefinition - { - protected ContainerDefinition() { } - } -} namespace NServiceBus.DataBus { public abstract class DataBusDefinition @@ -1413,45 +1096,6 @@ namespace NServiceBus.DelayedDelivery public DoNotDeliverBefore(System.DateTimeOffset at) { } public System.DateTimeOffset At { get; } } - [System.Obsolete("The timeout manager has been removed in favor of native delayed delivery support " + - "provided by transports. See the upgrade guide for more details. Will be removed " + - "in version 9.0.0.", true)] - public static class ExternalTimeoutManagerConfigurationExtensions - { - [System.Obsolete("The timeout manager has been removed in favor of native delayed delivery support " + - "provided by transports. See the upgrade guide for more details. The member curre" + - "ntly throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public static void UseExternalTimeoutManager(this NServiceBus.EndpointConfiguration endpointConfiguration, string externalTimeoutManagerAddress) { } - } -} -namespace NServiceBus.DeliveryConstraints -{ - [System.Obsolete("Use `DispatchProperties` instead. Will be removed in version 9.0.0.", true)] - public abstract class DeliveryConstraint - { - [System.Obsolete("Will be removed in version 9.0.0.", true)] - protected DeliveryConstraint() { } - } - public static class DeliveryConstraintContextExtensions - { - [System.Obsolete("Use `DispatchProperties` instead. The member currently throws a NotImplementedExc" + - "eption. Will be removed in version 9.0.0.", true)] - public static void AddDeliveryConstraint(this NServiceBus.Extensibility.ContextBag context, NServiceBus.DeliveryConstraints.DeliveryConstraint constraint) { } - [System.Obsolete("Use `DispatchProperties` instead. The member currently throws a NotImplementedExc" + - "eption. Will be removed in version 9.0.0.", true)] - public static System.Collections.Generic.List GetDeliveryConstraints(this NServiceBus.Extensibility.ContextBag context) { } - [System.Obsolete("Use `DispatchProperties` instead. The member currently throws a NotImplementedExc" + - "eption. Will be removed in version 9.0.0.", true)] - public static void RemoveDeliveryConstraint(this NServiceBus.Extensibility.ContextBag context, NServiceBus.DeliveryConstraints.DeliveryConstraint constraint) { } - [System.Obsolete("Use `DispatchProperties` instead. The member currently throws a NotImplementedExc" + - "eption. Will be removed in version 9.0.0.", true)] - public static bool TryGetDeliveryConstraint(this NServiceBus.Extensibility.ContextBag context, out T constraint) - where T : NServiceBus.DeliveryConstraints.DeliveryConstraint { } - [System.Obsolete("Use `DispatchProperties` instead. The member currently throws a NotImplementedExc" + - "eption. Will be removed in version 9.0.0.", true)] - public static bool TryRemoveDeliveryConstraint(this NServiceBus.Extensibility.ContextBag context, out T constraint) - where T : NServiceBus.DeliveryConstraints.DeliveryConstraint { } - } } namespace NServiceBus.Extensibility { @@ -1493,8 +1137,6 @@ namespace NServiceBus.Extensibility bool TryGet(out T result); bool TryGet(string key, out T result); } - [System.Obsolete("Use `IReadOnlyContextBag` instead. Will be removed in version 9.0.0.", true)] - public interface ReadOnlyContextBag { } } namespace NServiceBus.Faults { @@ -1507,25 +1149,6 @@ namespace NServiceBus.Faults public string MessageId { get; } public int RetryAttempt { get; } } - public class ErrorsNotifications - { - public ErrorsNotifications() { } - [System.Obsolete("The .NET event based error notifications will be deprecated in favor of Task-base" + - "d callbacks. Use endpointConfiguration.Recoverability().Delayed(settings => sett" + - "ings.OnMessageBeingRetried(callback)) instead. Will be removed in version 9.0.0." + - "", true)] - public event System.EventHandler MessageHasBeenSentToDelayedRetries; - [System.Obsolete("The .NET event based error notifications will be deprecated in favor of Task-base" + - "d callbacks. Use endpointConfiguration.Recoverability().Immediate(settings => se" + - "ttings.OnMessageBeingRetried(callback)) instead. Will be removed in version 9.0." + - "0.", true)] - public event System.EventHandler MessageHasFailedAnImmediateRetryAttempt; - [System.Obsolete("The .NET event based error notifications will be deprecated in favor of Task-base" + - "d callbacks. Use endpointConfiguration.Recoverability().Failed(settings => setti" + - "ngs.OnMessageSentToErrorQueue(callback)) instead. Will be removed in version 9.0" + - ".0.", true)] - public event System.EventHandler MessageSentToErrorQueue; - } public class FailedMessage { public FailedMessage(string messageId, System.Collections.Generic.Dictionary headers, System.ReadOnlyMemory body, System.Exception exception, string errorQueue) { } @@ -1587,8 +1210,8 @@ namespace NServiceBus.Features } public class FeatureConfigurationContext { - [System.Obsolete("Use `Services` instead. Will be treated as an error from version 9.0.0. Will be r" + - "emoved in version 10.0.0.", false)] + [System.Obsolete("Use `Services` instead. The member currently throws a NotImplementedException. Wi" + + "ll be removed in version 10.0.0.", true)] public Microsoft.Extensions.DependencyInjection.IServiceCollection Container { get; } public NServiceBus.Pipeline.PipelineSettings Pipeline { get; } public Microsoft.Extensions.DependencyInjection.IServiceCollection Services { get; } @@ -1614,13 +1237,7 @@ namespace NServiceBus.Features Active = 2, Deactivated = 3, } - [System.Obsolete("Message forwarding is no longer supported, but can be implemented as a custom pip" + - "eline behavior. Will be removed in version 9.0.0.", true)] - public class ForwardReceivedMessages { } - [System.Obsolete("Gateway persistence has been moved to the NServiceBus.Gateway dedicated package. " + - "Will be removed in version 9.0.0.", true)] - public class InMemoryGatewayPersistence { } - [System.Obsolete(@"It's not recommended to disable the MessageDrivenSubscriptions feature and this option will be removed in future versions. Use 'TransportExtensions.DisablePublishing()' to avoid the need for a subscription storage if this endpoint does not publish events. Will be treated as an error from version 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete(@"It's not recommended to disable the MessageDrivenSubscriptions feature and this option will be removed in future versions. Use 'TransportExtensions.DisablePublishing()' to avoid the need for a subscription storage if this endpoint does not publish events. Will be removed in version 10.0.0.", true)] public class MessageDrivenSubscriptions : NServiceBus.Features.Feature { protected override void Setup(NServiceBus.Features.FeatureConfigurationContext context) { } @@ -1637,12 +1254,6 @@ namespace NServiceBus.Features { protected override void Setup(NServiceBus.Features.FeatureConfigurationContext context) { } } - [System.Obsolete("The built-in scheduler is no longer supported, see our upgrade guide for details " + - "on how to migrate to plain .NET Timers. Will be removed in version 9.0.0.", true)] - public class Scheduler - { - public Scheduler() { } - } public static class SettingsExtensions { public static NServiceBus.Settings.SettingsHolder EnableFeatureByDefault(this NServiceBus.Settings.SettingsHolder settings, System.Type featureType) { } @@ -1655,19 +1266,6 @@ namespace NServiceBus.Features { protected override void Setup(NServiceBus.Features.FeatureConfigurationContext context) { } } - [System.Obsolete("The timeout manager has been removed in favor of native delayed delivery support " + - "provided by transports. See the upgrade guide for more details. Will be removed " + - "in version 9.0.0.", true)] - public class TimeoutManager { } -} -namespace NServiceBus.Gateway.Deduplication -{ - [System.Obsolete("Gateway persistence has been moved to the NServiceBus.Gateway dedicated package. " + - "Will be removed in version 9.0.0.", true)] - public interface IDeduplicateMessages - { - System.Threading.Tasks.Task DeduplicateMessage(string clientId, System.DateTime timeReceived, NServiceBus.Extensibility.ContextBag context); - } } namespace NServiceBus.Hosting.Helpers { @@ -1859,87 +1457,26 @@ namespace NServiceBus.MessageMutator public static void RegisterMessageMutator(this NServiceBus.EndpointConfiguration endpointConfiguration, object messageMutator) { } } } -namespace NServiceBus.ObjectBuilder.Common -{ - [System.Obsolete("The NServiceBus dependency injection container API has been deprecated. Use the e" + - "xternally managed container mode to use custom containers. Will be removed in ve" + - "rsion 9.0.0.", true)] - public interface IContainer : System.IDisposable { } -} namespace NServiceBus.ObjectBuilder { - [System.Obsolete("Use `IServiceProvider` instead. Will be removed in version 9.0.0.", true)] - public interface IBuilder : System.IDisposable - { - [System.Obsolete("The Build method is not supported anymore. Use `GetService` instead. Will be remo" + - "ved in version 9.0.0.", true)] - object Build(System.Type typeToBuild); - [System.Obsolete("The Build method is not supported anymore. Use `GetService` instead. Will be r" + - "emoved in version 9.0.0.", true)] - T Build(); - [System.Obsolete("The BuildAll method is not supported anymore. Use `GetServices` instead. Will be " + - "removed in version 9.0.0.", true)] - System.Collections.Generic.IEnumerable BuildAll(System.Type typeToBuild); - [System.Obsolete("The BuildAll method is not supported anymore. Use `GetServices` instead. Will " + - "be removed in version 9.0.0.", true)] - System.Collections.Generic.IEnumerable BuildAll(); - [System.Obsolete("The BuildAndDispatch method is not supported anymore. Will be removed in version " + - "9.0.0.", true)] - void BuildAndDispatch(System.Type typeToBuild, System.Action action); - [System.Obsolete("The CreateChildBuilder method is not supported anymore. Use `CreateScope` instead" + - ". Will be removed in version 9.0.0.", true)] - NServiceBus.ObjectBuilder.IBuilder CreateChildBuilder(); - [System.Obsolete("The Release method is not supported anymore. Will be removed in version 9.0.0.", true)] - void Release(object instance); - } - [System.Obsolete("Use `IServiceCollection` instead. Will be removed in version 9.0.0.", true)] - public interface IConfigureComponents - { - [System.Obsolete("Use `IServiceCollection.ConfigureComponent` instead. Will be removed in version 9" + - ".0.0.", true)] - void ConfigureComponent(System.Type concreteComponent, NServiceBus.DependencyLifecycle dependencyLifecycle); - [System.Obsolete("Use `IServiceCollection.ConfigureComponent` instead. Will be removed in version 9" + - ".0.0.", true)] - void ConfigureComponent(NServiceBus.DependencyLifecycle dependencyLifecycle); - [System.Obsolete("Use `IServiceCollection.ConfigureComponent` instead. Will be removed in version 9" + - ".0.0.", true)] - void ConfigureComponent(System.Func componentFactory, NServiceBus.DependencyLifecycle dependencyLifecycle); - [System.Obsolete("Use `IServiceCollection.ConfigureComponent` instead. Will be removed in version 9" + - ".0.0.", true)] - void ConfigureComponent(System.Func componentFactory, NServiceBus.DependencyLifecycle dependencyLifecycle); - [System.Obsolete("Use `IServiceCollection.HasComponent` instead. Will be removed in version 9.0.0.", true)] - bool HasComponent(System.Type componentType); - [System.Obsolete("Use `IServiceCollection.HasComponent` instead. Will be removed in version 9.0.0.", true)] - bool HasComponent(); - [System.Obsolete("Use `IServiceCollection.AddSingleton` instead. Will be removed in version 9.0.0.", true)] - void RegisterSingleton(System.Type lookupType, object instance); - [System.Obsolete("Use `IServiceCollection.AddSingleton` instead. Will be removed in version 9.0.0.", true)] - void RegisterSingleton(T instance); - } + [System.Obsolete("Will be removed in version 10.0.0.", true)] public static class ServiceProviderExtensions { - [System.Obsolete("Use `IServiceProvider.GetService` instead. Will be treated as an error from versi" + - "on 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete("Use `IServiceProvider.GetService` instead. The member currently throws a NotImple" + + "mentedException. Will be removed in version 10.0.0.", true)] public static object Build(this System.IServiceProvider serviceProvider, System.Type typeToBuild) { } - [System.Obsolete("Use `IServiceProvider.GetService` instead. Will be treated as an error from versi" + - "on 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete("Use `IServiceProvider.GetService` instead. The member currently throws a NotImple" + + "mentedException. Will be removed in version 10.0.0.", true)] public static T Build(this System.IServiceProvider serviceProvider) { } - [System.Obsolete("Use `IServiceProvider.GetServices` instead. Will be treated as an error from vers" + - "ion 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete("Use `IServiceProvider.GetServices` instead. The member currently throws a NotImpl" + + "ementedException. Will be removed in version 10.0.0.", true)] public static System.Collections.Generic.IEnumerable BuildAll(this System.IServiceProvider serviceProvider, System.Type typeToBuild) { } - [System.Obsolete("Use `IServiceProvider.GetServices` instead. Will be treated as an error from vers" + - "ion 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete("Use `IServiceProvider.GetServices` instead. The member currently throws a NotImpl" + + "ementedException. Will be removed in version 10.0.0.", true)] public static System.Collections.Generic.IEnumerable BuildAll(this System.IServiceProvider serviceProvider) { } - [System.Obsolete("The BuildAndDispatch method is not supported anymore. Use `IServiceProvider.GetSe" + - "rvice(typeToBuild)` and call the action on the returned service. The member curr" + - "ently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public static void BuildAndDispatch(this System.IServiceProvider serviceProvider, System.Type typeToBuild, System.Action action) { } - [System.Obsolete("Use `IServiceProvider.CreateScope` instead. Will be treated as an error from vers" + - "ion 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete("Use `IServiceProvider.CreateScope` instead. The member currently throws a NotImpl" + + "ementedException. Will be removed in version 10.0.0.", true)] public static Microsoft.Extensions.DependencyInjection.IServiceScope CreateChildBuilder(this System.IServiceProvider serviceProvider) { } - [System.Obsolete("The Release method is not supported. The member currently throws a NotImplemented" + - "Exception. Will be removed in version 9.0.0.", true)] - public static void Release(this System.IServiceProvider serviceProvider, object instance) { } } } namespace NServiceBus.Outbox @@ -1962,8 +1499,6 @@ namespace NServiceBus.Outbox public NServiceBus.Outbox.TransportOperation[] TransportOperations { get; } } public class OutboxSettings : NServiceBus.Configuration.AdvancedExtensibility.ExposeSettings { } - [System.Obsolete("Use `IOutboxTransaction` instead. Will be removed in version 9.0.0.", true)] - public interface OutboxTransaction { } public class TransportOperation { public TransportOperation(string messageId, NServiceBus.Transport.DispatchProperties properties, System.ReadOnlyMemory body, System.Collections.Generic.Dictionary headers) { } @@ -1983,9 +1518,6 @@ namespace NServiceBus.Performance.TimeToBeReceived } namespace NServiceBus.Persistence { - [System.Obsolete("Use `ICompletableSynchronizedStorageSession` instead. Will be removed in version " + - "9.0.0.", true)] - public interface CompletableSynchronizedStorageSession { } public static class CompletableSynchronizedStorageSessionExtensions { public static System.Threading.Tasks.ValueTask Open(this NServiceBus.Persistence.ICompletableSynchronizedStorageSession session, NServiceBus.Pipeline.IIncomingLogicalMessageContext context) { } @@ -1998,19 +1530,6 @@ namespace NServiceBus.Persistence System.Threading.Tasks.ValueTask TryOpen(NServiceBus.Outbox.IOutboxTransaction transaction, NServiceBus.Extensibility.ContextBag context, System.Threading.CancellationToken cancellationToken = default); System.Threading.Tasks.ValueTask TryOpen(NServiceBus.Transport.TransportTransaction transportTransaction, NServiceBus.Extensibility.ContextBag context, System.Threading.CancellationToken cancellationToken = default); } - [System.Obsolete("Use `ICompletableSynchronizedStorageSession` instead. Will be removed in version " + - "9.0.0.", true)] - public interface ISynchronizedStorage - { - System.Threading.Tasks.Task OpenSession(NServiceBus.Extensibility.ContextBag contextBag, System.Threading.CancellationToken cancellationToken = default); - } - [System.Obsolete("Use `ICompletableSynchronizedStorageSession` instead. Will be removed in version " + - "9.0.0.", true)] - public interface ISynchronizedStorageAdapter - { - System.Threading.Tasks.Task TryAdapt(NServiceBus.Outbox.IOutboxTransaction transaction, NServiceBus.Extensibility.ContextBag context, System.Threading.CancellationToken cancellationToken = default); - System.Threading.Tasks.Task TryAdapt(NServiceBus.Transport.TransportTransaction transportTransaction, NServiceBus.Extensibility.ContextBag context, System.Threading.CancellationToken cancellationToken = default); - } public interface ISynchronizedStorageSession { } public abstract class PersistenceDefinition { @@ -2022,8 +1541,6 @@ namespace NServiceBus.Persistence protected void Supports(System.Action action) where T : NServiceBus.StorageType { } } - [System.Obsolete("Use `ISynchronizedStorageSession` instead. Will be removed in version 9.0.0.", true)] - public interface SynchronizedStorageSession { } } namespace NServiceBus.Pipeline { @@ -2056,8 +1573,7 @@ namespace NServiceBus.Pipeline System.Collections.Generic.Dictionary AuditMetadata { get; } NServiceBus.Transport.OutgoingMessage Message { get; } System.TimeSpan? TimeToBeReceived { get; } - [System.Obsolete("Use `AuditMetadata` instead. Will be treated as an error from version 9.0.0. Will" + - " be removed in version 10.0.0.", false)] + [System.Obsolete("Use `AuditMetadata` instead. Will be removed in version 10.0.0.", true)] void AddAuditData(string key, string value); NServiceBus.Pipeline.IAuditActionContext PreventChanges(); } @@ -2080,9 +1596,6 @@ namespace NServiceBus.Pipeline { System.Collections.Generic.IEnumerable Operations { get; } } - [System.Obsolete("Message forwarding is no longer supported, but can be implemented as a custom pip" + - "eline behavior. Will be removed in version 9.0.0.", true)] - public interface IForwardingContext : NServiceBus.Extensibility.IExtendable, NServiceBus.ICancellableContext, NServiceBus.Pipeline.IBehaviorContext { } public interface IIncomingContext : NServiceBus.Extensibility.IExtendable, NServiceBus.ICancellableContext, NServiceBus.IMessageProcessingContext, NServiceBus.IPipelineContext, NServiceBus.Pipeline.IBehaviorContext { } public interface IIncomingLogicalMessageContext : NServiceBus.Extensibility.IExtendable, NServiceBus.ICancellableContext, NServiceBus.IMessageProcessingContext, NServiceBus.IPipelineContext, NServiceBus.Pipeline.IBehaviorContext, NServiceBus.Pipeline.IIncomingContext { @@ -2161,16 +1674,11 @@ namespace NServiceBus.Pipeline } public interface ISubscribeContext : NServiceBus.Extensibility.IExtendable, NServiceBus.ICancellableContext, NServiceBus.Pipeline.IBehaviorContext { - [System.Obsolete("Use `EventTypes` instead. Will be removed in version 9.0.0.", true)] - System.Type EventType { get; } System.Type[] EventTypes { get; } } public interface ITransportReceiveContext : NServiceBus.Extensibility.IExtendable, NServiceBus.ICancellableContext, NServiceBus.Pipeline.IBehaviorContext { NServiceBus.Transport.IncomingMessage Message { get; } - [System.Obsolete("The AbortReceiveOperation method is no longer supported. See the upgrade guide fo" + - "r more details. Will be removed in version 9.0.0.", true)] - void AbortReceiveOperation(); } public interface IUnsubscribeContext : NServiceBus.Extensibility.IExtendable, NServiceBus.ICancellableContext, NServiceBus.Pipeline.IBehaviorContext { @@ -2222,8 +1730,6 @@ namespace NServiceBus.Pipeline where T : NServiceBus.Pipeline.IBehavior { } public void RegisterOrReplace(string stepId, T behavior, string description = null) where T : NServiceBus.Pipeline.IBehavior { } - [System.Obsolete(@"Removing behaviors from the pipeline is discouraged, to disable a behavior replace the behavior by an empty one. Documentation: https://docs.particular.net/nservicebus/pipeline/manipulate-with-behaviors. The member currently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public void Remove(string stepId) { } public void Replace(string stepId, System.Type newBehavior, string description = null) { } public void Replace(string stepId, System.Func factoryMethod, string description = null) where T : NServiceBus.Pipeline.IBehavior { } @@ -2411,12 +1917,6 @@ namespace NServiceBus.Sagas public string SagaId { get; } public void AttachNewEntity(NServiceBus.IContainSagaData sagaEntity) { } } - [System.Obsolete("Use `ISagaFinder` instead. Will be removed in version 9.0.0." + - "", true)] - public abstract class IFindSagas - { - protected IFindSagas() { } - } public interface IFinder { } public interface IHandleSagaNotFound { @@ -2538,8 +2038,6 @@ namespace NServiceBus.Settings bool TryGet(out T val); bool TryGet(string key, out T val); } - [System.Obsolete("Use `IReadOnlySettings` instead. Will be removed in version 9.0.0.", true)] - public interface ReadOnlySettings { } public class SettingsHolder : NServiceBus.Settings.IReadOnlySettings { public SettingsHolder() { } @@ -2557,15 +2055,9 @@ namespace NServiceBus.Settings public bool HasSetting() { } public void Set(string key, object value) { } public void Set(System.Action value) { } - [System.Obsolete("Use `Set(T value)` instead. The member currently throws a NotImplementedExcept" + - "ion. Will be removed in version 9.0.0.", true)] - public void Set(object value) { } public void Set(T value) { } public void SetDefault(string key, object value) { } public void SetDefault(System.Action value) { } - [System.Obsolete("Use `SetDefault(T value)` instead. The member currently throws a NotImplemente" + - "dException. Will be removed in version 9.0.0.", true)] - public void SetDefault(object value) { } public void SetDefault(T value) { } public bool TryGet(out T val) { } public bool TryGet(string key, out T val) { } @@ -2576,63 +2068,10 @@ namespace NServiceBus.Support public static class RuntimeEnvironment { public static string MachineName { get; } - [System.Obsolete("Use `HostInfoSettings.UsingHostName` instead. Will be treated as an error from ve" + - "rsion 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete("Use `HostInfoSettings.UsingHostName` instead. Will be removed in version 10.0.0.", true)] public static System.Func MachineNameAction { get; set; } } } -namespace NServiceBus.Timeout.Core -{ - [System.Obsolete("The timeout manager has been removed in favor of native delayed delivery support " + - "provided by transports. See the upgrade guide for more details. Will be removed " + - "in version 9.0.0.", true)] - public interface IPersistTimeouts - { - System.Threading.Tasks.Task Add(NServiceBus.Timeout.Core.TimeoutData timeout, NServiceBus.Extensibility.ContextBag context); - System.Threading.Tasks.Task Peek(string timeoutId, NServiceBus.Extensibility.ContextBag context); - System.Threading.Tasks.Task RemoveTimeoutBy(System.Guid sagaId, NServiceBus.Extensibility.ContextBag context); - System.Threading.Tasks.Task TryRemove(string timeoutId, NServiceBus.Extensibility.ContextBag context); - } - [System.Obsolete("The timeout manager has been removed in favor of native delayed delivery support " + - "provided by transports. See the upgrade guide for more details. Will be removed " + - "in version 9.0.0.", true)] - public interface IQueryTimeouts - { - System.Threading.Tasks.Task GetNextChunk(System.DateTime startSlice); - } - [System.Obsolete("The timeout manager has been removed in favor of native delayed delivery support " + - "provided by transports. See the upgrade guide for more details. Will be removed " + - "in version 9.0.0.", true)] - public class TimeoutData - { - public TimeoutData() { } - public string Destination { get; } - public System.Collections.Generic.Dictionary Headers { get; } - public string Id { get; } - public string OwningTimeoutManager { get; } - public System.Guid SagaId { get; } - public byte[] State { get; } - public System.DateTime Time { get; } - } - [System.Obsolete("The timeout manager has been removed in favor of native delayed delivery support " + - "provided by transports. See the upgrade guide for more details. Will be removed " + - "in version 9.0.0.", true)] - public class TimeoutsChunk - { - public TimeoutsChunk(NServiceBus.Timeout.Core.TimeoutsChunk.Timeout[] dueTimeouts, System.DateTime nextTimeToQuery) { } - public NServiceBus.Timeout.Core.TimeoutsChunk.Timeout[] DueTimeouts { get; } - public System.DateTime NextTimeToQuery { get; } - [System.Obsolete("The timeout manager has been removed in favor of native delayed delivery support " + - "provided by transports. See the upgrade guide for more details. Will be removed " + - "in version 9.0.0.", true)] - public struct Timeout - { - public Timeout(string id, System.DateTime dueTime) { } - public System.DateTime DueTime { get; } - public string Id { get; } - } - } -} namespace NServiceBus.Transport { public enum DispatchConsistency @@ -2666,9 +2105,6 @@ namespace NServiceBus.Transport } public class HostSettings { - [System.Obsolete("Use the overload that accepts a delegate with a cancellation token. The member cu" + - "rrently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public HostSettings(string name, string hostDisplayName, NServiceBus.StartupDiagnosticEntries startupDiagnostic, System.Action criticalErrorAction, bool setupInfrastructure, NServiceBus.Settings.ReadOnlySettings coreSettings = null) { } public HostSettings(string name, string hostDisplayName, NServiceBus.StartupDiagnosticEntries startupDiagnostic, System.Action criticalErrorAction, bool setupInfrastructure, NServiceBus.Settings.IReadOnlySettings coreSettings = null) { } public NServiceBus.Settings.IReadOnlySettings CoreSettings { get; } public System.Action CriticalErrorAction { get; } @@ -2677,37 +2113,6 @@ namespace NServiceBus.Transport public bool SetupInfrastructure { get; } public NServiceBus.StartupDiagnosticEntries StartupDiagnostic { get; } } - [System.Obsolete("The timeout manager has been removed in favor of native delayed delivery support " + - "provided by transports. See the upgrade guide for more details. Will be removed " + - "in version 9.0.0.", true)] - public interface ICancelDeferredMessages - { - System.Threading.Tasks.Task CancelDeferredMessages(string messageKey, NServiceBus.Pipeline.IBehaviorContext context); - } - [System.Obsolete("Queue creation is done by TransportDefinition.Initialize. Will be removed in vers" + - "ion 9.0.0.", true)] - public interface ICreateQueues - { - [System.Obsolete("Queue creation is done by TransportDefinition.Initialize. Will be removed in vers" + - "ion 9.0.0.", true)] - System.Threading.Tasks.Task CreateQueueIfNecessary(NServiceBus.Transport.QueueBindings queueBindings, string identity); - } - [System.Obsolete("The IDispatchMessages interface has been removed. See the upgrade guide for more " + - "details. Use `IMessageDispatcher` instead. Will be removed in version 9.0.0.", true)] - public interface IDispatchMessages - { - System.Threading.Tasks.Task Dispatch(NServiceBus.Transport.TransportOperations outgoingMessages, NServiceBus.Transport.TransportTransaction transaction, NServiceBus.Extensibility.ContextBag context); - } - [System.Obsolete("Use `ISubscriptionManager` instead. Will be removed in version 9.0.0.", true)] - public interface IManageSubscriptions - { - [System.Obsolete("Use `ISubscriptionManager.SubscribeAll` instead. Will be removed in version 9.0.0" + - ".", true)] - System.Threading.Tasks.Task Subscribe(System.Type eventType, NServiceBus.Extensibility.ContextBag context); - [System.Obsolete("Use `ISubscriptionManager.Unsubscribe` instead. Will be removed in version 9.0.0." + - "", true)] - System.Threading.Tasks.Task Unsubscribe(System.Type eventType, NServiceBus.Extensibility.ContextBag context); - } public interface IMessageDispatcher { System.Threading.Tasks.Task Dispatch(NServiceBus.Transport.TransportOperations outgoingMessages, NServiceBus.Transport.TransportTransaction transaction, System.Threading.CancellationToken cancellationToken = default); @@ -2728,16 +2133,6 @@ namespace NServiceBus.Transport NServiceBus.Transport.DispatchProperties Properties { get; } NServiceBus.Transport.DispatchConsistency RequiredDispatchConsistency { get; } } - [System.Obsolete("Use `IMessageReceiver` instead. Will be removed in version 9.0.0.", true)] - public interface IPushMessages - { - [System.Obsolete("Use `IMessageReceiver.Initialize` instead. Will be removed in version 9.0.0.", true)] - System.Threading.Tasks.Task Init(System.Func onMessage, System.Func> onError, NServiceBus.CriticalError criticalError, NServiceBus.Transport.PushSettings settings); - [System.Obsolete("Use `IMessageReceiver.StartReceive` instead. Will be removed in version 9.0.0.", true)] - void Start(NServiceBus.Transport.PushRuntimeSettings limitations); - [System.Obsolete("Use `IMessageReceiver.StopReceive` instead. Will be removed in version 9.0.0.", true)] - System.Threading.Tasks.Task Stop(); - } public interface ISubscriptionManager { System.Threading.Tasks.Task SubscribeAll(NServiceBus.Unicast.Messages.MessageMetadata[] eventTypes, NServiceBus.Extensibility.ContextBag context, System.Threading.CancellationToken cancellationToken = default); @@ -2760,29 +2155,14 @@ namespace NServiceBus.Transport public static NServiceBus.MessageIntent GetMessageIntent(this NServiceBus.Transport.IncomingMessage message) { } public static string GetReplyToAddress(this NServiceBus.Transport.IncomingMessage message) { } } - public static class LogicalAddressExtensions - { - [System.Obsolete("Use `TransportDefinition.ToTransportAddress` instead. The member currently throws" + - " a NotImplementedException. Will be removed in version 9.0.0.", true)] - public static string GetTransportAddress(this NServiceBus.Settings.ReadOnlySettings settings, NServiceBus.LogicalAddress logicalAddress) { } - } public class MessageContext : NServiceBus.Extensibility.IExtendable { - [System.Obsolete("Use `MessageContext(string, Dictionary, ReadonlyMemory, Tra" + - "nsportTransaction, string, ContextBag)` instead. The member currently throws a N" + - "otImplementedException. Will be removed in version 9.0.0.", true)] - public MessageContext(string messageId, System.Collections.Generic.Dictionary headers, byte[] body, NServiceBus.Transport.TransportTransaction transportTransaction, System.Threading.CancellationTokenSource receiveCancellationTokenSource, NServiceBus.Extensibility.ContextBag context) { } public MessageContext(string nativeMessageId, System.Collections.Generic.Dictionary headers, System.ReadOnlyMemory body, NServiceBus.Transport.TransportTransaction transportTransaction, string receiveAddress, NServiceBus.Extensibility.ContextBag context) { } public System.ReadOnlyMemory Body { get; } public NServiceBus.Extensibility.ContextBag Extensions { get; } public System.Collections.Generic.Dictionary Headers { get; } - [System.Obsolete("Use `NativeMessageId` instead. Will be removed in version 9.0.0.", true)] - public string MessageId { get; } public string NativeMessageId { get; } public string ReceiveAddress { get; } - [System.Obsolete("The member currently throws a NotImplementedException. Will be removed in version" + - " 9.0.0.", true)] - public System.Threading.CancellationTokenSource ReceiveCancellationTokenSource { get; } public NServiceBus.Transport.TransportTransaction TransportTransaction { get; } } public class MulticastTransportOperation : NServiceBus.Transport.IOutgoingTransportOperation @@ -2795,34 +2175,6 @@ namespace NServiceBus.Transport } public delegate System.Threading.Tasks.Task OnError(NServiceBus.Transport.ErrorContext errorContext, System.Threading.CancellationToken cancellationToken = default); public delegate System.Threading.Tasks.Task OnMessage(NServiceBus.Transport.MessageContext messageContext, System.Threading.CancellationToken cancellationToken = default); - [System.Obsolete("This type is no longer necessary when implementing a transport. Will be removed i" + - "n version 9.0.0.", true)] - public class OutboundRoutingPolicy - { - [System.Obsolete("This type is no longer necessary when implementing a transport. The member curren" + - "tly throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public OutboundRoutingPolicy(NServiceBus.Transport.OutboundRoutingType sends, NServiceBus.Transport.OutboundRoutingType publishes, NServiceBus.Transport.OutboundRoutingType replies) { } - [System.Obsolete("Use `TransportDefinition.SupportsPublishSubscribe` instead. The member currently " + - "throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public NServiceBus.Transport.OutboundRoutingType Publishes { get; } - [System.Obsolete("This property is no longer necessary when implementing a transport. The member cu" + - "rrently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public NServiceBus.Transport.OutboundRoutingType Replies { get; } - [System.Obsolete("This property is no longer necessary when implementing a transport. The member cu" + - "rrently throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public NServiceBus.Transport.OutboundRoutingType Sends { get; } - } - [System.Obsolete("This enum is no longer necessary when implementing a transport. Will be removed i" + - "n version 9.0.0.", true)] - public enum OutboundRoutingType - { - [System.Obsolete("This enum is no longer necessary when implementing a transport. Will be removed i" + - "n version 9.0.0.", true)] - Unicast = 0, - [System.Obsolete("This enum is no longer necessary when implementing a transport. Will be removed i" + - "n version 9.0.0.", true)] - Multicast = 1, - } public class OutgoingMessage { public OutgoingMessage(string messageId, System.Collections.Generic.Dictionary headers, System.ReadOnlyMemory body) { } @@ -2838,11 +2190,6 @@ namespace NServiceBus.Transport public int MaxConcurrency { get; } public static NServiceBus.Transport.PushRuntimeSettings Default { get; } } - [System.Obsolete("Use `ReceiveSettings` instead. Will be removed in version 9.0.0.", true)] - public class PushSettings - { - public PushSettings() { } - } public class QueueAddress { public QueueAddress(string baseAddress, string discriminator = null, System.Collections.Generic.IReadOnlyDictionary properties = null, string qualifier = null) { } @@ -2855,13 +2202,7 @@ namespace NServiceBus.Transport public class QueueBindings { public QueueBindings() { } - [System.Obsolete("Receiving addresses are automatically registered. The member currently throws a N" + - "otImplementedException. Will be removed in version 9.0.0.", true)] - public System.Collections.Generic.IReadOnlyCollection ReceivingAddresses { get; } public System.Collections.Generic.IReadOnlyCollection SendingAddresses { get; } - [System.Obsolete("Receiving addresses are automatically registered. The member currently throws a N" + - "otImplementedException. Will be removed in version 9.0.0.", true)] - public void BindReceiving(string address) { } public void BindSending(string transportAddress) { } } public class ReceiveSettings @@ -2873,22 +2214,6 @@ namespace NServiceBus.Transport public NServiceBus.Transport.QueueAddress ReceiveAddress { get; } public bool UsePublishSubscribe { get; set; } } - [System.Obsolete("Will be removed in version 9.0.0.", true)] - public class StartupCheckResult - { - [System.Obsolete("Will be removed in version 9.0.0.", true)] - public static readonly NServiceBus.Transport.StartupCheckResult Success; - public StartupCheckResult() { } - [System.Obsolete("The member currently throws a NotImplementedException. Will be removed in version" + - " 9.0.0.", true)] - public string ErrorMessage { get; } - [System.Obsolete("The member currently throws a NotImplementedException. Will be removed in version" + - " 9.0.0.", true)] - public bool Succeeded { get; } - [System.Obsolete("The member currently throws a NotImplementedException. Will be removed in version" + - " 9.0.0.", true)] - public static NServiceBus.Transport.StartupCheckResult Failed(string errorMessage) { } - } public abstract class TransportDefinition { protected TransportDefinition(NServiceBus.TransportTransactionMode defaultTransactionMode, bool supportsDelayedDelivery, bool supportsPublishSubscribe, bool supportsTTBR) { } @@ -2900,8 +2225,7 @@ namespace NServiceBus.Transport public abstract System.Threading.Tasks.Task Initialize(NServiceBus.Transport.HostSettings hostSettings, NServiceBus.Transport.ReceiveSettings[] receivers, string[] sendingAddresses, System.Threading.CancellationToken cancellationToken = default); [System.Obsolete("Inject the ITransportAddressResolver type to access the address translation mecha" + "nism at runtime. See the NServiceBus version 8 upgrade guide for further details" + - ". Will be treated as an error from version 9.0.0. Will be removed in version 10." + - "0.0.", false)] + ". Will be removed in version 10.0.0.", true)] public abstract string ToTransportAddress(NServiceBus.Transport.QueueAddress address); } public abstract class TransportInfrastructure @@ -2926,28 +2250,6 @@ namespace NServiceBus.Transport public System.Collections.Generic.List MulticastTransportOperations { get; } public System.Collections.Generic.List UnicastTransportOperations { get; } } - [System.Obsolete("This type is no longer necessary when implementing a transport. Will be removed i" + - "n version 9.0.0.", true)] - public class TransportSendInfrastructure - { - [System.Obsolete("This type is no longer necessary when implementing a transport. The member curren" + - "tly throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public TransportSendInfrastructure(System.Func dispatcherFactory, System.Func> preStartupCheck) { } - [System.Obsolete("Use `TransportInfrastructure.Dispatcher` instead. The member currently throws a N" + - "otImplementedException. Will be removed in version 9.0.0.", true)] - public System.Func DispatcherFactory { get; } - [System.Obsolete("Pre-startup checks have been removed. The member currently throws a NotImplemente" + - "dException. Will be removed in version 9.0.0.", true)] - public System.Func> PreStartupCheck { get; } - } - [System.Obsolete("This type is no longer necessary when implementing a transport. Will be removed i" + - "n version 9.0.0.", true)] - public class TransportSubscriptionInfrastructure - { - [System.Obsolete("This type is no longer necessary when implementing a transport. The member curren" + - "tly throws a NotImplementedException. Will be removed in version 9.0.0.", true)] - public TransportSubscriptionInfrastructure(System.Func subscriptionManagerFactory) { } - } public sealed class TransportTransaction : NServiceBus.Extensibility.ContextBag { public TransportTransaction() { } @@ -2963,13 +2265,6 @@ namespace NServiceBus.Transport } namespace NServiceBus.Unicast { - [System.Obsolete("Will be removed in version 9.0.0.", true)] - public static class BuilderExtensions - { - [System.Obsolete("Replace usages of ForEach with a foreach loop. The member currently throws a N" + - "otImplementedException. Will be removed in version 9.0.0.", true)] - public static void ForEach(this System.IServiceProvider builder, System.Action action) { } - } public class MessageEventArgs : System.EventArgs { public MessageEventArgs(object msg) { } @@ -3009,23 +2304,15 @@ namespace NServiceBus.Unicast.Messages } namespace NServiceBus.Unicast.Queuing { - [System.Serializable] public class QueueNotFoundException : System.Exception { public QueueNotFoundException() { } - protected QueueNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public QueueNotFoundException(string queue, string message, System.Exception inner) { } public string Queue { get; set; } - public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } } namespace NServiceBus.Unicast.Subscriptions.MessageDrivenSubscriptions { - [System.Obsolete("Will be removed in version 9.0.0.", true)] - public interface IInitializableSubscriptionStorage : NServiceBus.Unicast.Subscriptions.MessageDrivenSubscriptions.ISubscriptionStorage - { - void Init(); - } public interface ISubscriptionStorage { System.Threading.Tasks.Task> GetSubscriberAddressesForMessage(System.Collections.Generic.IEnumerable messageTypes, NServiceBus.Extensibility.ContextBag context, System.Threading.CancellationToken cancellationToken = default); @@ -3066,7 +2353,9 @@ namespace NServiceBus.Unicast.Transport } namespace NServiceBus.UnitOfWork { - [System.Obsolete(@"The unit of work pattern is more straightforward to implement in a pipeline behavior, where the using keyword and try/catch blocks can be used. Use `NServiceBus.Pipeline.Behavior` instead. Will be treated as an error from version 9.0.0. Will be removed in version 10.0.0.", false)] + [System.Obsolete("The unit of work pattern is more straightforward to implement in a pipeline behav" + + "ior, where the using keyword and try/catch blocks can be used. Use `NServiceBus." + + "Pipeline.Behavior` instead. Will be removed in version 10.0.0.", true)] public interface IManageUnitsOfWork { System.Threading.Tasks.Task Begin(); diff --git a/src/NServiceBus.Core.Tests/ApprovalFiles/ActivityDecoratorTests.Verify_promotable_headers.ignored.approved.txt b/src/NServiceBus.Core.Tests/ApprovalFiles/ActivityDecoratorTests.Verify_promotable_headers.ignored.approved.txt index 564065bf3e..215ef5a77e 100644 --- a/src/NServiceBus.Core.Tests/ApprovalFiles/ActivityDecoratorTests.Verify_promotable_headers.ignored.approved.txt +++ b/src/NServiceBus.Core.Tests/ApprovalFiles/ActivityDecoratorTests.Verify_promotable_headers.ignored.approved.txt @@ -14,4 +14,3 @@ Headers.SubscriberEndpoint Headers.DiagnosticsTraceParent Headers.DiagnosticsTraceState Headers.DiagnosticsBaggage -Headers.HeaderName diff --git a/src/NServiceBus.Core.Tests/ApprovalFiles/ActivityDecoratorTests.Verify_promotable_headers.promoted.approved.txt b/src/NServiceBus.Core.Tests/ApprovalFiles/ActivityDecoratorTests.Verify_promotable_headers.promoted.approved.txt index b1ecad1a82..d3889f30ef 100644 --- a/src/NServiceBus.Core.Tests/ApprovalFiles/ActivityDecoratorTests.Verify_promotable_headers.promoted.approved.txt +++ b/src/NServiceBus.Core.Tests/ApprovalFiles/ActivityDecoratorTests.Verify_promotable_headers.promoted.approved.txt @@ -27,6 +27,6 @@ Headers.OriginatingAddress: NServiceBus.OriginatingAddress -> nservicebus.origin Headers.ConversationId: NServiceBus.ConversationId -> nservicebus.conversation_id Headers.PreviousConversationId: NServiceBus.PreviousConversationId -> nservicebus.previous_conversation_id Headers.MessageIntent: NServiceBus.MessageIntent -> nservicebus.message_intent +Headers.NonDurableMessage: NServiceBus.NonDurableMessage -> nservicebus.non_durable Headers.TimeToBeReceived: NServiceBus.TimeToBeReceived -> nservicebus.time_to_be_received Headers.DataBusConfigContentType: NServiceBus.DataBusConfig.ContentType -> nservicebus.databus.content_type -Headers.NonDurableMessage: NServiceBus.NonDurableMessage -> nservicebus.non_durable diff --git a/src/NServiceBus.Core.Tests/ApprovalFiles/NullableAnnotations.ApproveNullableTypes.approved.txt b/src/NServiceBus.Core.Tests/ApprovalFiles/NullableAnnotations.ApproveNullableTypes.approved.txt index d8db0bbcd3..9aa23bd91a 100644 --- a/src/NServiceBus.Core.Tests/ApprovalFiles/NullableAnnotations.ApproveNullableTypes.approved.txt +++ b/src/NServiceBus.Core.Tests/ApprovalFiles/NullableAnnotations.ApproveNullableTypes.approved.txt @@ -48,7 +48,6 @@ NServiceBus.Extensibility.IExtendable NServiceBus.Extensibility.IReadOnlyContextBag NServiceBus.FailedConfig NServiceBus.Faults.DelayedRetryMessage -NServiceBus.Faults.ErrorsNotifications NServiceBus.Faults.FailedMessage NServiceBus.Faults.FaultsHeaderKeys NServiceBus.Faults.ImmediateRetryMessage @@ -111,7 +110,6 @@ NServiceBus.MessageProcessingContextExtensions NServiceBus.MessageProcessingOptimizationExtensions NServiceBus.MessageSessionExtensions NServiceBus.MoveToError -NServiceBus.Notifications NServiceBus.NServiceBusMarkerInterfaceConvention NServiceBus.OnSatelliteMessage NServiceBus.OpenTelemetryConfigurationExtensions From a3b791e6d948353e938046107f49d3a6ecfe12ab Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 15 Aug 2023 17:20:09 -0400 Subject: [PATCH 48/51] Remove binding redirect stuff from AssemblyScanner error messages --- ...oveErrorLog_FileLoadException.approved.txt | 5 +- ...FileLoadException_NServiceBus.approved.txt | 11 +--- ...oadException_NServiceBus_Only.approved.txt | 11 +--- ...adException_NServiceBus_Other.approved.txt | 14 +----- ...rorLog_FileLoadException_Only.approved.txt | 5 +- .../Hosting/Helpers/AssemblyScanner.cs | 50 ++++--------------- 6 files changed, 19 insertions(+), 77 deletions(-) diff --git a/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException.approved.txt b/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException.approved.txt index 788e53de33..6297d6dd98 100644 --- a/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException.approved.txt +++ b/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException.approved.txt @@ -3,6 +3,5 @@ Exceptions: System.Exception: Generic exception 1 System.Exception: Generic exception 2 -It looks like you may be missing binding redirects in the config file for the following assemblies: -NServiceBus.Core.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b50674d1e0c6ce54 -For more information see http://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.100).aspx \ No newline at end of file +FileLoadExceptions: +NServiceBus.Core.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b50674d1e0c6ce54 \ No newline at end of file diff --git a/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_NServiceBus.approved.txt b/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_NServiceBus.approved.txt index 0f0d1d298c..61a5efad26 100644 --- a/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_NServiceBus.approved.txt +++ b/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_NServiceBus.approved.txt @@ -3,12 +3,5 @@ Exceptions: System.Exception: Generic exception 1 System.Exception: Generic exception 2 -Try to add the following binding redirects to the config file: - - - - - - - - \ No newline at end of file +FileLoadExceptions: +NServiceBus.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c \ No newline at end of file diff --git a/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_NServiceBus_Only.approved.txt b/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_NServiceBus_Only.approved.txt index 55b3a48d58..15a91b92bf 100644 --- a/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_NServiceBus_Only.approved.txt +++ b/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_NServiceBus_Only.approved.txt @@ -1,11 +1,4 @@ Could not enumerate all types for 'MyFile'. -Try to add the following binding redirects to the config file: - - - - - - - - \ No newline at end of file +FileLoadExceptions: +NServiceBus.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c \ No newline at end of file diff --git a/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_NServiceBus_Other.approved.txt b/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_NServiceBus_Other.approved.txt index 6263aefd07..4090c1f60e 100644 --- a/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_NServiceBus_Other.approved.txt +++ b/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_NServiceBus_Other.approved.txt @@ -1,15 +1,5 @@ Could not enumerate all types for 'MyFile'. -It looks like you may be missing binding redirects in the config file for the following assemblies: +FileLoadExceptions: NServiceBus.Core.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b50674d1e0c6ce54 -For more information see http://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.100).aspx - -Try to add the following binding redirects to the config file: - - - - - - - - \ No newline at end of file +NServiceBus.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c \ No newline at end of file diff --git a/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_Only.approved.txt b/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_Only.approved.txt index a10d32bc77..8961273cc2 100644 --- a/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_Only.approved.txt +++ b/src/NServiceBus.Core.Tests/ApprovalFiles/ErrorLoggingTest.ApproveErrorLog_FileLoadException_Only.approved.txt @@ -1,5 +1,4 @@ Could not enumerate all types for 'MyFile'. -It looks like you may be missing binding redirects in the config file for the following assemblies: -NServiceBus.Core.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b50674d1e0c6ce54 -For more information see http://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.100).aspx \ No newline at end of file +FileLoadExceptions: +NServiceBus.Core.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b50674d1e0c6ce54 \ No newline at end of file diff --git a/src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs b/src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs index 35bcb02e3a..fc704b154d 100644 --- a/src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs +++ b/src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs @@ -254,38 +254,24 @@ internal static string FormatReflectionTypeLoadException(string fileName, Reflec return sb.ToString(); } - var nsbAssemblyName = typeof(AssemblyScanner).Assembly.GetName(); - var nsbPublicKeyToken = BitConverter.ToString(nsbAssemblyName.GetPublicKeyToken()).Replace("-", string.Empty).ToLowerInvariant(); - var displayBindingRedirects = false; var files = new List(); var sbFileLoadException = new StringBuilder(); var sbGenericException = new StringBuilder(); foreach (var ex in e.LoaderExceptions) { - var loadException = ex as FileLoadException; - - if (loadException?.FileName != null) + if (ex is FileLoadException loadException && loadException.FileName != null) { - var assemblyName = new AssemblyName(loadException.FileName); - var assemblyPublicKeyToken = BitConverter.ToString(assemblyName.GetPublicKeyToken()).Replace("-", string.Empty).ToLowerInvariant(); - if (nsbAssemblyName.Name == assemblyName.Name && - nsbAssemblyName.CultureInfo.ToString() == assemblyName.CultureInfo.ToString() && - nsbPublicKeyToken == assemblyPublicKeyToken) - { - displayBindingRedirects = true; - continue; - } - if (!files.Contains(loadException.FileName)) { files.Add(loadException.FileName); sbFileLoadException.NewLine(loadException.FileName); } - continue; } - - sbGenericException.NewLine(ex.ToString()); + else + { + sbGenericException.NewLine(ex.ToString()); + } } if (sbGenericException.Length > 0) @@ -297,26 +283,8 @@ internal static string FormatReflectionTypeLoadException(string fileName, Reflec if (sbFileLoadException.Length > 0) { sb.AppendLine(); - sb.NewLine("It looks like you may be missing binding redirects in the config file for the following assemblies:"); + sb.NewLine("FileLoadExceptions:"); sb.Append(sbFileLoadException); - sb.NewLine("For more information see http://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.100).aspx"); - } - - if (displayBindingRedirects) - { - sb.AppendLine(); - sb.NewLine("Try to add the following binding redirects to the config file:"); - - const string bindingRedirects = @" - - - - - - -"; - - sb.NewLine(string.Format(bindingRedirects, nsbAssemblyName.Version.ToString(4))); } return sb.ToString(); @@ -432,10 +400,10 @@ bool ShouldScanDependencies(Assembly assembly) return true; } - readonly AssemblyValidator assemblyValidator = new AssemblyValidator(); - internal List AssembliesToSkip = new List(); + readonly AssemblyValidator assemblyValidator = new(); + internal List AssembliesToSkip = new(); internal bool ScanNestedDirectories; - internal List TypesToSkip = new List(); + internal List TypesToSkip = new(); readonly Assembly assemblyToScan; readonly string baseDirectoryToScan; const string NServicebusCoreAssemblyName = "NServiceBus.Core"; From d35686bd2fca35f996d1d942ec7b674a9fde58e8 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Wed, 16 Aug 2023 17:05:35 -0400 Subject: [PATCH 49/51] Update PreObsolete issue link --- .../Learning/LearningTransportConfigurationExtensions.cs | 8 ++++---- src/NServiceBus.Core/Transports/TransportExtensions.cs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/NServiceBus.Core/Transports/Learning/LearningTransportConfigurationExtensions.cs b/src/NServiceBus.Core/Transports/Learning/LearningTransportConfigurationExtensions.cs index e1cdc5e35b..8e4ea30188 100644 --- a/src/NServiceBus.Core/Transports/Learning/LearningTransportConfigurationExtensions.cs +++ b/src/NServiceBus.Core/Transports/Learning/LearningTransportConfigurationExtensions.cs @@ -3,14 +3,14 @@ /// /// Configuration options for the learning transport. /// - [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", + [PreObsolete("https://github.com/Particular/NServiceBus/issues/6811", Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public static class LearningTransportConfigurationExtensions { /// /// Configures NServiceBus to use the given transport. /// - [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", + [PreObsolete("https://github.com/Particular/NServiceBus/issues/6811", ReplacementTypeOrMember = "EndpointConfiguration.UseTransport(TransportDefinition)", Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public static TransportExtensions UseTransport(this EndpointConfiguration config) @@ -28,7 +28,7 @@ public static TransportExtensions UseTransport(this Endpoi /// /// Configures the location where message files are stored. /// - [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", + [PreObsolete("https://github.com/Particular/NServiceBus/issues/6811", ReplacementTypeOrMember = "Use LearningTransport.StorageDirectory", Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public static void StorageDirectory(this TransportExtensions transportExtensions, string path) @@ -39,7 +39,7 @@ public static void StorageDirectory(this TransportExtensions /// /// Allows messages of any size to be sent. /// - [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", + [PreObsolete("https://github.com/Particular/NServiceBus/issues/6811", ReplacementTypeOrMember = "Use LearningTransport.RestrictPayloadSize", Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public static void NoPayloadSizeRestriction(this TransportExtensions transportExtensions) diff --git a/src/NServiceBus.Core/Transports/TransportExtensions.cs b/src/NServiceBus.Core/Transports/TransportExtensions.cs index 3339fe6585..2bd211b8dd 100644 --- a/src/NServiceBus.Core/Transports/TransportExtensions.cs +++ b/src/NServiceBus.Core/Transports/TransportExtensions.cs @@ -6,7 +6,7 @@ /// This class provides implementers of transports with an extension mechanism for custom settings via extension methods. /// /// The transport definition e.g. , etc. - [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", + [PreObsolete("https://github.com/Particular/NServiceBus/issues/6811", Message = "Configure the transport via the TransportDefinition instance's properties", Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public class TransportExtensions where T : TransportDefinition @@ -30,7 +30,7 @@ public TransportExtensions(T transport, RoutingSettings routing) /// /// Routing configuration. /// - [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", + [PreObsolete("https://github.com/Particular/NServiceBus/issues/6811", ReplacementTypeOrMember = "Use EndpointConfiguration.UseTransport() to access routing settings", Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public RoutingSettings Routing() => routing; @@ -38,7 +38,7 @@ public TransportExtensions(T transport, RoutingSettings routing) /// /// Configures the transport to use a specific transaction mode. /// - [PreObsolete("https://github.com/Particular/GeneralPlatformExperience/issues/1403", + [PreObsolete("https://github.com/Particular/NServiceBus/issues/6811", ReplacementTypeOrMember = "TransportDefinition.TransportTransactionMode", Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public TransportExtensions Transactions(TransportTransactionMode transportTransactionMode) From 1b9907de68dda1e14caa3b5da4d79f7d566c6a82 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Wed, 16 Aug 2023 17:37:47 -0400 Subject: [PATCH 50/51] Update PreObsoleteAttribute XML comment --- src/NServiceBus.Core/PreObsoleteAttribute.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NServiceBus.Core/PreObsoleteAttribute.cs b/src/NServiceBus.Core/PreObsoleteAttribute.cs index c36af5b1b3..f8e6ca84b9 100644 --- a/src/NServiceBus.Core/PreObsoleteAttribute.cs +++ b/src/NServiceBus.Core/PreObsoleteAttribute.cs @@ -3,7 +3,7 @@ using System; /// - /// Meant for staging future obsoletes. Mimics the structure of . + /// Meant for staging future obsoletes. /// [AttributeUsage(AttributeTargets.All)] sealed class PreObsoleteAttribute : Attribute From f88ce813826ba21ed5f205fe0daa1d9b14d98c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96hlund?= Date: Thu, 17 Aug 2023 16:24:03 +0200 Subject: [PATCH 51/51] Get rid of AddWithInterfaces --- ...up.Make_sure_things_are_in_DI.approved.txt | 4 -- .../When_registering_components.cs | 52 ------------------- .../Pipeline/PipelineComponent.cs | 2 +- src/NServiceBus.Core/Pipeline/RegisterStep.cs | 2 +- .../Receiving/ReceiveComponent.cs | 2 +- src/NServiceBus.Core/Sagas/Sagas.cs | 6 +-- .../ServiceCollectionExtensions.cs | 19 ------- 7 files changed, 6 insertions(+), 81 deletions(-) delete mode 100644 src/NServiceBus.Core/ServiceCollectionExtensions.cs diff --git a/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_endpoint_is_warmed_up.Make_sure_things_are_in_DI.approved.txt b/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_endpoint_is_warmed_up.Make_sure_things_are_in_DI.approved.txt index 7efa8b8136..f46eb014c9 100644 --- a/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_endpoint_is_warmed_up.Make_sure_things_are_in_DI.approved.txt +++ b/src/NServiceBus.AcceptanceTests/ApprovalFiles/When_endpoint_is_warmed_up.Make_sure_things_are_in_DI.approved.txt @@ -9,13 +9,9 @@ NServiceBus.Unicast.Subscriptions.MessageDrivenSubscriptions.ISubscriptionStorag ----------- Public registrations not used by Core ----------- NServiceBus.CriticalError - Singleton NServiceBus.Hosting.HostInformation - Singleton -NServiceBus.IHandleMessages`1[[NServiceBus.AcceptanceTests.Core.DependencyInjection.When_endpoint_is_warmed_up+SomeMessage, NServiceBus.AcceptanceTests, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null]] - Scoped NServiceBus.IMessageCreator - Singleton NServiceBus.MessageInterfaces.IMessageMapper - Singleton NServiceBus.Persistence.ISynchronizedStorageSession - Scoped -NServiceBus.Pipeline.IBehavior - Transient -NServiceBus.Pipeline.IBehavior`2[[NServiceBus.Pipeline.IIncomingLogicalMessageContext, NServiceBus.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c],[NServiceBus.Pipeline.IIncomingLogicalMessageContext, NServiceBus.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c]] - Transient -NServiceBus.Pipeline.IBehavior`2[[NServiceBus.Pipeline.IIncomingPhysicalMessageContext, NServiceBus.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c],[NServiceBus.Pipeline.IIncomingPhysicalMessageContext, NServiceBus.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c]] - Transient NServiceBus.Pipeline.LogicalMessageFactory - Singleton NServiceBus.Settings.IReadOnlySettings - Singleton NServiceBus.Transport.ISubscriptionManager - Singleton diff --git a/src/NServiceBus.ContainerTests/When_registering_components.cs b/src/NServiceBus.ContainerTests/When_registering_components.cs index 998e713723..fec99164e5 100644 --- a/src/NServiceBus.ContainerTests/When_registering_components.cs +++ b/src/NServiceBus.ContainerTests/When_registering_components.cs @@ -5,8 +5,6 @@ namespace NServiceBus.ContainerTests using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.DependencyInjection; - using NServiceBus; - using NServiceBus.ObjectBuilder; using NUnit.Framework; @@ -77,47 +75,6 @@ public void Registering_the_same_singleton_for_different_interfaces_should_be_su Assert.AreEqual(serviceProvider.GetService(typeof(ISingleton2)), singleton); } - [Test] - public void Concrete_classes_should_get_the_same_lifecycle_as_their_interfaces() - { - var serviceCollection = new ServiceCollection(); - serviceCollection.AddWithInterfaces(typeof(SingletonComponent), ServiceLifetime.Singleton); - - var serviceProvider = serviceCollection.BuildServiceProvider(); - Assert.AreSame(serviceProvider.GetService(typeof(SingletonComponent)), serviceProvider.GetService(typeof(ISingletonComponent))); - } - - [Test] - public void All_implemented_interfaces_should_be_registered() - { - var serviceCollection = new ServiceCollection(); - serviceCollection.AddWithInterfaces(typeof(ComponentWithMultipleInterfaces), ServiceLifetime.Transient); - Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ISomeInterface))); - Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ISomeOtherInterface))); - Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(IYetAnotherInterface))); - - var serviceProvider = serviceCollection.BuildServiceProvider(); - Assert.AreEqual(1, serviceProvider.GetServices(typeof(IYetAnotherInterface)).Count()); - } - - [Test] - public void Multiple_implementations_should_be_supported() - { - var serviceCollection = new ServiceCollection(); - serviceCollection.AddWithInterfaces(typeof(SomeClass), ServiceLifetime.Scoped); - serviceCollection.AddWithInterfaces(typeof(SomeOtherClass), ServiceLifetime.Scoped); - - var serviceProvider = serviceCollection.BuildServiceProvider(); - Assert.NotNull(serviceProvider.GetService(typeof(SomeClass))); - Assert.AreEqual(2, serviceProvider.GetServices(typeof(ISomeInterface)).Count()); - - using (var scope = serviceProvider.CreateScope()) - { - Assert.NotNull(scope.ServiceProvider.GetService(typeof(SomeClass))); - Assert.AreEqual(2, scope.ServiceProvider.GetServices(typeof(ISomeInterface)).Count()); - } - } - [Test] public void Given_lookupType_should_be_used_as_service_in_the_registration_when_RegisterSingleton() { @@ -133,15 +90,6 @@ public void Given_lookupType_should_be_used_as_service_in_the_registration_when_ Assert.AreEqual(expected, scope.ServiceProvider.GetService(typeof(SomeClass))); } } - - [Test] - public void Generic_interfaces_should_be_registered() - { - var serviceCollection = new ServiceCollection(); - serviceCollection.AddWithInterfaces(typeof(ComponentWithGenericInterface), ServiceLifetime.Transient); - - Assert.True(serviceCollection.Any(sd => sd.ServiceType == typeof(ISomeGenericInterface))); - } } diff --git a/src/NServiceBus.Core/Pipeline/PipelineComponent.cs b/src/NServiceBus.Core/Pipeline/PipelineComponent.cs index 3749e2abed..d519c227e8 100644 --- a/src/NServiceBus.Core/Pipeline/PipelineComponent.cs +++ b/src/NServiceBus.Core/Pipeline/PipelineComponent.cs @@ -17,7 +17,7 @@ public static PipelineComponent Initialize(PipelineSettings settings, HostingCom foreach (var registeredBehavior in modifications.Replacements) { - hostingConfiguration.Services.AddWithInterfaces(registeredBehavior.BehaviorType, ServiceLifetime.Transient); + hostingConfiguration.Services.AddTransient(registeredBehavior.BehaviorType); } foreach (var step in modifications.Additions) diff --git a/src/NServiceBus.Core/Pipeline/RegisterStep.cs b/src/NServiceBus.Core/Pipeline/RegisterStep.cs index b3015dfdbf..9331adb916 100644 --- a/src/NServiceBus.Core/Pipeline/RegisterStep.cs +++ b/src/NServiceBus.Core/Pipeline/RegisterStep.cs @@ -55,7 +55,7 @@ internal void ApplyContainerRegistration(IServiceCollection serviceCollection) return; } - serviceCollection.AddWithInterfaces(BehaviorType, ServiceLifetime.Transient); + serviceCollection.AddTransient(BehaviorType); } /// diff --git a/src/NServiceBus.Core/Receiving/ReceiveComponent.cs b/src/NServiceBus.Core/Receiving/ReceiveComponent.cs index 7ec0baa10a..6199b34749 100644 --- a/src/NServiceBus.Core/Receiving/ReceiveComponent.cs +++ b/src/NServiceBus.Core/Receiving/ReceiveComponent.cs @@ -257,7 +257,7 @@ static void RegisterMessageHandlers(MessageHandlerRegistry handlerRegistry, List foreach (var t in types.Where(IsMessageHandler)) { - serviceCollection.AddWithInterfaces(t, ServiceLifetime.Scoped); + serviceCollection.AddScoped(t); handlerRegistry.RegisterHandler(t); } diff --git a/src/NServiceBus.Core/Sagas/Sagas.cs b/src/NServiceBus.Core/Sagas/Sagas.cs index ada1b27ea3..4fd7667588 100644 --- a/src/NServiceBus.Core/Sagas/Sagas.cs +++ b/src/NServiceBus.Core/Sagas/Sagas.cs @@ -64,7 +64,7 @@ protected internal override void Setup(FeatureConfigurationContext context) { if (IsSagaNotFoundHandler(t)) { - context.Services.AddWithInterfaces(t, ServiceLifetime.Transient); + context.Services.AddTransient(typeof(IHandleSagaNotFound), t); } } @@ -78,11 +78,11 @@ static void RegisterCustomFindersInContainer(IServiceCollection container, IEnum { foreach (var finder in sagaMetaModel.SelectMany(m => m.Finders)) { - container.AddWithInterfaces(finder.Type, ServiceLifetime.Transient); + container.AddTransient(finder.Type); if (finder.Properties.TryGetValue("custom-finder-clr-type", out var customFinderType)) { - container.AddWithInterfaces((Type)customFinderType, ServiceLifetime.Transient); + container.AddTransient((Type)customFinderType); } } } diff --git a/src/NServiceBus.Core/ServiceCollectionExtensions.cs b/src/NServiceBus.Core/ServiceCollectionExtensions.cs deleted file mode 100644 index 4af93f30db..0000000000 --- a/src/NServiceBus.Core/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace NServiceBus -{ - using System; - using Microsoft.Extensions.DependencyInjection; - - // Rename this class to ServiceCollectionExtensions when public version is removed from obsoletes. - static class ServiceCollectionExtensionsInternal - { - public static void AddWithInterfaces(this IServiceCollection serviceCollection, Type serviceType, ServiceLifetime serviceLifetime) - { - serviceCollection.Add(new ServiceDescriptor(serviceType, serviceType, serviceLifetime)); - - foreach (var interfaceType in serviceType.GetInterfaces()) - { - serviceCollection.Add(new ServiceDescriptor(interfaceType, sp => sp.GetService(serviceType), serviceLifetime)); - } - } - } -}