Commit 62058bd9de6d617527523bc3ae9fc3f5f57c2f89
Generate proper exception in OrderedDictionary.Insert() for invalid indexes.
IList<T>.Insert() is documented as throwing ArgumentOutOfRangeException if the
index is invalid. However, OrderedDictionary.Insert() was instead throwing an
ArgumentException. The reason is because OrderedDictionary.Insert() isn't
doing any argument validation, instead relying upon the underlying Dictionary
and List instances, and in some circumstances the Dictionary would throw
ArgumentException before the List could throw ArgumentOutOfRangeException.
| |   |
| 263 | 263 | /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is less than 0 or greater than <see cref="Count"/></exception> |
| 264 | 264 | public void Insert (int index, TKey key, TValue value) |
| 265 | 265 | { |
| this.dict.Add (key, value); |
| 267 | 266 | this.keyOrder.Insert (index, key); |
| this.dict.Add (key, value); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | void IList<KeyValuePair<TKey, TValue>>.Insert (int index, KeyValuePair<TKey, TValue> item) |