Skip to content

Commit

Permalink
Log warn when the client version is below 5.2.0 to make sure clients …
Browse files Browse the repository at this point in the history
…start upgrading to later versions without enforcing them to have Encrypt=true that was introduced in a breaking change in 4.x of the client
  • Loading branch information
danielmarbach committed Mar 5, 2024
1 parent 63335fb commit 9d9facc
Showing 1 changed file with 16 additions and 2 deletions.
Expand Up @@ -2,13 +2,15 @@ namespace NServiceBus.Transport.SqlServer
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Transactions;
#if SYSTEMDATASQLCLIENT
using System.Data.SqlClient;
#else
using Microsoft.Data.SqlClient;
#endif
using System.Threading.Tasks;
using System.Transactions;
using DelayedDelivery;
using NServiceBus.Logging;
using Performance.TimeToBeReceived;
Expand Down Expand Up @@ -67,6 +69,18 @@ internal SqlServerTransportInfrastructure(string catalog, SettingsHolder setting
}
var subscriptionTableCreator = new SubscriptionTableCreator(subscriptionTableName, connectionFactory);
settings.Set(subscriptionTableCreator);

if (typeof(SqlConnection).Namespace != "Microsoft.Data.SqlClient")
{
return;
}

var informationalVersion = typeof(SqlConnection).Assembly.GetCustomAttributes().OfType<AssemblyInformationalVersionAttribute>().Single();
var currentClientVersion = new Version(informationalVersion.InformationalVersion.Split('+').First());
if (currentClientVersion < new Version(5, 2, 0))
{
Logger.WarnFormat("You are using an outdated version '{0}' of Microsoft.Data.SqlClient. We recommend using version 5.2.0 or later by adding a top-level package reference to avoid known problems in older versions of the client. Consult the SQL client release notes https://github.com/dotnet/SqlClient/blob/main/release-notes for breaking changes before upgrading.", currentClientVersion);
}
}

SqlConnectionFactory CreateConnectionFactory()
Expand Down

0 comments on commit 9d9facc

Please sign in to comment.