Skip to content

Don't throw exception in ServiceDescriptor #99622

@benjaminpetit

Description

@benjaminpetit

Right now, when a ServiceDescriptor is not keyed, accessing all the keyed properties (KeyedImplementationInstance, KeyedImplementationType, KeyedImplementationFactory) will throw an InvalidOperationException.

Similary, when the ServiceDescriptor is not keyed, accessing all the non-keyed properties(ImplementationInstance, ImplementationType, ImplementationFactory) will also throw an InvalidOperationException`.

Ideally the application should check the value of IsKeyedService before accessing these properties, but applications that are not yet aware of keyed services break because of these exceptions.

We should remove this behavior. Note that applications that do not "keyed services aware" can still break because all the expected properties will be null, but it should cause less issues.

@halter73 @steveharter @davidfowl

Metadata

Metadata

Assignees

Labels

area-Extensions-DependencyInjectionbreaking-changeIssue or PR that represents a breaking API or functional change over a previous release.design-discussionOngoing discussion about design without consensusneeds-breaking-change-doc-createdBreaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions