aspnetcore/fundamentals/aot/request-delegate-generator/diagnostics/rdg013.md
| Value | |
|---|---|
| Rule ID | RDG013 |
| Fix is breaking or non-breaking | Non-breaking |
This diagnostic is emitted by the Request Delegate Generator when an endpoint contains a route handler with a parameter that contains an invalid combination of service source attributes.
ASP.NET Core supports resolving keyed and non-keyed services via dependency injection. It's not feasible to resolve a service as both keyed and non-keyed. The following code produces the diagnostic and throws a run time error with the same message:
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg13/Program.cs" id="snippet_1" highlight="14":::
Resolve the target parameter as either a keyed or non-keyed service.
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg13/Program.cs" id="snippet_1f" highlight="16,21,26":::
This warning should not be suppressed. Suppressing the warning leads to a NotSupportedException runtime exception The FromKeyedServicesAttribute is not supported on parameters that are also annotated with IFromServiceMetadata.