diff options
author | Wes Haggard <weshaggard@users.noreply.github.com> | 2015-12-23 18:28:44 -0800 |
---|---|---|
committer | Wes Haggard <weshaggard@users.noreply.github.com> | 2015-12-23 18:28:44 -0800 |
commit | e79ae8ca1847620fa20add382cea1ef2468ffe1a (patch) | |
tree | c29fa6c9f2849d9955fe1ad039961da73d42f523 /src | |
parent | 90de35b5c7131526cddbe13fd52c8af7332bbedf (diff) | |
parent | 0f5bca6b8f63f5209fb9d038bac451c52a73d47f (diff) | |
download | coreclr-e79ae8ca1847620fa20add382cea1ef2468ffe1a.tar.gz coreclr-e79ae8ca1847620fa20add382cea1ef2468ffe1a.tar.bz2 coreclr-e79ae8ca1847620fa20add382cea1ef2468ffe1a.zip |
Merge pull request #1452 from akoeplinger/dictionary-duplicatekey
Dictionary: include the key in the "duplicate key" exception message
Diffstat (limited to 'src')
-rw-r--r-- | src/mscorlib/src/System/Collections/Generic/Dictionary.cs | 4 | ||||
-rw-r--r-- | src/mscorlib/src/System/ThrowHelper.cs | 6 | ||||
-rw-r--r-- | src/mscorlib/src/mscorlib.txt | 3 |
3 files changed, 13 insertions, 0 deletions
diff --git a/src/mscorlib/src/System/Collections/Generic/Dictionary.cs b/src/mscorlib/src/System/Collections/Generic/Dictionary.cs index 4b2b82e2ad..22f2ed786c 100644 --- a/src/mscorlib/src/System/Collections/Generic/Dictionary.cs +++ b/src/mscorlib/src/System/Collections/Generic/Dictionary.cs @@ -346,7 +346,11 @@ namespace System.Collections.Generic { for (int i = buckets[targetBucket]; i >= 0; i = entries[i].next) { if (entries[i].hashCode == hashCode && comparer.Equals(entries[i].key, key)) { if (add) { +#if FEATURE_CORECLR + ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(key); +#else ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_AddingDuplicate); +#endif } entries[i].value = value; version++; diff --git a/src/mscorlib/src/System/ThrowHelper.cs b/src/mscorlib/src/System/ThrowHelper.cs index 3f0169b20f..b050dbc4a7 100644 --- a/src/mscorlib/src/System/ThrowHelper.cs +++ b/src/mscorlib/src/System/ThrowHelper.cs @@ -53,6 +53,12 @@ namespace System { throw new ArgumentException(Environment.GetResourceString("Arg_WrongType", value, targetType), "value"); } +#if FEATURE_CORECLR + internal static void ThrowAddingDuplicateWithKeyArgumentException(object key) { + throw new ArgumentException(Environment.GetResourceString("Argument_AddingDuplicateWithKey", key)); + } +#endif + internal static void ThrowKeyNotFoundException() { throw new System.Collections.Generic.KeyNotFoundException(); } diff --git a/src/mscorlib/src/mscorlib.txt b/src/mscorlib/src/mscorlib.txt index 7687e80fa2..5dcdbb885f 100644 --- a/src/mscorlib/src/mscorlib.txt +++ b/src/mscorlib/src/mscorlib.txt @@ -121,6 +121,9 @@ Access_Void = Cannot create an instance of void. Arg_TypedReference_Null = The TypedReference must be initialized. Argument_AddingDuplicate__ = Item has already been added. Key in dictionary: '{0}' Key being added: '{1}' Argument_AddingDuplicate = An item with the same key has already been added. +#if FEATURE_CORECLR +Argument_AddingDuplicateWithKey = An item with the same key has already been added. Key: {0} +#endif // FEATURE_CORECLR Argument_MethodDeclaringTypeGenericLcg = Method '{0}' has a generic declaring type '{1}'. Explicitly provide the declaring type to GetTokenFor. Argument_MethodDeclaringTypeGeneric = Cannot resolve method {0} because the declaring type of the method handle {1} is generic. Explicitly provide the declaring type to GetMethodFromHandle. Argument_FieldDeclaringTypeGeneric = Cannot resolve field {0} because the declaring type of the field handle {1} is generic. Explicitly provide the declaring type to GetFieldFromHandle. |