diff options
author | Jon Skeet <jonskeet@google.com> | 2015-07-03 11:41:37 +0100 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2015-07-09 08:26:07 +0100 |
commit | 14f2222a50a18ff0d8772095587b9cdad455a7bb (patch) | |
tree | 1422e99fad875a04921a0b8c881f48c63937f84c /csharp/src/ProtocolBuffers/Collections/RepeatedField.cs | |
parent | af259b77bf04fcfb68609776cb27f04d289a2c39 (diff) | |
download | protobuf-14f2222a50a18ff0d8772095587b9cdad455a7bb.tar.gz protobuf-14f2222a50a18ff0d8772095587b9cdad455a7bb.tar.bz2 protobuf-14f2222a50a18ff0d8772095587b9cdad455a7bb.zip |
Lots more tests for FieldCodec, MapField, RepeatedField
... and some implementation changes to go with them.
Diffstat (limited to 'csharp/src/ProtocolBuffers/Collections/RepeatedField.cs')
-rw-r--r-- | csharp/src/ProtocolBuffers/Collections/RepeatedField.cs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index ebc711de..b6b52cb9 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -376,6 +376,7 @@ namespace Google.Protobuf.Collections this.CheckMutable(); EnsureSize(count + 1); Array.Copy(array, index, array, index + 1, count - index); + array[index] = item; count++; } @@ -421,18 +422,12 @@ namespace Google.Protobuf.Collections void ICollection.CopyTo(Array array, int index) { - ThrowHelper.ThrowIfNull(array, "array"); - T[] strongArray = array as T[]; - if (strongArray == null) - { - throw new ArgumentException("Array is of incorrect type", "array"); - } - CopyTo(strongArray, index); + Array.Copy(this.array, 0, array, index, count); } bool ICollection.IsSynchronized { get { return false; } } - object ICollection.SyncRoot { get { return null; } } + object ICollection.SyncRoot { get { return this; } } object IList.this[int index] { @@ -490,6 +485,7 @@ namespace Google.Protobuf.Collections { if (index + 1 >= field.Count) { + index = field.Count; return false; } index++; |