dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.28k stars 5.91k forks source link

Ambiguous paragraph #34173

Open SmartmanApps opened 1 year ago

SmartmanApps commented 1 year ago

Hi, I'm just learning dependency injection, and found this paragraph...

"Once the Build method has been called, the services registered with the dependency injection container will be immutable and no longer can be updated or modified"

...to be ambiguous. When it says "the services registered....will be immutable", does that mean that the registrations are immutable (can't register any more services), or the services themselves are immutable (no data within the service can be altered)?

i.e. saying "services registered" could be referring to the list of services on the register, or the services themselves. Please make this clearer. e.g. "the register (of services) is immutable", or "the services (which you have registered) will be immutable".

thanks, Donald.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

gewarren commented 1 year ago

cc @IEvangelist @jamesmontemagno

michaelstonis commented 1 year ago

@gewarren @SmartmanApps this means that the list of registered services is immutable, and no additional service can be added, removed, or modified later. If the registered object has properties or maintains values, those are mutable per what that object allows.

Thanks for the feedback. I will look into getting this section updated for clarity.

SmartmanApps commented 1 year ago

Thanks @michaelstonis, I figured that was probably the case (but I'd never used DI before reading through this, so who knows), but it's certainly confusing at first. Maybe something like "the register of services" or "the registration of services" or something like that would make it clearer you're referring to the register, not the services. To me it reads like the services are the subject. i.e. "the services....".

jamesmontemagno commented 1 year ago

@michaelstonis any tweaks? shoot over the PR and tag me