-
Notifications
You must be signed in to change notification settings - Fork 5k
Improve error message when GetRequiredKeyedService() fails #114796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
Files not reviewed (1)
- src/libraries/Microsoft.Extensions.DependencyInjection/src/Resources/Strings.resx: Language not supported
Tagging subscribers to this area: @dotnet/area-extensions-dependencyinjection |
@@ -195,4 +195,7 @@ | |||
<data name="KeyedServiceAnyKeyUsedToResolveService" xml:space="preserve"> | |||
<value>KeyedService.AnyKey cannot be used to resolve a single service.</value> | |||
</data> | |||
<data name="NoKeyedServiceRegistered" xml:space="preserve"> | |||
<value>No keyed service for type '{0}' using key type '{1}' has been registered.</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to include a ToString()'d key, only its type? Seems like one of the most common types of keys is string, and that string value would be more useful than "System.String". Is it that we're concerned about leaking details in the error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically don't show disclose (possible) user data, but type names are OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modulo @stephentoub comment, LGTM.
/ba-g infra build timeouts |
Adds "keyed" and the name of the key type to the message to help with diagnostics.
Fixes #112702