Configure WebApplicationBuilder directly instead of with ConfigureWebHostDefaults
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
#40459 Simplifies the WebApplicationBuilder by refactoring it to use the new HostApplicationBuilder type instead of HostBuilder internally. However, we still configure the GenericWebHostService by calling ConfigureWebHostDefaults on a fake IHostBuilder.
It would be better to come up with a more first-class way to configure the GenericWebHostService and allow other IHostedServices to be registered beforehand.
This still needs some design but will likely require new public API because WebApplicationBuildier and GenericWebHostService live in different assemblies. Ideally, this design would be based on HostApplicationBuilder instead of IHostBuilder.
It's also important that this new API gives direct access to the GenericWebHostService so it doesn't need to be extracted from the IServiceCollection and then appended at the end during `WebApplicationBuilder.Build()` like it is today to ensure the GenericWebHostService is the last IHostedService to start.
Contributor guide
Research direction
Start by reviewing WebApplicationBuilder, HostApplicationBuilder, GenericWebHostService, and ConfigureWebHostDefaults, then trace how WebApplicationBuilder.Build() currently orders hosted services. The issue is complete when a public, first-class design is agreed and implemented that configures GenericWebHostService directly, allows other IHostedServices to be registered beforehand, and avoids extracting and appending the service during Build().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100