Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registering implementation type X is not assignable to service type IX when using Generics #55

Open
ruslanss opened this issue Oct 22, 2020 · 4 comments

Comments

@ruslanss
Copy link

is this a known issue limitation?

I have added code to reproduce it here: https://github.com/ruslanss/azure-functions-dotnet-extensions/tree/service_registration_bug

this type of service registration doesn't appear to be supported:

builder.Services.AddSingleton<IValidator<WhateverCommand>, NullValidator>();

Error on host startup:

[2020-10-22T20:12:11.169] A host error has occurred during startup operation '3a905cf7-b8f9-4dad-868a-ae23c7e8c1db'.
[2020-10-22T20:12:11.170] Microsoft.Azure.WebJobs.Script.WebHost: Registering implementation type Microsoft.Azure.Functions.Samples.DependencyInjectionBasic.InjectionTest.NullValidator is not assignable to service type Microsoft.Azure.Functions.Samples.DependencyInjectionBasic.InjectionTest.IValidator<Microsoft.Azure.Functions.Samples.DependencyInjectionBasic.InjectionTest.WhateverCommand>.

@remiX-
Copy link

remiX- commented Sep 23, 2022

Hey Ruslanss, did you ever manage to resolve this? I'm having issues with this after updating my Function App from ~3 -> ~4 whilst migrating from DOTNETCORE|3.1 to DOTNET|6.0

@ruslanss
Copy link
Author

Hi @remiX- ! yes try downgrading Scrutor nuget package to v4.1.0 if you're using it.

@remiX-
Copy link

remiX- commented Sep 26, 2022

Ah I'm not using it.

I had to resort to using Provider in the Add and create the instance

Something like this, even if I didn't need it
builder.Services.AddSingleton<IValidator<WhateverCommand>>(sp => new NullValidator());

@waynebrantley
Copy link

@fabiocav @brettsam Wondering if this project is being depreciated? No changes since 2020.
Who would we be able to get to update this type check to stop this issue - assuming this project is not dead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants