Skip to content

[Breaking change]: FromKeyedServicesAttribute.Key may be null #46269

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

Open
1 of 3 tasks
ericstj opened this issue May 20, 2025 · 0 comments
Open
1 of 3 tasks

[Breaking change]: FromKeyedServicesAttribute.Key may be null #46269

ericstj opened this issue May 20, 2025 · 0 comments
Assignees
Labels
breaking-change Indicates a .NET Core breaking change ⌚ Not Triaged Not triaged

Comments

@ericstj
Copy link
Member

ericstj commented May 20, 2025

Description

FromServiceKeyAttribute has been extended to support null (for unkeyed) and inheritance.

Version

.NET 8

Previous behavior

FromServiceKeyAttribute.Key was a non-nullable object object.

New behavior

FromServiceKeyAttribute.Key is a nullable object object?.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

See dotnet/runtime#113585. Support was added for keyed services to annotate parameters as unkeyed.

Recommended action

Adjust any caller that is using FromServiceKeyAttribute to accept a null value for Key.

Feature area

Extensions

Affected APIs

Microsoft.Extensions.DependencyInjection.FromServiceKeyAttribute.Key

@ericstj ericstj added the breaking-change Indicates a .NET Core breaking change label May 20, 2025
@dotnet-policy-service dotnet-policy-service bot added the ⌚ Not Triaged Not triaged label May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates a .NET Core breaking change ⌚ Not Triaged Not triaged
Projects
None yet
Development

No branches or pull requests

2 participants