Commit 6ef2be492e56707bc181017660b8aef6067834be

Fix ArgumentOutOfRangeException in OrderedCollection.CopyTo().

Consider:

  var dict = new OrderedDictionary<int, int>() {
    { 1, 1 },
    { 2, 4 },
    { 3, 9 },
  };
  int[] dest= new int [5];
	dict.CopyTo (dest, 1);

In the above, we're copying the OrderedDictionary contents into the middle of
the `dest` array, which is perfectly acceptable.

However, this would result in an ArgumentOutOfRangeException, because CopyTo()
would loop until it hit the length of the destination array, which can be (is,
above) larger than the dictionary itself.

Result: ArgumentOutOfRangeException when indexing into the backing List<int>.

The fix is to instead loop until we hit the maximum index of the dictionary,
not the maximum size of the destination array.
  
316316 if (arrayIndex < 0)
317317 throw new ArgumentOutOfRangeException ("arrayIndex");
318318
319 int index = 0;
320 for (int i = arrayIndex; i < array.Length; ++i)
321 {
322 TKey key = keyOrder[index++];
323 array[i] = new KeyValuePair<TKey, TValue> (key, this.dict[key]);
319
320 for (int i = 0; i < this.keyOrder.Count; ++i) {
321 TKey key = keyOrder [i];
322 array [arrayIndex++] = new KeyValuePair<TKey, TValue> (key, this.dict [key]);
324323 }
325324 }
326325
372372 if (arrayIndex < 0 || arrayIndex > array.Length)
373373 throw new ArgumentOutOfRangeException ("arrayIndex");
374374
375 int index = 0;
376 for (int i = arrayIndex; i < array.Length; ++i)
377 array[i] = this.odict[index++];
375 for (int i = 0; i < this.odict.Count; ++i)
376 array [arrayIndex++] = this.odict [i];
378377 }
379378
380379 public int Count