Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log a warning when the version of Microsoft.Data.SqlClient is lower than 5.2.0 #1306

Merged
merged 1 commit into from Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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