Skip to content

Will property injection be revisited with the upcoming addition of required members? #76854

@NetherGranite

Description

@NetherGranite

Is there an existing issue for this?

  • I have searched the existing issues

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

Property injection is not supported in the default service container, but now required members are coming with C# 11.

Describe the solution you'd like

Property injection like in legacy ASP.NET via something like an InjectAttribute could be valuable. Maybe required members should even be automatically detected.

Additional context

I was not able to find any reasoning as to why property injection was omitted in ASP.NET Core's default service container, so I don't know if the fact that property injection was considered a design issue since it makes dependencies optional was a factor.

If it was a factor, a lot of ASP.NET Core boilerplate could be massively reduced via property injection the way required members will now reduce constructor boilerplate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Extensions-DependencyInjectionquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions