dotnet / dotnet/AspNetCore.Docs
Rationale needed for claims made by this page
- Dominant language
- C#
- Stars
- 13.1k
- Forks
- 24.6k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 109
Description
[Enter feedback here]
>>To replace MyDependency with a different implementation, the IndexModel class must be modified.
Nonsense - you just change the implementation of MyDependency and then recompile the solution. As long as it's only MyDependency's internal code (i.e. its implementation) that has changed (as opposed to its public data and methods), no change to IndexModel or any other code that makes use of MyDependency will be needed.
>>If MyDependency has dependencies, they must also be configured by the IndexModel class. In a large project with multiple classes depending on MyDependency, the configuration code becomes scattered across the app.
That entirely depends upon the nature of MyDependency and its dependencies - it's entirely conceivable that MyDependency implicitly knows how to configure its own dependencies (if indeed they need any configuration). We appear to be picking somewhat at the outside of the envelope here.
>>This implementation is difficult to unit test.
Why?
---
#### Document Details
⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*
* ID: 0d78f540-81fd-1ba9-cb90-591e4ec27d9b
* Version Independent ID: 2251f557-dd3a-ec35-2558-6243337db009
* Content: [Dependency injection in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-7.0#service-lifetimes)
* Content Source: [aspnetcore/fundamentals/dependency-injection.md](https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/dependency-injection.md)
* Product: **aspnet-core**
* Technology: **aspnetcore-fundamentals**
* GitHub Login: @Rick-Anderson
* Microsoft Alias: **riande**
Contributor guide
Assessment
This issue has not been assessed yet.