/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.

Primary LanguageC#MIT LicenseMIT

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.

image