Skip to content

DiagnosticListener no longer works on .NET Core 3.1 or .NET 5 #1928

@mattjohnsonpint

Description

@mattjohnsonpint

Describe the bug

SqlClient 5.1.0 dropped support for .NET Core 3.1, and targeted .NET 6 instead. However, there are still .NET Standard 2.0 and 2.1 targets, so applications running .NET Core 3.1 or .NET 5.0 can still install the newer version - but in doing so they'll get the .NET Standard version of SqlClient.

Unfortunately, the SqlDiagnosticListener class is unimplemented for .NET Standard. Thus, if a .NET Core 3.1 or .NET 5.0 application updates to the latest version, they will silently lose all diagnostic messages from Sql Client at runtime.

We found this by a test breaking in our CI. See getsentry/sentry-dotnet#2189

To reproduce

Make a .NET Core 3.1 or .NET 5 app that uses Microsoft.Data.SqlClient version 5.0.1 and subscribes to diagnostic listeners. Perform any operation so you can see the diagnostic information.

Then update to Microsoft.Data.SqlClient version 5.1.0. Notice there are no compilation errors, but the diagnostic data is no longer emitted.

Expected behavior

Any of the following would have been acceptable:

  • Diagnostic data still is emitted (requiring implementation of SqlDiagnosticListener for .NET Standard)
  • The application didn't compile due to the breaking change (which would require some msbuild trickery)
  • The version number of the release should have been 6.0.0 to indicate a significant breaking change.

Yes, I understand both .NET Core 3.1 and .NET 5 are out of support, but that doesn't mean it's fine to release changes that will break behavior in them without bumping the major.

Metadata

Metadata

Assignees

No one assigned

    Labels

    By Design 🎨Issues due to driver feature design and will not be fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions