From: Marek Safar Date: Tue, 28 Dec 2021 21:20:30 +0000 (+0100) Subject: Use shared strings for Array:Copy exception messages (#63163) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~11699 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eff08ef067fde28e56f19a5d95ca5aba51ac0a75;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Use shared strings for Array:Copy exception messages (#63163) --- 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 a8bf7fd..5a7bab2 100644 --- a/src/mono/System.Private.CoreLib/src/System/Array.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Array.Mono.cs @@ -130,7 +130,7 @@ namespace System 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); @@ -153,19 +153,17 @@ namespace System 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()!;