diff --git a/src/libraries/System.Private.CoreLib/src/System/Array.cs b/src/libraries/System.Private.CoreLib/src/System/Array.cs index 5ff7790fad3ae0..dbf4766b7e958e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Array.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Array.cs @@ -352,6 +352,8 @@ public static void Copy(Array sourceArray, long sourceIndex, Array destinationAr Copy(sourceArray, isourceIndex, destinationArray, idestinationIndex, ilength); } +#if !MONO // implementation details of MethodTable + // Provides a strong exception guarantee - either it succeeds, or // it throws an exception with no side effects. The arrays must be // compatible array types based on the array element type - this @@ -359,11 +361,9 @@ public static void Copy(Array sourceArray, long sourceIndex, Array destinationAr // It will up-cast, assuming the array types are correct. public static void ConstrainedCopy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { - CopyImpl(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable: true); + Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable: true); } -#if !MONO // implementation details of MethodTable - // Copies length elements from sourceArray, starting at index 0, to // destinationArray, starting at index 0. public static unsafe void Copy(Array sourceArray, Array destinationArray, int length) @@ -396,7 +396,12 @@ public static unsafe void Copy(Array sourceArray, Array destinationArray, int le // Copies length elements from sourceArray, starting at sourceIndex, to // destinationArray, starting at destinationIndex. - public static unsafe void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) + public static void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) + { + Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable: false); + } + + private static unsafe void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { if (sourceArray != null && destinationArray != null) { @@ -423,7 +428,7 @@ public static unsafe void Copy(Array sourceArray, int sourceIndex, Array destina } // Less common - CopyImpl(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable: false); + CopyImpl(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable); } // Reliability-wise, this method will either possibly corrupt your diff --git a/src/mono/System.Private.CoreLib/src/System/Array.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Array.Mono.cs index fa2abf42a567ce..e7cec206975d8f 100644 --- a/src/mono/System.Private.CoreLib/src/System/Array.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Array.Mono.cs @@ -106,6 +106,11 @@ public static void Copy(Array sourceArray, int sourceIndex, Array destinationArr CopyImpl(sourceArray, sourceIndex, destinationArray, destinationIndex, length, false); } + public static void ConstrainedCopy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) + { + CopyImpl(sourceArray, sourceIndex, destinationArray, destinationIndex, length, true); + } + private static void CopyImpl(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { ArgumentNullException.ThrowIfNull(sourceArray);