Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public TValue this[TKey key]

Entry entry = Find(key);
if (entry == null)
throw new KeyNotFoundException();
throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
return entry._value;
}
set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public object this[string key]
position++;
}

throw new System.Collections.Generic.KeyNotFoundException();
throw new System.Collections.Generic.KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
}
set
{
Expand Down
3 changes: 3 additions & 0 deletions src/System.Collections.Concurrent/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,7 @@
<data name="ConcurrentBag_Enumerator_EnumerationNotStartedOrAlreadyFinished" xml:space="preserve">
<value>Enumeration has either not started or has already finished.</value>
</data>
<data name="Arg_KeyNotFoundWithKey" xml:space="preserve">
<value>The given key '{0}' was not present in the dictionary.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ public TValue this[TKey key]
TValue value;
if (!TryGetValue(key, out value))
{
ThrowKeyNotFoundException();
ThrowKeyNotFoundException(key);
}
return value;
}
Expand All @@ -894,9 +894,9 @@ public TValue this[TKey key]
// of important methods like TryGetValue and ContainsKey.

[MethodImpl(MethodImplOptions.NoInlining)]
private static void ThrowKeyNotFoundException()
private static void ThrowKeyNotFoundException(object key)
{
throw new KeyNotFoundException();
throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
}

[MethodImpl(MethodImplOptions.NoInlining)]
Expand Down
3 changes: 3 additions & 0 deletions src/System.Collections.Immutable/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Arg_KeyNotFoundWithKey" xml:space="preserve">
<value>The given key '{0}' was not present in the dictionary.</value>
</data>
<data name="ArrayInitializedStateNotEqual" xml:space="preserve">
<value>Object is not an array with the same initialization state as the array to compare it to.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public TValue this[TKey key]
return value;
}

throw new KeyNotFoundException();
throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
}

set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public TValue this[TKey key]
return value;
}

throw new KeyNotFoundException();
throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
}

set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public TValue this[TKey key]
return value;
}

throw new KeyNotFoundException();
throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/System.Collections/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,7 @@
<data name="Serialization_MissingValues" xml:space="preserve">
<value>The values for this dictionary are missing.</value>
</data>
</root>
<data name="Arg_KeyNotFoundWithKey" xml:space="preserve">
<value>The given key '{0}' was not present in the dictionary.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public TValue this[TKey key]
TreeSet<KeyValuePair<TKey, TValue>>.Node node = _set.FindNode(new KeyValuePair<TKey, TValue>(key, default(TValue)));
if (node == null)
{
throw new KeyNotFoundException();
throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
}

return node.Item.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ public TValue this[TKey key]
if (i >= 0)
return values[i];

throw new KeyNotFoundException();
throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
}
set
{
Expand Down
3 changes: 3 additions & 0 deletions src/System.Linq.Expressions/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -565,4 +565,7 @@
<data name="SameKeyExistsInExpando" xml:space="preserve">
<value>An element with the same key '{0}' already exists in the ExpandoObject.</value>
</data>
<data name="Arg_KeyNotFoundWithKey" xml:space="preserve">
<value>The given key '{0}' was not present in the dictionary.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public TValue this[TKey key]
return res;
}

throw new KeyNotFoundException();
throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
}
set
{
Expand Down
3 changes: 3 additions & 0 deletions src/System.ObjectModel/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,7 @@
<data name="Argument_InvalidArrayType" xml:space="preserve">
<value>Target array type is not compatible with the type of items in the collection.</value>
</data>
<data name="Arg_KeyNotFoundWithKey" xml:space="preserve">
<value>The given key '{0}' was not present in the dictionary.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public TItem this[TKey key]
return item;
}

throw new KeyNotFoundException();
throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/System.Private.Uri/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,7 @@
<data name="Argument_InvalidUriSubcomponent" xml:space="preserve">
<value>The subcomponent, {0}, of this uri is not valid.</value>
</data>
</root>
<data name="Arg_KeyNotFoundWithKey" xml:space="preserve">
<value>The given key '{0}' was not present in the dictionary.</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/System.Runtime.Extensions/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,7 @@
<data name="IO_PathTooLong_Path" xml:space="preserve">
<value>The path '{0}' is too long, or a component of the specified path is too long.</value>
</data>
<data name="Arg_KeyNotFoundWithKey" xml:space="preserve">
<value>The given key '{0}' was not present in the dictionary.</value>
</data>
</root>