Skip to content

Calls to retrieve an IEnumerable of a type that is not registered call the constructor of said type. #320

@belav

Description

@belav

I'm attempting to get Quartz working in a project.

The startup code for Quartz makes a few calls like the following

serviceProvider.GetServices<JobListenerConfiguration>();

This results in call to

serviceProvider.GetRequiredService<IEnumerable<JobListenerConfiguration>>();

There is nothing registered for JobListenerConfiguration. When running this code in a project without grace, this results in an empty array of JobListenerConfiguration being returned. I don't believe anything is specifically registering that as a service.

On the other hand grace attempts to locate and inject parameters into JobListenerConfiguration, which fails because one of the parameters is just Type listenerType

I've worked around this by specifically registering an empty enumerable for IEnumerable<JobListenerConfiguration> which was complicated by JobListenerConfiguration being an internal type.

Not sure if this is a bug exactly, but I think ideally grace would also return an empty enumerable and not try to figure out how to inject services into the constructor of a type that is not registered with it when the request is for a collection of said type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions