-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Improve WebApplication debugging #48827
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
dda2d17 to
4806128
Compare
ed8dd9d to
30ed8b3
Compare
Bad, they should at least show after build/run is called. |
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.
- Showing middleware would be nice
- This is a very hacky way to do it, and not very representative when there are pipeline forks involved.
- I think you're missing several other ways that middleware are defined like with the Map or Use extensions.
- I'm not sure there's a better way
- Is it worth it? Depends, what does the list look like for a real application? At least one of the more complex templates with auth and such.
Done. More hacking was required though to merge the app pipelines nicely 😬 Here you can see UseRouting/UseEndpoints/UseAuthN/UseAuthZ are automatically added because the app has an endpoint and authn/authz configured:
The delegate method name is added to the list. It's a bit ugly, but the information is there. One thing that is missing is middleware from branched pipelines (MapWhen, UseWhen). I think displaying that kind of complexity would be very tough, require some public API to build up the graph, and generally involve substantial changes This is what it looks like: |
2fed5b6 to
8d5625a
Compare
|
@JamesNK make this a draft 😄 |
|
All the work-in-progress points identified at the top are done. Draft isn't necessary. It's ready for review. |
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.
❤️
5b1131f to
56760c2
Compare
| // IDebugger service can optionally be added by tests to simulate the debugger being attached. | ||
| _debugger = (IDebugger?)serviceProvider?.GetService(typeof(IDebugger)) ?? DebuggerWrapper.Instance; | ||
|
|
||
| if (_debugger.IsAttached) |
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.
👍🏾
| return descriptions; | ||
| } | ||
|
|
||
| throw new NotSupportedException("Unable to get configured middleware."); |
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.
s/get/resolve
|
This is really nice! Great work @JamesNK |
| // This type exists so the place where the source pipeline is wired into the destination pipeline can be identified. | ||
| private sealed class WireSourcePipeline(IApplicationBuilder builtApplication) | ||
| { | ||
| private readonly IApplicationBuilder _builtApplication = builtApplication; |
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.
Why did you declare a field?
|
@JamesNK, this change will be considered for inclusion in the blog post for the release it'll ship in. Nice work! Please ensure that the original comment in this thread contains a clear explanation of what the change does, why it's important (what problem does it solve?), and, if relevant, include things like code samples and/or performance numbers. This content may not be exactly what goes into the blog post, but it will help the team putting together the announcement. Thanks! |


This PR adds various debugging improvements around WebApplication.
Notable improvements:
IsRunningproperty calculated from lifetime events to quickly understand state of the appNote that the collection doesn't include middleware automatically added by WebApplication. Good or bad?Middleware automatically added when the web app starts is included.More testing is needed to ensure it hangs together when branching the app pipeline.DoneApplicationLifetime. It lives in dotnet/runtime.Will improve it later.Add DebuggerDisplay to some hosting types runtime#87599Before:
After:
App endpoints:
App middleware:
More complex example: