-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Clarify automatic disposal for all service lifetimes in DI guidelines #51384
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
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.
Pull request overview
This PR clarifies the automatic disposal behavior for all three service lifetime types in the dependency injection guidelines documentation. The original issue raised confusion about whether transient and scoped services are also automatically disposed, since the documentation only explicitly mentioned singleton disposal.
Changes:
- Added explicit disposal timing documentation for transient, scoped, and singleton service lifetimes
- Structured the information as a bulleted list with disposal behavior for each lifetime type
- Included context about disposal timing in request-processing applications
The "Disposal of services" section stated only that singletons are automatically disposed, leaving readers uncertain about transient and scoped service disposal behavior.
Changes
docs/core/extensions/dependency-injection/guidelines.mdto document disposal timing for all three service lifetimes:service-lifetimes.md("In apps that process requests")The existing code examples and console output already demonstrated this behavior but lacked explicit documentation.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Internal previews