diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08f9576af..abb0851c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,6 @@ jobs: uses: actions/setup-dotnet@v4.0.0 with: 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 7146947bc..e942473fb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,6 @@ jobs: uses: actions/setup-dotnet@v4.0.0 with: dotnet-version: 8.0.x - dotnet-quality: 'preview' - name: Build run: dotnet build src --configuration Release - name: Sign NuGet packages diff --git a/nugets/.gitkeep b/nugets/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/ConfigureEndpointSqlServerTransport.cs b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/ConfigureEndpointSqlServerTransport.cs index 345a95923..cbd7cf38b 100644 --- a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/ConfigureEndpointSqlServerTransport.cs +++ b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/ConfigureEndpointSqlServerTransport.cs @@ -1,12 +1,8 @@ using System; -#if SYSTEMDATASQLCLIENT -using System.Data.SqlClient; -#else -using Microsoft.Data.SqlClient; -#endif using System.Text; using System.Threading; using System.Threading.Tasks; +using Microsoft.Data.SqlClient; using NServiceBus; using NServiceBus.AcceptanceTesting.Support; diff --git a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/MultiCatalog/MultiCatalogAcceptanceTest.cs b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/MultiCatalog/MultiCatalogAcceptanceTest.cs index d7930b56c..3cc3f8c04 100644 --- a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/MultiCatalog/MultiCatalogAcceptanceTest.cs +++ b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/MultiCatalog/MultiCatalogAcceptanceTest.cs @@ -1,11 +1,7 @@ namespace NServiceBus.Transport.SqlServer.AcceptanceTests.MultiCatalog { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else using Microsoft.Data.SqlClient; -#endif using NServiceBus.AcceptanceTests; public class MultiCatalogAcceptanceTest : NServiceBusAcceptanceTest diff --git a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/MultiCatalog/SqlUtilities.cs b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/MultiCatalog/SqlUtilities.cs index a6e46c161..1f62fd112 100644 --- a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/MultiCatalog/SqlUtilities.cs +++ b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/MultiCatalog/SqlUtilities.cs @@ -1,22 +1,18 @@ namespace NServiceBus.Transport.SqlServer.AcceptanceTests.MultiCatalog { -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System; - using System.Threading.Tasks; using System.Threading; + using System.Threading.Tasks; + using Microsoft.Data.SqlClient; public static class SqlUtilities { public static Task CheckIfTableExists(string catalogName, string schemaName, string tableName, SqlConnection connection, CancellationToken cancellationToken = default) { - Guard.AgainstNull("catalogName", catalogName); - Guard.AgainstNull("schemaName", schemaName); - Guard.AgainstNull("tableName", tableName); - Guard.AgainstNull("connection", connection); + ArgumentNullException.ThrowIfNull(catalogName); + ArgumentNullException.ThrowIfNull(schemaName); + ArgumentNullException.ThrowIfNull(tableName); + ArgumentNullException.ThrowIfNull(connection); return RunCommand(connection, async (command, token) => { @@ -31,10 +27,10 @@ public static Task CheckIfTableExists(string catalogName, string schemaNam public static Task DropTable(string catalogName, string schemaName, string tableName, SqlConnection connection, CancellationToken cancellationToken = default) { - Guard.AgainstNull("catalogName", catalogName); - Guard.AgainstNull("schemaName", schemaName); - Guard.AgainstNull("tableName", tableName); - Guard.AgainstNull("connection", connection); + ArgumentNullException.ThrowIfNull(catalogName); + ArgumentNullException.ThrowIfNull(schemaName); + ArgumentNullException.ThrowIfNull(tableName); + ArgumentNullException.ThrowIfNull(connection); return RunCommand(connection, async (command, token) => { @@ -49,8 +45,8 @@ public static Task DropTable(string catalogName, string schemaName, string table static async Task RunCommand(SqlConnection connection, Func> action, CancellationToken cancellationToken) { - Guard.AgainstNull("connetion", connection); - Guard.AgainstNull("action", action); + ArgumentNullException.ThrowIfNull(connection); + ArgumentNullException.ThrowIfNull(action); bool weOpenedTheConnection = false; @@ -62,10 +58,9 @@ static async Task RunCommand(SqlConnection connection, Func - + diff --git a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/NativeTimeouts/When_configured_to_purge_expired_messages_at_startup.cs b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/NativeTimeouts/When_configured_to_purge_expired_messages_at_startup.cs index edb706c97..e0cfa1e1c 100644 --- a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/NativeTimeouts/When_configured_to_purge_expired_messages_at_startup.cs +++ b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/NativeTimeouts/When_configured_to_purge_expired_messages_at_startup.cs @@ -4,11 +4,7 @@ using System.Collections.Generic; using System.Data.Common; using System.Threading.Tasks; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else using Microsoft.Data.SqlClient; -#endif using NServiceBus.AcceptanceTesting; using NServiceBus.AcceptanceTesting.Customization; using NServiceBus.AcceptanceTests; diff --git a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/TimeToBeReceived/When_queue_contains_expired_messages.cs b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/TimeToBeReceived/When_queue_contains_expired_messages.cs index 505859182..f307c265c 100644 --- a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/TimeToBeReceived/When_queue_contains_expired_messages.cs +++ b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/TimeToBeReceived/When_queue_contains_expired_messages.cs @@ -1,15 +1,11 @@ namespace NServiceBus.Transport.SqlServer.AcceptanceTests.TimeToBeReceived { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading.Tasks; using AcceptanceTesting; using AcceptanceTesting.Customization; using Configuration.AdvancedExtensibility; + using Microsoft.Data.SqlClient; using NServiceBus.AcceptanceTests; using NServiceBus.AcceptanceTests.EndpointTemplates; using NUnit.Framework; diff --git a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_a_corrupted_message_is_received.cs b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_a_corrupted_message_is_received.cs index 6bca13172..e8abb9177 100644 --- a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_a_corrupted_message_is_received.cs +++ b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_a_corrupted_message_is_received.cs @@ -2,17 +2,13 @@ { using System; using System.Data; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Linq; using System.Text; using System.Threading.Tasks; using AcceptanceTesting; using AcceptanceTesting.Customization; using Logging; + using Microsoft.Data.SqlClient; using NServiceBus.AcceptanceTests; using NServiceBus.AcceptanceTests.EndpointTemplates; using NUnit.Framework; diff --git a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_connection_in_receive_context.cs b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_connection_in_receive_context.cs index 3190311c3..713b14bf8 100644 --- a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_connection_in_receive_context.cs +++ b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_connection_in_receive_context.cs @@ -1,14 +1,10 @@ namespace NServiceBus.Transport.SqlServer.AcceptanceTests { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading.Tasks; using System.Transactions; using AcceptanceTesting; + using Microsoft.Data.SqlClient; using NServiceBus.AcceptanceTests; using NServiceBus.AcceptanceTests.EndpointTemplates; using NUnit.Framework; diff --git a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_connection_outside_receive_context.cs b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_connection_outside_receive_context.cs index 704a41c84..1f6eedee3 100644 --- a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_connection_outside_receive_context.cs +++ b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_connection_outside_receive_context.cs @@ -1,14 +1,10 @@ namespace NServiceBus.Transport.SqlServer.AcceptanceTests { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading.Tasks; using System.Transactions; using AcceptanceTesting; + using Microsoft.Data.SqlClient; using NServiceBus.AcceptanceTests; using NServiceBus.AcceptanceTests.EndpointTemplates; using NUnit.Framework; diff --git a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_transaction_in_receive_context.cs b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_transaction_in_receive_context.cs index e5ac740f0..939b194ec 100644 --- a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_transaction_in_receive_context.cs +++ b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_transaction_in_receive_context.cs @@ -1,14 +1,10 @@ namespace NServiceBus.Transport.SqlServer.AcceptanceTests { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading.Tasks; using System.Transactions; using AcceptanceTesting; + using Microsoft.Data.SqlClient; using NServiceBus.AcceptanceTests; using NServiceBus.AcceptanceTests.EndpointTemplates; using NUnit.Framework; diff --git a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_transaction_outside_receive_context.cs b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_transaction_outside_receive_context.cs index 9b73ca945..4259208f1 100644 --- a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_transaction_outside_receive_context.cs +++ b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_passing_custom_transaction_outside_receive_context.cs @@ -1,13 +1,9 @@ namespace NServiceBus.Transport.SqlServer.AcceptanceTests { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading.Tasks; using AcceptanceTesting; + using Microsoft.Data.SqlClient; using NServiceBus.AcceptanceTests; using NServiceBus.AcceptanceTests.EndpointTemplates; using NUnit.Framework; diff --git a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_using_column_encrypted_connection.cs b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_using_column_encrypted_connection.cs index 80bfe4513..358246d0b 100644 --- a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_using_column_encrypted_connection.cs +++ b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_using_column_encrypted_connection.cs @@ -1,14 +1,10 @@ namespace NServiceBus.Transport.SqlServer.AcceptanceTests { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading.Tasks; using AcceptanceTesting; using AcceptanceTesting.Customization; + using Microsoft.Data.SqlClient; using NServiceBus.AcceptanceTests; using NUnit.Framework; @@ -17,9 +13,6 @@ public class When_using_column_encrypted_connection : NServiceBusAcceptanceTest [Test] public async Task Should_work() { -#if SYSTEMDATASQLCLIENT && NET - Assert.Ignore("System.Data.SqlClient doesn't support this setting on .NET (works on .NET Framework)"); -#endif var ctx = await Scenario.Define() .WithEndpoint(b => b.When((bus, c) => bus.SendLocal(new Message()))) .Done(c => c.MessageReceived) diff --git a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_using_custom_connection_factory.cs b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_using_custom_connection_factory.cs index d80ffc049..89668361d 100644 --- a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_using_custom_connection_factory.cs +++ b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_using_custom_connection_factory.cs @@ -1,14 +1,10 @@ namespace NServiceBus.Transport.SqlServer.AcceptanceTests { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading.Tasks; using AcceptanceTesting; using AcceptanceTesting.Customization; + using Microsoft.Data.SqlClient; using NServiceBus.AcceptanceTests; using NUnit.Framework; diff --git a/src/NServiceBus.Transport.SqlServer.IntegrationTests/NServiceBus.Transport.SqlServer.IntegrationTests.csproj b/src/NServiceBus.Transport.SqlServer.IntegrationTests/NServiceBus.Transport.SqlServer.IntegrationTests.csproj index 0f2474ee6..843791a38 100644 --- a/src/NServiceBus.Transport.SqlServer.IntegrationTests/NServiceBus.Transport.SqlServer.IntegrationTests.csproj +++ b/src/NServiceBus.Transport.SqlServer.IntegrationTests/NServiceBus.Transport.SqlServer.IntegrationTests.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/NServiceBus.Transport.SqlServer.IntegrationTests/When_dispatching_messages.cs b/src/NServiceBus.Transport.SqlServer.IntegrationTests/When_dispatching_messages.cs index c8cbf3443..130be8e93 100644 --- a/src/NServiceBus.Transport.SqlServer.IntegrationTests/When_dispatching_messages.cs +++ b/src/NServiceBus.Transport.SqlServer.IntegrationTests/When_dispatching_messages.cs @@ -2,19 +2,15 @@ { using System; using System.Collections.Generic; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif + using System.Threading; using System.Threading.Tasks; using Extensibility; + using Microsoft.Data.SqlClient; using NUnit.Framework; using Routing; - using Transport; using SqlServer; + using Transport; using Unicast.Queuing; - using System.Threading; public class When_dispatching_messages { diff --git a/src/NServiceBus.Transport.SqlServer.IntegrationTests/When_receiving_messages.cs b/src/NServiceBus.Transport.SqlServer.IntegrationTests/When_receiving_messages.cs index 1bc165212..3c4746cfc 100644 --- a/src/NServiceBus.Transport.SqlServer.IntegrationTests/When_receiving_messages.cs +++ b/src/NServiceBus.Transport.SqlServer.IntegrationTests/When_receiving_messages.cs @@ -2,16 +2,12 @@ { using System; using System.Linq; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading; using System.Threading.Tasks; + using Microsoft.Data.SqlClient; using NUnit.Framework; - using Transport; using SqlServer; + using Transport; public class When_receiving_messages { diff --git a/src/NServiceBus.Transport.SqlServer.IntegrationTests/When_recoverable_column_is_removed.cs b/src/NServiceBus.Transport.SqlServer.IntegrationTests/When_recoverable_column_is_removed.cs index 99c620287..0dcdc66c9 100644 --- a/src/NServiceBus.Transport.SqlServer.IntegrationTests/When_recoverable_column_is_removed.cs +++ b/src/NServiceBus.Transport.SqlServer.IntegrationTests/When_recoverable_column_is_removed.cs @@ -2,18 +2,14 @@ { using System; using System.Collections.Generic; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif + using System.Threading; using System.Threading.Tasks; using Extensibility; + using Microsoft.Data.SqlClient; using NUnit.Framework; using Routing; - using Transport; using SqlServer; - using System.Threading; + using Transport; public class When_recoverable_column_is_removed { diff --git a/src/NServiceBus.Transport.SqlServer.TransportTests/ConfigureSqlServerTransportInfrastructure.cs b/src/NServiceBus.Transport.SqlServer.TransportTests/ConfigureSqlServerTransportInfrastructure.cs index eeb3981c7..50d7650d4 100644 --- a/src/NServiceBus.Transport.SqlServer.TransportTests/ConfigureSqlServerTransportInfrastructure.cs +++ b/src/NServiceBus.Transport.SqlServer.TransportTests/ConfigureSqlServerTransportInfrastructure.cs @@ -1,11 +1,7 @@ using System; using System.Threading; -#if SYSTEMDATASQLCLIENT -using System.Data.SqlClient; -#else -using Microsoft.Data.SqlClient; -#endif using System.Threading.Tasks; +using Microsoft.Data.SqlClient; using NServiceBus; using NServiceBus.Transport; using NServiceBus.TransportTests; @@ -41,7 +37,7 @@ public async Task Configure(TransportDefinition transpo "mainReceiver", queueAddress, transportDefinition.SupportsPublishSubscribe, - true, + false, errorQueueName) }; diff --git a/src/NServiceBus.Transport.SqlServer.TransportTests/NServiceBus.Transport.SqlServer.TransportTests.csproj b/src/NServiceBus.Transport.SqlServer.TransportTests/NServiceBus.Transport.SqlServer.TransportTests.csproj index fae9261e0..7547aad7b 100644 --- a/src/NServiceBus.Transport.SqlServer.TransportTests/NServiceBus.Transport.SqlServer.TransportTests.csproj +++ b/src/NServiceBus.Transport.SqlServer.TransportTests/NServiceBus.Transport.SqlServer.TransportTests.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -13,13 +13,9 @@ - + - - - - \ No newline at end of file diff --git a/src/NServiceBus.Transport.SqlServer.UnitTests/NServiceBus.Transport.SqlServer.UnitTests.csproj b/src/NServiceBus.Transport.SqlServer.UnitTests/NServiceBus.Transport.SqlServer.UnitTests.csproj index 127193d7f..c7ce56479 100644 --- a/src/NServiceBus.Transport.SqlServer.UnitTests/NServiceBus.Transport.SqlServer.UnitTests.csproj +++ b/src/NServiceBus.Transport.SqlServer.UnitTests/NServiceBus.Transport.SqlServer.UnitTests.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/NServiceBus.Transport.SqlServer/Addressing/CanonicalQueueAddress.cs b/src/NServiceBus.Transport.SqlServer/Addressing/CanonicalQueueAddress.cs index 028a40722..1ffba46cd 100644 --- a/src/NServiceBus.Transport.SqlServer/Addressing/CanonicalQueueAddress.cs +++ b/src/NServiceBus.Transport.SqlServer/Addressing/CanonicalQueueAddress.cs @@ -1,14 +1,16 @@ namespace NServiceBus.Transport.SqlServer { + using System; using static NameHelper; class CanonicalQueueAddress { public CanonicalQueueAddress(string table, string schemaName, string catalogName) { - Guard.AgainstNullAndEmpty(nameof(table), table); - Guard.AgainstNullAndEmpty(nameof(schemaName), schemaName); - Guard.AgainstNullAndEmpty(nameof(catalogName), catalogName); + ArgumentException.ThrowIfNullOrWhiteSpace(table); + ArgumentException.ThrowIfNullOrWhiteSpace(schemaName); + ArgumentException.ThrowIfNullOrWhiteSpace(catalogName); + Table = table; Catalog = catalogName; Schema = schemaName; diff --git a/src/NServiceBus.Transport.SqlServer/Addressing/EndpointAddressConfiguration.cs b/src/NServiceBus.Transport.SqlServer/Addressing/EndpointAddressConfiguration.cs index 7a9c7d248..e3704cd09 100644 --- a/src/NServiceBus.Transport.SqlServer/Addressing/EndpointAddressConfiguration.cs +++ b/src/NServiceBus.Transport.SqlServer/Addressing/EndpointAddressConfiguration.cs @@ -18,7 +18,7 @@ public static class EndpointAddressConfiguration /// Custom schema value. public static void UseSchemaForEndpoint(this RoutingSettings settings, string endpointName, string schema) { - Guard.AgainstNull(nameof(endpointName), endpointName); + ArgumentNullException.ThrowIfNull(endpointName); var localEndpointName = settings.GetSettings().EndpointName(); @@ -43,7 +43,7 @@ public static void UseSchemaForEndpoint(this RoutingSettings settings, string en /// Custom catalog value. public static void UseCatalogForEndpoint(this RoutingSettings settings, string endpointName, string catalog) { - Guard.AgainstNull(nameof(endpointName), endpointName); + ArgumentNullException.ThrowIfNull(endpointName); var localEndpointName = settings.GetSettings().EndpointName(); diff --git a/src/NServiceBus.Transport.SqlServer/Addressing/QueueAddress.cs b/src/NServiceBus.Transport.SqlServer/Addressing/QueueAddress.cs index 40e9f95ec..ef0794880 100644 --- a/src/NServiceBus.Transport.SqlServer/Addressing/QueueAddress.cs +++ b/src/NServiceBus.Transport.SqlServer/Addressing/QueueAddress.cs @@ -7,7 +7,8 @@ class QueueAddress { public QueueAddress(string table, string schemaName, string catalogName) { - Guard.AgainstNullAndEmpty(nameof(table), table); + ArgumentException.ThrowIfNullOrWhiteSpace(table); + Table = table; Catalog = SafeUnquote(catalogName); Schema = SafeUnquote(schemaName); diff --git a/src/NServiceBus.Transport.SqlServer/Addressing/QueueAddressTranslator.cs b/src/NServiceBus.Transport.SqlServer/Addressing/QueueAddressTranslator.cs index 3e76d560b..2e08e58fc 100644 --- a/src/NServiceBus.Transport.SqlServer/Addressing/QueueAddressTranslator.cs +++ b/src/NServiceBus.Transport.SqlServer/Addressing/QueueAddressTranslator.cs @@ -1,5 +1,6 @@ namespace NServiceBus.Transport.SqlServer { + using System; using System.Collections.Concurrent; using System.Linq; @@ -7,7 +8,7 @@ class QueueAddressTranslator { public QueueAddressTranslator(string defaultCatalog, string defaultSchema, string defaultSchemaOverride, QueueSchemaAndCatalogOptions queueOptions) { - Guard.AgainstNullAndEmpty(nameof(defaultSchema), defaultSchema); + ArgumentException.ThrowIfNullOrWhiteSpace(defaultSchema); DefaultCatalog = defaultCatalog; DefaultSchema = string.IsNullOrWhiteSpace(defaultSchemaOverride) ? defaultSchema : defaultSchemaOverride; @@ -52,9 +53,9 @@ static string Override(string configuredValue, string addressValue, string defau return configuredValue ?? addressValue ?? defaultValue; } - QueueSchemaAndCatalogOptions queueOptions; - ConcurrentDictionary physicalAddressCache = new(); - ConcurrentDictionary logicalAddressCache = new(); + readonly QueueSchemaAndCatalogOptions queueOptions; + readonly ConcurrentDictionary logicalAddressCache = new(); + readonly ConcurrentDictionary physicalAddressCache = new(); record struct AddressKey(string BaseAddress, string Discriminator, string Qualifier, string Schema, string Catalog) { diff --git a/src/NServiceBus.Transport.SqlServer/Configuration/ConnectionPoolValidator.cs b/src/NServiceBus.Transport.SqlServer/Configuration/ConnectionPoolValidator.cs index ddeb6676b..7f2e7a069 100644 --- a/src/NServiceBus.Transport.SqlServer/Configuration/ConnectionPoolValidator.cs +++ b/src/NServiceBus.Transport.SqlServer/Configuration/ConnectionPoolValidator.cs @@ -1,11 +1,7 @@ namespace NServiceBus.Transport.SqlServer { using System.Data.Common; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else using Microsoft.Data.SqlClient; -#endif class ConnectionPoolValidator { diff --git a/src/NServiceBus.Transport.SqlServer/Configuration/DelayedDeliverySettings.cs b/src/NServiceBus.Transport.SqlServer/Configuration/DelayedDeliverySettings.cs index 5dd4e6689..a59fc224f 100644 --- a/src/NServiceBus.Transport.SqlServer/Configuration/DelayedDeliverySettings.cs +++ b/src/NServiceBus.Transport.SqlServer/Configuration/DelayedDeliverySettings.cs @@ -10,7 +10,7 @@ Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public partial class DelayedDeliverySettings { - DelayedDeliveryOptions options; + readonly DelayedDeliveryOptions options; internal DelayedDeliverySettings(DelayedDeliveryOptions options) => this.options = options; @@ -23,7 +23,7 @@ public partial class DelayedDeliverySettings Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public void TableSuffix(string suffix) { - Guard.AgainstNullAndEmpty(nameof(suffix), suffix); + ArgumentException.ThrowIfNullOrWhiteSpace(suffix); options.TableSuffix = suffix; } @@ -53,7 +53,7 @@ public void BatchSize(int batchSize) Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public class SubscriptionSettings { - SubscriptionOptions options; + readonly SubscriptionOptions options; internal SubscriptionSettings(SubscriptionOptions options) => this.options = options; @@ -77,7 +77,8 @@ public class SubscriptionSettings Note = "Should not be converted to an ObsoleteEx until API mismatch described in issue is resolved.")] public void CacheSubscriptionInformationFor(TimeSpan timeSpan) { - Guard.AgainstNegativeAndZero(nameof(timeSpan), timeSpan); + ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(timeSpan, TimeSpan.Zero); + options.CacheInvalidationPeriod = timeSpan; } diff --git a/src/NServiceBus.Transport.SqlServer/Configuration/SqlConnectionFactory.cs b/src/NServiceBus.Transport.SqlServer/Configuration/SqlConnectionFactory.cs index 4d9103591..02ce4833f 100644 --- a/src/NServiceBus.Transport.SqlServer/Configuration/SqlConnectionFactory.cs +++ b/src/NServiceBus.Transport.SqlServer/Configuration/SqlConnectionFactory.cs @@ -1,14 +1,10 @@ namespace NServiceBus.Transport.SqlServer { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif + using System.Threading; using System.Threading.Tasks; using Logging; - using System.Threading; + using Microsoft.Data.SqlClient; class SqlConnectionFactory { diff --git a/src/NServiceBus.Transport.SqlServer/Configuration/SqlServerTransportSettingsExtensions.cs b/src/NServiceBus.Transport.SqlServer/Configuration/SqlServerTransportSettingsExtensions.cs index fe784abce..f2dd2c4a5 100644 --- a/src/NServiceBus.Transport.SqlServer/Configuration/SqlServerTransportSettingsExtensions.cs +++ b/src/NServiceBus.Transport.SqlServer/Configuration/SqlServerTransportSettingsExtensions.cs @@ -2,14 +2,10 @@ namespace NServiceBus { -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System; using System.Threading.Tasks; using System.Transactions; + using Microsoft.Data.SqlClient; using Transport.SqlServer; /// diff --git a/src/NServiceBus.Transport.SqlServer/DelayedDelivery/DelayedDeliveryOptions.cs b/src/NServiceBus.Transport.SqlServer/DelayedDelivery/DelayedDeliveryOptions.cs index ce0852eb9..30db006e9 100644 --- a/src/NServiceBus.Transport.SqlServer/DelayedDelivery/DelayedDeliveryOptions.cs +++ b/src/NServiceBus.Transport.SqlServer/DelayedDelivery/DelayedDeliveryOptions.cs @@ -20,7 +20,8 @@ public string TableSuffix get => tableSuffix; set { - Guard.AgainstNullAndEmpty(nameof(tableSuffix), value); + ArgumentException.ThrowIfNullOrWhiteSpace(value); + tableSuffix = value; } } @@ -33,10 +34,7 @@ public int BatchSize get => batchSize; set { - if (value <= 0) - { - throw new ArgumentException("Batch size has to be a positive number", nameof(batchSize)); - } + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(value); batchSize = value; } diff --git a/src/NServiceBus.Transport.SqlServer/DelayedDelivery/DelayedMessageTable.cs b/src/NServiceBus.Transport.SqlServer/DelayedDelivery/DelayedMessageTable.cs index e3a82f0ab..4f32feba7 100644 --- a/src/NServiceBus.Transport.SqlServer/DelayedDelivery/DelayedMessageTable.cs +++ b/src/NServiceBus.Transport.SqlServer/DelayedDelivery/DelayedMessageTable.cs @@ -1,13 +1,9 @@ namespace NServiceBus.Transport.SqlServer { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading; using System.Threading.Tasks; + using Microsoft.Data.SqlClient; using Transport; interface IDelayedMessageStore diff --git a/src/NServiceBus.Transport.SqlServer/DelayedDelivery/StoreDelayedMessageCommand.cs b/src/NServiceBus.Transport.SqlServer/DelayedDelivery/StoreDelayedMessageCommand.cs index 5ca19252f..44d4f6920 100644 --- a/src/NServiceBus.Transport.SqlServer/DelayedDelivery/StoreDelayedMessageCommand.cs +++ b/src/NServiceBus.Transport.SqlServer/DelayedDelivery/StoreDelayedMessageCommand.cs @@ -3,11 +3,7 @@ using System; using System.Collections.Generic; using System.Data; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else using Microsoft.Data.SqlClient; -#endif class StoreDelayedMessageCommand { @@ -15,7 +11,7 @@ class StoreDelayedMessageCommand public static StoreDelayedMessageCommand From(Dictionary headers, ReadOnlyMemory body, TimeSpan dueAfter, string destination) { - Guard.AgainstNull(nameof(destination), destination); + ArgumentNullException.ThrowIfNull(destination); var row = new StoreDelayedMessageCommand(); diff --git a/src/NServiceBus.Transport.SqlServer/ExceptionExtensions.cs b/src/NServiceBus.Transport.SqlServer/ExceptionExtensions.cs index c9c600373..481c4e29d 100644 --- a/src/NServiceBus.Transport.SqlServer/ExceptionExtensions.cs +++ b/src/NServiceBus.Transport.SqlServer/ExceptionExtensions.cs @@ -1,13 +1,9 @@ -namespace NServiceBus +namespace NServiceBus.Transport.SqlServer { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Linq; using System.Threading; + using Microsoft.Data.SqlClient; static class ExceptionExtensions { diff --git a/src/NServiceBus.Transport.SqlServer/Guard.cs b/src/NServiceBus.Transport.SqlServer/Guard.cs deleted file mode 100644 index 5f3fb58cd..000000000 --- a/src/NServiceBus.Transport.SqlServer/Guard.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace NServiceBus.Transport.SqlServer -{ - using System; - - class Guard - { - public static void AgainstNull(string argumentName, object value) - { - if (value == null) - { - throw new ArgumentNullException(argumentName); - } - } - - public static void AgainstNullAndEmpty(string argumentName, string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new ArgumentNullException(argumentName); - } - } - - public static void AgainstNegativeAndZero(string argumentName, TimeSpan value) - { - if (value <= TimeSpan.Zero) - { - throw new ArgumentOutOfRangeException(argumentName); - } - } - - public static void AgainstNegative(string argumentName, TimeSpan value) - { - if (value < TimeSpan.Zero) - { - throw new ArgumentOutOfRangeException(argumentName); - } - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.Transport.SqlServer/NServiceBus.Transport.SqlServer.csproj b/src/NServiceBus.Transport.SqlServer/NServiceBus.Transport.SqlServer.csproj index 8c35c2a1f..e0918a1a7 100644 --- a/src/NServiceBus.Transport.SqlServer/NServiceBus.Transport.SqlServer.csproj +++ b/src/NServiceBus.Transport.SqlServer/NServiceBus.Transport.SqlServer.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -7,16 +7,19 @@ - SQL transport support for NServiceBus. This packages depends on Microsoft.Data.SqlClient. Use the NServiceBus.SqlServer package instead if System.Data.SqlClient support is required. + SQL transport support for NServiceBus. This packages depends on Microsoft.Data.SqlClient. + + + + + - - diff --git a/src/NServiceBus.Transport.SqlServer/PubSub/SubscriptionOptions.cs b/src/NServiceBus.Transport.SqlServer/PubSub/SubscriptionOptions.cs index 6bb79c64d..3b82a990b 100644 --- a/src/NServiceBus.Transport.SqlServer/PubSub/SubscriptionOptions.cs +++ b/src/NServiceBus.Transport.SqlServer/PubSub/SubscriptionOptions.cs @@ -30,7 +30,8 @@ public TimeSpan CacheInvalidationPeriod get => cacheInvalidationPeriod; set { - Guard.AgainstNegativeAndZero(nameof(CacheInvalidationPeriod), value); + ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(value, TimeSpan.Zero); + cacheInvalidationPeriod = value; } } diff --git a/src/NServiceBus.Transport.SqlServer/PublishOptionsExtensions.cs b/src/NServiceBus.Transport.SqlServer/PublishOptionsExtensions.cs index aa9702190..f6bbb3b3c 100644 --- a/src/NServiceBus.Transport.SqlServer/PublishOptionsExtensions.cs +++ b/src/NServiceBus.Transport.SqlServer/PublishOptionsExtensions.cs @@ -1,12 +1,8 @@ namespace NServiceBus { -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System; using Extensibility; + using Microsoft.Data.SqlClient; using Transport; using Transport.SqlServer; diff --git a/src/NServiceBus.Transport.SqlServer/Queuing/MessageRow.cs b/src/NServiceBus.Transport.SqlServer/Queuing/MessageRow.cs index 07ce55b34..0a98f1801 100644 --- a/src/NServiceBus.Transport.SqlServer/Queuing/MessageRow.cs +++ b/src/NServiceBus.Transport.SqlServer/Queuing/MessageRow.cs @@ -3,15 +3,11 @@ using System; using System.Collections.Generic; using System.Data; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.IO; + using System.Threading; using System.Threading.Tasks; using Logging; - using System.Threading; + using Microsoft.Data.SqlClient; class MessageRow { diff --git a/src/NServiceBus.Transport.SqlServer/Queuing/SqlCommandExtensions.cs b/src/NServiceBus.Transport.SqlServer/Queuing/SqlCommandExtensions.cs index 19f34336e..10c01eca4 100644 --- a/src/NServiceBus.Transport.SqlServer/Queuing/SqlCommandExtensions.cs +++ b/src/NServiceBus.Transport.SqlServer/Queuing/SqlCommandExtensions.cs @@ -1,13 +1,9 @@ namespace NServiceBus.Transport.SqlServer { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading; using System.Threading.Tasks; + using Microsoft.Data.SqlClient; static class SqlCommandExtensions { diff --git a/src/NServiceBus.Transport.SqlServer/Queuing/TableBasedQueue.cs b/src/NServiceBus.Transport.SqlServer/Queuing/TableBasedQueue.cs index 2cd345672..72adcd16b 100644 --- a/src/NServiceBus.Transport.SqlServer/Queuing/TableBasedQueue.cs +++ b/src/NServiceBus.Transport.SqlServer/Queuing/TableBasedQueue.cs @@ -2,15 +2,11 @@ namespace NServiceBus.Transport.SqlServer { using System; using System.Data; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading; using System.Threading.Tasks; - using Unicast.Queuing; using Logging; + using Microsoft.Data.SqlClient; + using Unicast.Queuing; using static System.String; class TableBasedQueue diff --git a/src/NServiceBus.Transport.SqlServer/Receiving/ExpiredMessagesPurger.cs b/src/NServiceBus.Transport.SqlServer/Receiving/ExpiredMessagesPurger.cs index 40f050fb4..ef88aa680 100644 --- a/src/NServiceBus.Transport.SqlServer/Receiving/ExpiredMessagesPurger.cs +++ b/src/NServiceBus.Transport.SqlServer/Receiving/ExpiredMessagesPurger.cs @@ -1,14 +1,10 @@ namespace NServiceBus.Transport.SqlServer { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading; using System.Threading.Tasks; using Logging; + using Microsoft.Data.SqlClient; class ExpiredMessagesPurger : IExpiredMessagesPurger { diff --git a/src/NServiceBus.Transport.SqlServer/Receiving/MessageReceiver.cs b/src/NServiceBus.Transport.SqlServer/Receiving/MessageReceiver.cs index 23d995302..5140adabb 100644 --- a/src/NServiceBus.Transport.SqlServer/Receiving/MessageReceiver.cs +++ b/src/NServiceBus.Transport.SqlServer/Receiving/MessageReceiver.cs @@ -1,14 +1,10 @@ namespace NServiceBus.Transport.SqlServer { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading; using System.Threading.Tasks; using Logging; + using Microsoft.Data.SqlClient; class MessageReceiver : IMessageReceiver { @@ -49,14 +45,9 @@ public MessageReceiver( public async Task Initialize(PushRuntimeSettings limitations, OnMessage onMessage, OnError onError, CancellationToken cancellationToken = default) { this.limitations = limitations; - messageReceivingCancellationTokenSource = new CancellationTokenSource(); - messageProcessingCancellationTokenSource = new CancellationTokenSource(); processStrategy = processStrategyFactory(transport.TransportTransactionMode); - messageReceivingCircuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("message receiving", waitTimeCircuitBreaker, ex => criticalErrorAction("Failed to peek " + ReceiveAddress, ex, messageProcessingCancellationTokenSource.Token)); - messageProcessingCircuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("message processing", waitTimeCircuitBreaker, ex => criticalErrorAction("Failed to receive from " + ReceiveAddress, ex, messageProcessingCancellationTokenSource.Token)); - inputQueue = queueFactory(ReceiveAddress); errorQueue = queueFactory(errorQueueAddress); @@ -87,6 +78,11 @@ public Task StartReceive(CancellationToken cancellationToken = default) maxConcurrency = limitations.MaxConcurrency; concurrencyLimiter = new SemaphoreSlim(limitations.MaxConcurrency); + messageReceivingCancellationTokenSource = new CancellationTokenSource(); + messageProcessingCancellationTokenSource = new CancellationTokenSource(); + messageReceivingCircuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("message receiving", waitTimeCircuitBreaker, ex => criticalErrorAction("Failed to peek " + ReceiveAddress, ex, messageProcessingCancellationTokenSource.Token)); + messageProcessingCircuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("message processing", waitTimeCircuitBreaker, ex => criticalErrorAction("Failed to receive from " + ReceiveAddress, ex, messageProcessingCancellationTokenSource.Token)); + // Task.Run() so the call returns immediately instead of waiting for the first await or return down the call stack messageReceivingTask = Task.Run(() => ReceiveMessagesAndSwallowExceptions(messageReceivingCancellationTokenSource.Token), CancellationToken.None); diff --git a/src/NServiceBus.Transport.SqlServer/Receiving/ProcessStrategy.cs b/src/NServiceBus.Transport.SqlServer/Receiving/ProcessStrategy.cs index 9b78df434..856509a18 100644 --- a/src/NServiceBus.Transport.SqlServer/Receiving/ProcessStrategy.cs +++ b/src/NServiceBus.Transport.SqlServer/Receiving/ProcessStrategy.cs @@ -1,17 +1,13 @@ namespace NServiceBus.Transport.SqlServer { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading; using System.Threading.Tasks; + using Faults; + using Microsoft.Data.SqlClient; using NServiceBus.Extensibility; using NServiceBus.Logging; using Unicast.Queuing; - using Faults; abstract class ProcessStrategy diff --git a/src/NServiceBus.Transport.SqlServer/Receiving/ProcessWithNativeTransaction.cs b/src/NServiceBus.Transport.SqlServer/Receiving/ProcessWithNativeTransaction.cs index dcf5b1814..27211476f 100644 --- a/src/NServiceBus.Transport.SqlServer/Receiving/ProcessWithNativeTransaction.cs +++ b/src/NServiceBus.Transport.SqlServer/Receiving/ProcessWithNativeTransaction.cs @@ -1,16 +1,12 @@ namespace NServiceBus.Transport.SqlServer { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading; using System.Threading.Tasks; using System.Transactions; - using IsolationLevel = System.Data.IsolationLevel; using Extensibility; + using Microsoft.Data.SqlClient; + using IsolationLevel = System.Data.IsolationLevel; class ProcessWithNativeTransaction : ProcessStrategy { diff --git a/src/NServiceBus.Transport.SqlServer/Receiving/QueueCreator.cs b/src/NServiceBus.Transport.SqlServer/Receiving/QueueCreator.cs index 36a9f0865..ac6ad7201 100644 --- a/src/NServiceBus.Transport.SqlServer/Receiving/QueueCreator.cs +++ b/src/NServiceBus.Transport.SqlServer/Receiving/QueueCreator.cs @@ -1,13 +1,9 @@ namespace NServiceBus.Transport.SqlServer { using System.Data; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif - using System.Threading.Tasks; using System.Threading; + using System.Threading.Tasks; + using Microsoft.Data.SqlClient; class QueueCreator { diff --git a/src/NServiceBus.Transport.SqlServer/Receiving/SchemaVerification.cs b/src/NServiceBus.Transport.SqlServer/Receiving/SchemaVerification.cs index a32307280..c946929e9 100644 --- a/src/NServiceBus.Transport.SqlServer/Receiving/SchemaVerification.cs +++ b/src/NServiceBus.Transport.SqlServer/Receiving/SchemaVerification.cs @@ -2,13 +2,9 @@ { using System; using System.Threading; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Threading.Tasks; using Logging; + using Microsoft.Data.SqlClient; class SchemaInspector { diff --git a/src/NServiceBus.Transport.SqlServer/SendOptionsExtensions.cs b/src/NServiceBus.Transport.SqlServer/SendOptionsExtensions.cs index 9b61e04d2..ca00006b8 100644 --- a/src/NServiceBus.Transport.SqlServer/SendOptionsExtensions.cs +++ b/src/NServiceBus.Transport.SqlServer/SendOptionsExtensions.cs @@ -1,12 +1,8 @@ namespace NServiceBus { -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System; using Extensibility; + using Microsoft.Data.SqlClient; using Transport; using Transport.SqlServer; diff --git a/src/NServiceBus.Transport.SqlServer/Sending/MessageDispatcher.cs b/src/NServiceBus.Transport.SqlServer/Sending/MessageDispatcher.cs index a3f0cebe0..4d7e5adaf 100644 --- a/src/NServiceBus.Transport.SqlServer/Sending/MessageDispatcher.cs +++ b/src/NServiceBus.Transport.SqlServer/Sending/MessageDispatcher.cs @@ -2,16 +2,12 @@ { using System; using System.Collections.Generic; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif using System.Linq; + using System.Threading; using System.Threading.Tasks; using System.Transactions; + using Microsoft.Data.SqlClient; using Transport; - using System.Threading; class MessageDispatcher : IMessageDispatcher { diff --git a/src/NServiceBus.Transport.SqlServer/SqlServerTransport.cs b/src/NServiceBus.Transport.SqlServer/SqlServerTransport.cs index be9ea2339..882ff62b7 100644 --- a/src/NServiceBus.Transport.SqlServer/SqlServerTransport.cs +++ b/src/NServiceBus.Transport.SqlServer/SqlServerTransport.cs @@ -1,16 +1,12 @@ namespace NServiceBus { using System; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif + using System.Collections.Generic; + using System.Threading; using System.Threading.Tasks; + using Microsoft.Data.SqlClient; using Transport; using Transport.SqlServer; - using System.Collections.Generic; - using System.Threading; /// /// SqlServer Transport @@ -23,7 +19,7 @@ public class SqlServerTransport : TransportDefinition public SqlServerTransport(string connectionString) : base(DefaultTransportTransactionMode, true, true, true) { - Guard.AgainstNullAndEmpty(nameof(connectionString), connectionString); + ArgumentException.ThrowIfNullOrWhiteSpace(connectionString); ConnectionString = connectionString; } @@ -35,7 +31,7 @@ public SqlServerTransport(string connectionString) public SqlServerTransport(Func> connectionFactory) : base(DefaultTransportTransactionMode, true, true, true) { - Guard.AgainstNull(nameof(connectionFactory), connectionFactory); + ArgumentNullException.ThrowIfNull(connectionFactory); ConnectionFactory = connectionFactory; } @@ -177,6 +173,6 @@ internal class TestingInformation internal string SubscriptionTable { get; set; } } - static TransportTransactionMode DefaultTransportTransactionMode = TransportTransactionMode.TransactionScope; + static readonly TransportTransactionMode DefaultTransportTransactionMode = TransportTransactionMode.TransactionScope; } } \ No newline at end of file diff --git a/src/NServiceBus.Transport.SqlServer/SubscriptionTableCreator.cs b/src/NServiceBus.Transport.SqlServer/SubscriptionTableCreator.cs index 7263b066b..587997c1f 100644 --- a/src/NServiceBus.Transport.SqlServer/SubscriptionTableCreator.cs +++ b/src/NServiceBus.Transport.SqlServer/SubscriptionTableCreator.cs @@ -1,13 +1,9 @@ namespace NServiceBus.Transport.SqlServer { using System.Data; -#if SYSTEMDATASQLCLIENT - using System.Data.SqlClient; -#else - using Microsoft.Data.SqlClient; -#endif - using System.Threading.Tasks; using System.Threading; + using System.Threading.Tasks; + using Microsoft.Data.SqlClient; class SubscriptionTableCreator {