-
Notifications
You must be signed in to change notification settings - Fork 6.1k
docs: clarify thread safety of service resolution in .NET dependency … #50123
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
…injection ### Summary Clarified that resolving services from the built-in .NET dependency injection (DI) container is thread-safe. ### Changes - Updated the **Thread safety** section in `dependency-injection-guidelines.md`. - Added explicit statement that: - Service resolution via `IServiceProvider` and `IServiceScope` is thread-safe. - Service implementations themselves must still handle internal concurrency. - Added a note block for clarity. ### Motivation Resolves issue dotnet#47086 by explicitly documenting DI service resolution thread safety, which was previously implied but not stated.
|
Hi @dotnet/docs |
Clarify thread safety and recommendations for DI usage.
|
Hi @IEvangelist, |
Updated the dependency injection guidelines to improve clarity and correctness in the documentation.
|
|
||
| - Property injection | ||
| - Injection based on name (.NET 7 and earlier versions only. For more information, see [Keyed services](dependency-injection.md#keyed-services).) | ||
| - Injection based on name (.NET 7 and earlier versions only–for more information, see [Keyed services](dependency-injection.md#keyed-services)) |
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.
This item may give the wrong impression that injection based on name is only available in .NET 7 and earlier versions.
Now that .NET 7 is no longer supported, and later versions of Microsoft.Extensions.DependencyInjection still target .NET Standard 2.0 too, it might be better to remove the item altogether.
…injection
Summary
Clarified that resolving services from the built-in .NET dependency injection (DI) container is thread-safe.
Changes
dependency-injection-guidelines.md.IServiceProviderandIServiceScopeis thread-safe.Motivation
Resolves issue #47086 by explicitly documenting DI service resolution thread safety, which was previously implied but not stated.
Summary
Describe your changes here.
Fixes #Issue_Number (if available)
Internal previews