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 #1305

Merged
merged 3 commits into from Mar 4, 2024
Merged
Changes from 2 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 @@ -3,9 +3,15 @@ namespace NServiceBus.Transport.SqlServer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Transactions;
#if SYSTEMDATASQLCLIENT
using System.Data.SqlClient;
#else
using Microsoft.Data.SqlClient;
#endif
using Logging;
using NServiceBus.Transport.SqlServer.PubSub;
using Transport;
Expand All @@ -21,6 +27,18 @@ internal SqlServerTransportInfrastructure(SqlServerTransport transport, HostSett

tableBasedQueueCache = new TableBasedQueueCache(addressTranslator, !isEncrypted);
connectionFactory = CreateConnectionFactory();

if (typeof(SqlConnection).Namespace != "Microsoft.Data.SqlClient")
danielmarbach marked this conversation as resolved.
Show resolved Hide resolved
{
return;
}

var informationalVersion = typeof(SqlConnection).Assembly.GetCustomAttributes().OfType<AssemblyInformationalVersionAttribute>().Single();
var currentClientVersion = new Version(informationalVersion.InformationalVersion.Split('+').First());
mauroservienti marked this conversation as resolved.
Show resolved Hide resolved
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. See https://github.com/dotnet/SqlClient/blob/main/release-notes/5.0/5.0.0.md#breaking-changes for details on breaking changes before ugprading.", currentClientVersion);
danielmarbach marked this conversation as resolved.
Show resolved Hide resolved
}
}

public async Task ConfigureSubscriptions(string catalog, CancellationToken cancellationToken = default)
Expand Down