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

Can't inject ILogger<T> #32

Closed
MartinRothschink opened this issue Mar 16, 2022 · 5 comments
Closed

Can't inject ILogger<T> #32

MartinRothschink opened this issue Mar 16, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@MartinRothschink
Copy link

Hi Thomas,

great package, I'm using it already in two projects.

I like to inject an ILogger in my view model, but that creates code that does not compile.

E.g.

[Inject(typeof(ILogger<SettingsPageViewModel>))]

Is that a known issue? Or should that work?

Regards
Martin

@thomasclaudiushuber
Copy link
Owner

Hi @MartinRothschink ,

that should definitely work, but looks like injecting generic interfaces does not work yet.

I'll take a look at it, thank you for reporting it. (Issue #22 might refer to the same problem)

@thomasclaudiushuber
Copy link
Owner

Hi @MartinRothschink ,

OK, I see, the generated property name contains in this case a closing angle bracket >, and so the code does not compile.

I'll create a fix for this. For now, a workaround would be to explicitly specify the property name with the Inject attribute:

[Inject(typeof(ILogger<SettingsPageViewModel>),PropertyName ="Logger")]

@MartinRothschink
Copy link
Author

Thanks Thomas,

will try the workaround.

@thomasclaudiushuber
Copy link
Owner

Fixed in release 1.1.4 that is now available via NuGet. Thanks for reporting this @MartinRothschink.

@Daimonion1980
Copy link

Perfect.

Exact the same situation as i ran into this morning.

Update nuget package from 1.1.3 to 1.1.4 and everything is fine again!!!! What a great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants