Support resolving keyed services from DI in RDF and RDG#50093
Support resolving keyed services from DI in RDF and RDG#50093captainsafia wants to merge 1 commit intomainfrom
Conversation
9c233cb to
95c58d7
Compare
There was a problem hiding this comment.
The changes in these text files are all related to the fact that we've added a Microsoft.Extensions.DependencyInjection using to the test script so the intercept line numbers changed. It's immaterial to the change here.
| { | ||
| Source = EndpointParameterSource.Service; | ||
| } | ||
| else if (attributes.TryGetAttribute(wellKnownTypes.Get(WellKnownType.Microsoft_Extensions_DependencyInjection_FromKeyedServicesAttribute), out var keyedServicesAttribute)) |
There was a problem hiding this comment.
Does this work with derived types?
There was a problem hiding this comment.
Are you referring to if the user is using a derived version of FromKeyedServices attribute? If so, the answer is no but not sure that is a scenario we want to support?
There was a problem hiding this comment.
That is what I'm referring to. The type is unsealed by design I believe.
| public async Task SupportsSingleKeyedServiceWithPrimitiveKeyTypes(object key) | ||
| { | ||
| var source = $$""" | ||
| app.MapGet("/", (HttpContext context, [FromKeyedServices({{key.ToString()?.ToLowerInvariant()}})] TestService arg) => context.Items["arg"] = arg); |
There was a problem hiding this comment.
Does this work? The key is a string but the keyed service is added with object.
There was a problem hiding this comment.
The key here is actually an object. The ToString()?.ToLowerVariant() here is to get it to emit the write code for the false value. The source code snippet ends up having [FromKeyedServices(false)], [FromKeyedServices(12.3)], etc.
There was a problem hiding this comment.
Ok, stringed code is odd looking 😃
|
Closing so I can cherry-pick and retarget to 8.0-rc1. See #50095. |
Addresses #49633