Skip to content

Merge Npgsql.DependencyInjection into Npgsql #6590

@bgrainger

Description

@bgrainger

Npgsql.DependencyInjection was added in 2022 in #4521.

The reasons for making its own package were not elucidated in that PR but I would guess it was either to minimize dependencies in Npgsql or avoid incompatibility with other TFMs it supported.

Npgsql now depends on Microsoft.Extensions.Logging.Abstractions which brings in Microsoft.Extensions.DependencyInjection.Abstractions. Both packages also require .NET 8.0 and higher. So there is no practical reason why the code couldn't be moved into Npgsql.

Making the DI types available in the base Npgsql package would simplify the usage story for consumers, who would get access to the DI helpers simply by installing Npgsql.

Two migration approaches I can think of:

  1. Move NpgsqlServiceCollectionExtensions.cs and NpgsqlServiceCollectionExtensions.Obsolete.cs to Npgsql and add [assembly:TypeForwardedTo] to Npgsql.DependencyInjection; this has the downside of preserving obsolete methods.
  2. Add NpgsqlServiceCollectionExtensions.cs (just the non-obsolete methods) to Npgsql and turn all the method bodies in Npgsql.DependencyInjection into simple wrappers that delegate to the new implementation in Npgsql.

Or:
3. Move the code but don't update Npgsql.DependencyInjection at all, just mark it as deprecated in NuGet next time you ship a major version.

Metadata

Metadata

Assignees

Type

No fields configured for Task.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions