https://github.com/marcominerva/keyedservicesissue
This repository shows a different behavior of FromKeyedServices attribute in Minimal APIs endpoint handler and inside a class library. The issue has been solved in .NET 8.0.11.
https://github.com/marcominerva/keyedservicesissue
Last synced: 9 months ago
JSON representation
This repository shows a different behavior of FromKeyedServices attribute in Minimal APIs endpoint handler and inside a class library. The issue has been solved in .NET 8.0.11.
- Host: GitHub
- URL: https://github.com/marcominerva/keyedservicesissue
- Owner: marcominerva
- License: mit
- Created: 2024-05-06T08:51:36.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-01-29T13:52:39.000Z (over 1 year ago)
- Last Synced: 2025-03-13T12:31:22.671Z (over 1 year ago)
- Language: C#
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Issue with FromKeyedServices attribute
If we use the `FromKeyedServices` attribute in a class library and the keyed registration is missing, it falls back to the default dependency injection behavior and gets the last registered implementation. However, If we use `FromKeyedServices` directly in a Minimal API endpoint handler and the key does not exist, it throws an exception.
This repo contains some examples that showcase all the different scenarios. Every endpoint comes with a description of the particular behavior it refers to.
The issue has been solved in .NET 8.0.11.
