Skip to content

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

Merged
merged 2 commits into from
Dec 21, 2023
Merged

Defer calling AddServices #213

merged 2 commits into from
Dec 21, 2023

Conversation

ChrisDoernen
Copy link
Contributor

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.

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.
@Arash-Sabet Arash-Sabet self-requested a review December 20, 2023 15:34
@Arash-Sabet
Copy link
Contributor

@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?

Copy link
Contributor

@Arash-Sabet Arash-Sabet left a 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.

@Arash-Sabet Arash-Sabet merged commit f7ed359 into Umplify:main Dec 21, 2023
@ChrisDoernen
Copy link
Contributor Author

ChrisDoernen commented Dec 21, 2023

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

@Arash-Sabet
Copy link
Contributor

@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!

@Arash-Sabet
Copy link
Contributor

@ChrisDoernen I changed the licensing model to MIT from GPL 3.0. Please let me know if you have any feedback on it.

@ChrisDoernen
Copy link
Contributor Author

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?

@Arash-Sabet
Copy link
Contributor

@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.

@ChrisDoernen
Copy link
Contributor Author

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!!

@ChrisDoernen ChrisDoernen deleted the patch-1 branch April 12, 2024 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants