Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

The "Disposal of services" section stated only that singletons are automatically disposed, leaving readers uncertain about transient and scoped service disposal behavior.

Changes

  • Updated docs/core/extensions/dependency-injection/guidelines.md to document disposal timing for all three service lifetimes:
    • Transient: disposed at scope end
    • Scoped: disposed at scope end
    • Singleton: disposed at container disposal (application shutdown)
  • Aligned terminology with 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

This section details on the original issue you should resolve

<issue_title>[UUF] Missing information</issue_title>
<issue_description>### Type of issue

Missing information

Description

Great info generally, but in the "Disposal of Services " section the following line is confusing: "If a type or factory is registered as a singleton, the container disposes the singleton automatically." Why mention the singleton case but not transient and scoped services? Are they not automatically disposed as well?

Page URL

https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection-guidelines

Content source URL

https://github.com/dotnet/docs/blob/main/docs/core/extensions/dependency-injection-guidelines.md

Document Version Independent Id

7fb2be80-cb54-27bf-4f93-423d8540429e

Platform Id

df1bff59-742c-a7b3-cfc6-4fc1f6510458

Article author

@gewarren

Metadata

  • ID: 8d1c8ef1-6a01-df24-34ad-570f88df9303
  • PlatformId: df1bff59-742c-a7b3-cfc6-4fc1f6510458
  • Service: dotnet-fundamentals

Related Issues</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 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

📄 File 🔗 Preview link
docs/core/extensions/dependency-injection/guidelines.md Dependency injection guidelines

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copilot AI changed the title [WIP] Clarify disposal of services in documentation Clarify automatic disposal for all service lifetimes in DI guidelines Jan 28, 2026
Copilot AI requested a review from gewarren January 28, 2026 23:18
@gewarren gewarren marked this pull request as ready for review January 29, 2026 15:46
@gewarren gewarren requested a review from a team as a code owner January 29, 2026 15:46
Copilot AI review requested due to automatic review settings January 29, 2026 15:46
@gewarren gewarren enabled auto-merge (squash) January 29, 2026 15:46
Copy link
Contributor

Copilot AI left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UUF] Missing information

2 participants