Allow HostFactoryResolver to listen on arbitrary events - #127743
Conversation
|
Tagging subscribers to this area: @dotnet/area-extensions-hosting |
There was a problem hiding this comment.
Pull request overview
This PR extends HostFactoryResolver.ResolveHostFactory to allow callers to attach callbacks for additional DiagnosticSource event names emitted by Microsoft.Extensions.Hosting, enabling tooling scenarios that need to observe more than just the existing HostBuilding / HostBuilt flow.
Changes:
- Adds an optional
arbitraryActionsmap toResolveHostFactoryand threads it intoHostingListener. - Invokes a registered callback when an observed hosting DiagnosticSource event key matches an entry in
arbitraryActions. - Adds a new
using Microsoft.Extensions.Configuration;directive (currently unused).
This comment has been minimized.
This comment has been minimized.
|
Mostly repeating what copilot said, but:
|
|
@Youssef1313 If you're not planning on getting this PR merged soon, can you turn it into a draft? We don't want to have PRs that are open for a long time. Thanks. |
|
@svick With regards to exceptions, how is the new arbitraryActions different from the existing |
|
Caution Security scanning requires review for Code Review DetailsThe threat detection results could not be parsed. The workflow output should be reviewed before merging. Review the workflow run logs for details. 🤖 Copilot Code Review — PR #127743Holistic AssessmentMotivation: The PR adds a hook mechanism to allow consumers (ASP.NET Core) to listen on arbitrary diagnostic source events during host resolution. The use case (firing Approach: Adding an Summary: Detailed Findings
|
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/c2f33a8c-2e5f-41cc-87fb-11636c3780e9 Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/c2f33a8c-2e5f-41cc-87fb-11636c3780e9 Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com>
Addressed in 08df3ae: added tests for |
It seems that with how it's used, an exception in |
|
Note that I have added your new project file to the solution. I hope you don't mind. |
|
API proposal on aspnetcore is approved. This should be ready for review again now. |
I needed this to prototype the change in dotnet/aspnetcore#66527. Whether or not we will need to use that in aspnet is to be decided when dotnet/aspnetcore#66574 is reviewed. The change here is in internal class which is consumed via an internal source-only package (that package isn't shipped to nuget.org). The PR doesn't introduce any behavior changes to runtime. It will only allow aspnetcore to hook additional delegates, which will allow us to fire HostApplicationBuilderCreated event when the user calls WebApplication.CreateBuilder, and gives us the opportunity in the testing library to add early configuration sources that users expect to be available before `Build()` is called. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Petr Onderka <petronderka@microsoft.com>
I needed this to prototype the change in dotnet/aspnetcore#66527.
Whether or not we will need to use that in aspnet is to be decided when dotnet/aspnetcore#66574 is reviewed.
The change here is in internal class which is consumed via an internal source-only package (that package isn't shipped to nuget.org). The PR doesn't introduce any behavior changes to runtime. It will only allow aspnetcore to hook additional delegates, which will allow us to fire HostApplicationBuilderCreated event when the user calls WebApplication.CreateBuilder, and gives us the opportunity in the testing library to add early configuration sources that users expect to be available before
Build()is called.