Key item added to KeyNotFoundException #15201
Conversation
@dotnet-bot test CentOS7.1 x64 Checked Innerloop Build and Test |
LGTM |
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
{ | ||
throw new KeyNotFoundException(); | ||
throw new KeyNotFoundException(key.ToString()); |
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.
@Anipik This needs to use SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString())
to get the proper error message.
Also, this may need to be split into the Throw
+ Get...Exception
method pair like the other similar methods in this file to allow JIT to generate better code for it.
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.
isn't both throw + get already separated as we have ThrowKeyNotFoundException(object key) and KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString())); functions
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.
Separating it even more has additional benefits - check the discussion in #7580 that introduced it.
@@ -426,6 +426,9 @@ | |||
</data> | |||
<data name="Arg_KeyNotFound" xml:space="preserve"> | |||
<value>The given key was not present in the dictionary.</value> | |||
</data> | |||
<data name="Arg_KeyNotFoundWithKey" xml:space="preserve"> | |||
<value>The given key '{0}' was not present in the dictionary.</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.
Indenting issue here.
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
@danmosemsft, this change is fine. However, it is going to break CoreFX and CoreRT because the use of the string is in the shared directory but the string definition is not. So, the string change needs to be ported to both corefx and corert. |
@Anipik note you have feedback above to address. |
@brianrob dotnet/corefx#25472 contains the changes for the issue. Are they sufficient or we require to change anything else in corefx ? |
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
issue- dotnet/corefx#5188
corefx pr - dotnet/corefx#25472