Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2017-01-12 23:57:14 +0300
committerGitHub <noreply@github.com>2017-01-12 23:57:14 +0300
commit74907431e33c9e6757c8937c81a8e6ebfb0aa2aa (patch)
tree3211b3577de1d87f9e12988db73ba9c78bdaa865
parentae5e3b5ba535cbf4c33d0d8b9063737525c65d74 (diff)
parentf1b398d4ffe2d6ad0f8095b8005bf45540cd64cd (diff)
Merge pull request #2494 from dotnet-bot/from-tfs
Merge changes from TFS
-rw-r--r--src/System.Private.CoreLib/src/Resources/Strings.resx3
-rw-r--r--src/System.Private.CoreLib/src/System/Array.cs173
2 files changed, 157 insertions, 19 deletions
diff --git a/src/System.Private.CoreLib/src/Resources/Strings.resx b/src/System.Private.CoreLib/src/Resources/Strings.resx
index 2e1ecbe88..24edf287c 100644
--- a/src/System.Private.CoreLib/src/Resources/Strings.resx
+++ b/src/System.Private.CoreLib/src/Resources/Strings.resx
@@ -687,6 +687,9 @@
<data name="Argument_OutOfOrderDateTimes" xml:space="preserve">
<value>The DateStart property must come before the DateEnd property.</value>
</data>
+ <data name="ArgumentOutOfRange_HugeArrayNotSupported" xml:space="preserve">
+ <value>Arrays larger than 2GB are not supported.</value>
+ </data>
<data name="ArgumentOutOfRange_Index" xml:space="preserve">
<value>Index was out of range. Must be non-negative and less than the size of the collection.</value>
</data>
diff --git a/src/System.Private.CoreLib/src/System/Array.cs b/src/System.Private.CoreLib/src/System/Array.cs
index 5564ab734..2b96eced9 100644
--- a/src/System.Private.CoreLib/src/System/Array.cs
+++ b/src/System.Private.CoreLib/src/System/Array.cs
@@ -985,18 +985,6 @@ namespace System
bool IList.IsReadOnly
{ get { return false; } }
- bool IList.IsFixedSize
- {
- get { return true; }
- }
-
- // Is this Array synchronized (i.e., thread-safe)? If you want a synchronized
- // collection, you can use SyncRoot as an object to synchronize your
- // collection with. You could also call GetSynchronized()
- // to get a synchronized wrapper around the Array.
- bool ICollection.IsSynchronized
- { get { return false; } }
-
Object IList.this[int index]
{
get
@@ -1061,13 +1049,6 @@ namespace System
Array.Copy(this, 0, array, index, Length);
}
- // Returns an object appropriate for synchronizing access to this
- // Array.
- Object ICollection.SyncRoot
- {
- get { return this; }
- }
-
// Make a new array which is a deep copy of the original array.
//
public Object Clone()
@@ -1180,6 +1161,160 @@ namespace System
return BinarySearch(array, 0, array.Length, value, null);
}
+ public static TOutput[] ConvertAll<TInput, TOutput>(TInput[] array, Converter<TInput, TOutput> converter)
+ {
+ if (array == null)
+ throw new ArgumentNullException(nameof(array));
+
+ if (converter == null)
+ throw new ArgumentNullException(nameof(converter));
+
+ Contract.Ensures(Contract.Result<TOutput[]>() != null);
+ Contract.Ensures(Contract.Result<TOutput[]>().Length == array.Length);
+ Contract.EndContractBlock();
+
+ TOutput[] newArray = new TOutput[array.Length];
+ for (int i = 0; i < array.Length; i++)
+ {
+ newArray[i] = converter(array[i]);
+ }
+ return newArray;
+ }
+
+ public static void Copy(Array sourceArray, Array destinationArray, long length)
+ {
+ if (length > Int32.MaxValue || length < Int32.MinValue)
+ throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_HugeArrayNotSupported);
+
+ Array.Copy(sourceArray, destinationArray, (int)length);
+ }
+
+ public static void Copy(Array sourceArray, long sourceIndex, Array destinationArray, long destinationIndex, long length)
+ {
+ if (sourceIndex > Int32.MaxValue || sourceIndex < Int32.MinValue)
+ throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_HugeArrayNotSupported);
+ if (destinationIndex > Int32.MaxValue || destinationIndex < Int32.MinValue)
+ throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_HugeArrayNotSupported);
+ if (length > Int32.MaxValue || length < Int32.MinValue)
+ throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_HugeArrayNotSupported);
+
+ Array.Copy(sourceArray, (int)sourceIndex, destinationArray, (int)destinationIndex, (int)length);
+ }
+
+ [Pure]
+ public void CopyTo(Array array, long index)
+ {
+ if (index > Int32.MaxValue || index < Int32.MinValue)
+ throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_HugeArrayNotSupported);
+ Contract.EndContractBlock();
+
+ this.CopyTo(array, (int)index);
+ }
+
+ public static void ForEach<T>(T[] array, Action<T> action)
+ {
+ if (array == null)
+ throw new ArgumentNullException(nameof(array));
+
+ if (action == null)
+ throw new ArgumentNullException(nameof(action));
+
+ Contract.EndContractBlock();
+
+ for (int i = 0; i < array.Length; i++)
+ {
+ action(array[i]);
+ }
+ }
+
+ public long LongLength
+ {
+ get
+ {
+ long ret = GetLength(0);
+
+ for (int i = 1; i < Rank; ++i)
+ {
+ ret = ret * GetLength(i);
+ }
+
+ return ret;
+ }
+ }
+
+ public long GetLongLength(int dimension)
+ {
+ // This method does throw an IndexOutOfRangeException for compat if dimension < 0 or >= Rank
+ // by calling GetUpperBound
+ return GetLength(dimension);
+ }
+
+ public Object GetValue(long index)
+ {
+ if (index > Int32.MaxValue || index < Int32.MinValue)
+ throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_HugeArrayNotSupported);
+ Contract.EndContractBlock();
+
+ return this.GetValue((int)index);
+ }
+
+ public Object GetValue(long index1, long index2)
+ {
+ if (index1 > Int32.MaxValue || index1 < Int32.MinValue)
+ throw new ArgumentOutOfRangeException(nameof(index1), SR.ArgumentOutOfRange_HugeArrayNotSupported);
+ if (index2 > Int32.MaxValue || index2 < Int32.MinValue)
+ throw new ArgumentOutOfRangeException(nameof(index2), SR.ArgumentOutOfRange_HugeArrayNotSupported);
+ Contract.EndContractBlock();
+
+ return this.GetValue((int)index1, (int)index2);
+ }
+
+ public Object GetValue(long index1, long index2, long index3)
+ {
+ if (index1 > Int32.MaxValue || index1 < Int32.MinValue)
+ throw new ArgumentOutOfRangeException(nameof(index1), SR.ArgumentOutOfRange_HugeArrayNotSupported);
+ if (index2 > Int32.MaxValue || index2 < Int32.MinValue)
+ throw new ArgumentOutOfRangeException(nameof(index2), SR.ArgumentOutOfRange_HugeArrayNotSupported);
+ if (index3 > Int32.MaxValue || index3 < Int32.MinValue)
+ throw new ArgumentOutOfRangeException(nameof(index3), SR.ArgumentOutOfRange_HugeArrayNotSupported);
+ Contract.EndContractBlock();
+
+ return this.GetValue((int)index1, (int)index2, (int)index3);
+ }
+
+ public Object GetValue(params long[] indices)
+ {
+ if (indices == null)
+ throw new ArgumentNullException(nameof(indices));
+ if (Rank != indices.Length)
+ throw new ArgumentException(SR.Arg_RankIndices);
+ Contract.EndContractBlock();
+
+ int[] intIndices = new int[indices.Length];
+
+ for (int i = 0; i < indices.Length; ++i)
+ {
+ long index = indices[i];
+ if (index > Int32.MaxValue || index < Int32.MinValue)
+ throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_HugeArrayNotSupported);
+ intIndices[i] = (int)index;
+ }
+
+ return this.GetValue(intIndices);
+ }
+
+ public bool IsFixedSize { get { return true; } }
+
+ // Is this Array synchronized (i.e., thread-safe)? If you want a synchronized
+ // collection, you can use SyncRoot as an object to synchronize your
+ // collection with. You could also call GetSynchronized()
+ // to get a synchronized wrapper around the Array.
+ public bool IsSynchronized { get { return false; } }
+
+ // Returns an object appropriate for synchronizing access to this
+ // Array.
+ public Object SyncRoot { get { return this; } }
+
// Searches a section of an array for a given element using a binary search
// algorithm. Elements of the array are compared to the search value using
// the IComparable interface, which must be implemented by all