dotnet / dotnet/aspnetcore

Move FromServicesAttribute to Microsoft.Extensions.DependencyInjection

Open
#55,000 0 comments 2 reactions 0 assignees View on GitHub
area-mvc
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I'm trying to create a better solution for running xUnit tests inside a DI container and as such would like to adhere to current coding norms to provide users with a seamless experience. To achieve that, I would like to allow users to annotate method parameters with the `FromServicesAttribute` or `FromKeyedServicesAttribute` attributes. `FromKeyedServices` is located in `Microsoft.Extensions.DependencyInjection` but `FromServicesAttribute` is not and instead live in the MVC namespace meaning I would need to reference the whole of MVC just to access this 1 attribute.

I have seen Mr Fowlers comment on `FromServicesAttribute` being a pure MVC feature and thus it belongs where it is, but with the addition of `FromKeyedServices` I wonder if this still holds true.

### Describe the solution you'd like

I would like the `FromServicesAttribute` to be handled like the `FromKeyedServicesAttribute` where the attribute itself lives inside the `Microsoft.Extensions.DependencyInjection` namespace, and is then handled internally by MVC.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.