Skip to content

Use shared strings for Array:Copy exception messages #63163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/mono/System.Private.CoreLib/src/System/Array.Mono.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static void Copy(Array sourceArray, int sourceIndex, Array destinationAr
throw new ArgumentNullException(nameof(destinationArray));

if (length < 0)
throw new ArgumentOutOfRangeException(nameof(length), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NeedNonNegNum);

if (sourceArray.Rank != destinationArray.Rank)
throw new RankException(SR.Rank_MultiDimNotSupported);
Expand All @@ -153,19 +153,17 @@ private static void CopySlow(Array sourceArray, int sourceIndex, Array destinati
int dest_pos = destinationIndex - destinationArray.GetLowerBound(0);

if (source_pos < 0)
throw new ArgumentOutOfRangeException(nameof(sourceIndex), "Index was less than the array's lower bound in the first dimension.");
throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_ArrayLB);

if (dest_pos < 0)
throw new ArgumentOutOfRangeException(nameof(destinationIndex), "Index was less than the array's lower bound in the first dimension.");
throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_ArrayLB);

// re-ordered to avoid possible integer overflow
if (source_pos > sourceArray.Length - length)
throw new ArgumentException(SR.Arg_LongerThanSrcArray, nameof(sourceArray));

if (dest_pos > destinationArray.Length - length)
{
throw new ArgumentException("Destination array was not long enough. Check destIndex and length, and the array's lower bounds", nameof(destinationArray));
}
throw new ArgumentException(SR.Arg_LongerThanDestArray, nameof(destinationArray));

Type src_type = sourceArray.GetType().GetElementType()!;
Type dst_type = destinationArray.GetType().GetElementType()!;
Expand Down