Skip to content

Commit a016341

Browse files
Log warn when the client version is below 5.2.0 to make sure clients 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 (#1306)
1 parent 63335fb commit a016341

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

+16-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ namespace NServiceBus.Transport.SqlServer
22
{
33
using System;
44
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Reflection;
7+
using System.Threading.Tasks;
8+
using System.Transactions;
59
#if SYSTEMDATASQLCLIENT
610
using System.Data.SqlClient;
711
#else
812
using Microsoft.Data.SqlClient;
913
#endif
10-
using System.Threading.Tasks;
11-
using System.Transactions;
1214
using DelayedDelivery;
1315
using NServiceBus.Logging;
1416
using Performance.TimeToBeReceived;
@@ -67,6 +69,18 @@ internal SqlServerTransportInfrastructure(string catalog, SettingsHolder setting
6769
}
6870
var subscriptionTableCreator = new SubscriptionTableCreator(subscriptionTableName, connectionFactory);
6971
settings.Set(subscriptionTableCreator);
72+
73+
if (typeof(SqlConnection).Namespace != "Microsoft.Data.SqlClient")
74+
{
75+
return;
76+
}
77+
78+
var informationalVersion = typeof(SqlConnection).Assembly.GetCustomAttributes().OfType<AssemblyInformationalVersionAttribute>().Single();
79+
var currentClientVersion = new Version(informationalVersion.InformationalVersion.Split('+').First());
80+
if (currentClientVersion < new Version(5, 2, 0))
81+
{
82+
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);
83+
}
7084
}
7185

7286
SqlConnectionFactory CreateConnectionFactory()

0 commit comments

Comments
 (0)