Skip to content

Update dependency-injection-guidelines.md to suggest avoid singleton for stateless service #47991

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RyanLiu99
Copy link
Contributor

@RyanLiu99 RyanLiu99 commented Aug 17, 2025

Over years I have seen multiple companies use singleton as default IoC scope.

So I want to update guide line to make clear what is the cost, suggest at least avoid singleton for stateless service

Summary

I add a list to list what are the drawbacks of singleton, emphasis when and esp. when not to use Singleton IoC scope.


Internal previews

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

…for stateless service

Over years I have seen multiple companies use singleton as default IoC scope. 

So I want to update guide line to make clear what is the cost, suggest at least avoid singleton for stateless service
@RyanLiu99 RyanLiu99 requested review from IEvangelist and a team as code owners August 17, 2025 22:32
@dotnetrepoman dotnetrepoman bot added this to the August 2025 milestone Aug 17, 2025
Copy link
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 issues. Other issues are also a high priority. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@dotnet-policy-service dotnet-policy-service bot added dotnet-fundamentals/svc community-contribution Indicates PR is created by someone from the .NET community. labels Aug 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates PR is created by someone from the .NET community. dotnet-fundamentals/svc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant