-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Obsolete WebHostBuilder #20964
Comments
To clarify even more, the idea here is to obsolete the types and public APIs on:
The obsolete message should include an |
We shouldn’t do this until we resolve the remaining gaps that people complain about:
|
Related issue: #19809 |
Also the |
Lets start cleaning up areas before obsoleting this starting in preview6.
|
Example changes #23626 Make sure to dispose the IHost. Common changes: Before: var host = new WebHostBuilder()
.Configure(app =>
{
//...
}).Build(); After: using var host = new HostBuilder()
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder
.Configure(app =>
{
//...
}
}).Build(); TestServer: var builder = new WebHostBuilder();
var server = new TestServer(builder); After: using var host = new HostBuilder()
// ...
.UseTestServer()
.Build();
var server = host.GetTestServer();
await host.StartAsync(); // new TestServer(builder); used to run Start, but we don't use that anymore |
@mkArtakMSFT Can you find some folks to handle MVC? Read previous comment for some helpers. |
Yup I can do identity/security |
Just to be clear, we're not obsoleting anything in 5.0 😄. We haven't scheduled the linked items though I am supportive of updating the other projects. |
How bad is it if the host doesn't get disposed? There's a bunch of tests that rely on a helper method that creates the server, which if the helper has a using var host, the host gets disposed and the test code fails due to object disposed. i.e.
|
You'll get hangs because by default the console lifetime service is hooked up which waits for ctrl-c (or dispose) before closing. I changed a bunch of helpers in middleware to return |
Hangs? Everything seems to work fine if I just drop the using |
meaning the tests complete just fine without the using |
Yeah, I'm not sure how VS handles that, but when running from command line you should see hangs. |
I just tried via dotnet test and it 'worked'. Does that mean its ok? |
@BrennanConroy the other thing we should consider is having UseTestServer register its own lifetime to replace ConsoleLifetime. The implementation should be a no-op. |
Thanks for contacting us. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Thanks for contacting us. We're moving this issue to the |
WebHostBuilder was replaced by HostBuilder in 3.0. In 5.0 we should consider obsoleting the old one.
The text was updated successfully, but these errors were encountered: