YairHalberstadt / stronginject

compile time dependency injection for .NET
MIT License
845 stars 24 forks source link

Enable injecting Owned<T> and delegates returning Owned<T> #149

Closed jnm2 closed 3 years ago

jnm2 commented 3 years ago

Closes #140.

Lots of discussion and early exploration in https://github.com/YairHalberstadt/stronginject/pull/143.

YairHalberstadt commented 3 years ago

Thanks so much @jnm2 for your amazing contribution!

Would you like to edit the Readme, or shall I?

jnm2 commented 3 years ago

It was a joint effort and I'm looking forward to using it!

I'm game. What do you think would be best, a section inside or underneath the https://github.com/YairHalberstadt/stronginject#delegate-support section perhaps?

People coming from Castle Windsor will be looking for IFactory<T> and the terminology "typed factories" and it might be nice to have a way to catch that and show that Func<..., Owned<T>> is exactly equivalent.

YairHalberstadt commented 3 years ago

It's not directly related to DelegateSupport, just has a strong synthesis with it, so I think a separate section underneath makes sense.

I don't know much about castle Windsor, so maybe suggest a design for that?

jnm2 commented 3 years ago

You mean like a "Coming from Castle Windsor" section that goes beyond explaining how to refactor Windsor's factory interface auto-implementation to using StrongInject's Func<..., Owned<T>>?

YairHalberstadt commented 3 years ago

Oh, I wasn't quite sure what you were saying - I thought you meant some sort of warning. I don't think it's worth having a whole section in the Readme, but I would be happy to add separate migration documents/FAQs explaining how to do specific things maybe.

jnm2 commented 2 years ago

https://github.com/YairHalberstadt/stronginject/pull/150 updates the readme.

jnm2 commented 2 years ago

@YairHalberstadt I didn't think of testing what happens if you ask for Owned<Func<X>> :)

YairHalberstadt commented 2 years ago

I don't think there's any particular need to test that precise combination TBH. I can't see anything special about it...

jnm2 commented 2 years ago

It indicates a confused user :D but I agree, no priority yet.