ipjohnson / Grace

Grace is a feature rich dependency injection container library
MIT License
336 stars 33 forks source link

Export an unrelated type with an attribute #283

Closed jods4 closed 2 years ago

jods4 commented 2 years ago

I have a bit of a weird use-case: I am interested in exporting a type that's related, but not the same, as an attributed type.

Basically I would like to have the following code:

[MagicExport]
class C { }

and that would actually register Register<C> as an export for IRegister.

It seems you were going into that direction at one point with IExportStrategyProviderAttribute, which seems to be an attribute that provides a complete -- so possibly unrelated to attributed type -- export strategy.

Unfortunately for me, that interface is never referenced in Grace code.

ipjohnson commented 2 years ago

Hi @jods4

I've pushed a new version to nuget. If you look at the changeset I added a test similar to the situation you described. Let me know how it works.

jods4 commented 2 years ago

That looks perfect, and it was so quick... as always! You're the best, thanks.

Do you have a planned release date for 7.2.1 final?

ipjohnson commented 2 years ago

I'll look at pushing it this weekend, as I need to look at rolling out support for .net 6 and a new DI feature.

ipjohnson commented 2 years ago

This has been released