-
Notifications
You must be signed in to change notification settings - Fork 15
Defer calling AddServices #213
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
Conversation
When placed in the constructor, AddServices is called before the constructor of the deriving fixtures runs. This is suboptimal in cases where the implementation of AddServices depends on something that happens in that constructor. Examples is loading env variables (dotenv.net package) or bootstrapping a WebApplicationFactory like in ASP.NET integration tests.
@ChrisDoernen Thanks for submitting this PR. I will have to examine your PR against a couple of other projects that I have to ensure it's not a breaking change. Have you observed any issues when running the associated test example? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The service collection must not be initialized multiple times.
Hi Arash, I was about to report that the example tests still work but it seems you know that already 😊 Thanks for merging! If you want, I can add a example test with the use case for reference!? Best Chris |
@ChrisDoernen You're most welcome. Although, I had to make a slight change on the top of yours. Please feel free to add your example as a use case reference as it will be a valuable reference for the community. Cheers! |
@ChrisDoernen I changed the licensing model to MIT from GPL 3.0. Please let me know if you have any feedback on it. |
Hi @Arash-Sabet, happy new year! I personally would not be affected by the change as both licenses support my use case. I am working on a small intranet project without distribution or commercial intentions (correct me if this is not backed by GPL 3.0!). If I understand it correctly, people would not be able to use this package if they are working on commercial projects which they are selling/shipping unless they publish their source code? |
@ChrisDoernen Happy New Year to your too Chris! Yes, your understanding is correct and that's why I changed the license model to give the community more freedom of use. |
I just realized I got it wrong - you changed from GPL to MIT. I somehow thought it was the other way around. This is of course even better for the community! So on behalf of the community, thanks for authoring this package!! |
When placed in the constructor, AddServices is called before the constructor of the deriving fixtures runs. This is suboptimal in cases where the implementation of AddServices depends on something that happens in that constructor.
Examples is loading env variables (dotenv.net package) or bootstrapping a WebApplicationFactory like in ASP.NET integration tests.
In my case, the WebApplicationFactory uses the IMessageSink injected in my fixture constructor by xUnit.