-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Stop the host first and then dispose it! #29404
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
Where's the test? |
Not sure if this is correct way to tests. As _host is private field in WebApplicationFactory<T>
@davidfowl I added the test, but not sure if this is the correct way to test. Because |
What are you trying to fix? |
I have linked corresponding issue in first link. |
Then why isn't there a test that verifies the behavior? Are you clear on what event isn't firing and what event should be firing after the fix? |
I did not found any existing tests that verifies that bug! |
@@ -524,6 +524,7 @@ protected virtual void Dispose(bool disposing) | |||
} | |||
|
|||
_server?.Dispose(); | |||
_host?.StopAsync().Wait(); |
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.
If we want to test that this is called, we could
- Create the factory, request the
IapplicationLifetime
service from the host services (available through the factory). - Register a callback on stop.
- Dispose the factory.
- Validate the callback was invoked.
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.
Very thanks @javiercn. I added the corresponding test as per your instructions, but instead of IApplicationLifetime
, I used IHostApplicationLifetime
as IApplicationLifetime
is obsolete
.
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.
Yes, I didn't remember exactly how it was named, so perfect!
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.
😀
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.
Thanks for the contribution!
Great set of changes
Hey @javiercn, I forget to remove the leftover bool variable!! Should I create a new PR, or is there any way to get this done in this PR, as you just merged it! |
Hi @MCCshreyas. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
@MCCshreyas If you want to send a separate PR to clean it up that's fine with us. I was about to comment on this PR to point out that we should also implement IAsyncDisposable since I'm not a fan of the I've filed a follow up issue here if you feel like tackling it |
Hi @javiercn. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
@javiercn Ok. I will check that out, and will open PR! |
Hi @MCCshreyas. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
Hi @quixoticaxis. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
1. Other fix - Removed unwanted variable was added as part of dotnet#29404 Fixes dotnet#29455
1. Other fix - Removed unwanted variable was added as part of dotnet#29404 Fixes dotnet#29455
Fixes #29348
Fixes #25857