Conversation
|
This is very much needed behavior. Hope this can get fast-tracked into the next release. Although, in the future it might be nice to have a solution that doesn't require our services to be decorated with DI-specific metadata. e.g. I'd like to be able to write a Func<Type, string> that serves as a key selector. |
There was a problem hiding this comment.
Hmm. I'm not sure I'm fully on board with this design. We already have UsingAttributes and the ServiceDescriptorAttribute. Can we just expand that to hold a service key as well? At the very least, that functionality should also consider the new attribute.
I guess it's valid to want to specify the key while keeping a fluent configuration for service type and lifetime configuration, but at the very least, the method should be named more explicitly, like WithServiceKeyFromAttribute, as we'd want to use the WithKeyName for overloads taking Func<Type, string> or just string.
| <LangVersion>latest</LangVersion> | ||
| <Nullable>enable</Nullable> | ||
| <TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
| <TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
@khellang
Add ServiceKeyAttribute to keyed services.
ServiceDescriptor make the rest in LifetimeSelector.Populate