Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
code review Exceptions
  • Loading branch information
AlexRadch committed Jul 12, 2023
commit 8296fe679a2a42ed3db77f4e95c090ff8b0d0ea1
Original file line number Diff line number Diff line change
Expand Up @@ -4235,7 +4235,4 @@
<data name="OutOfMemory_StringTooLong" xml:space="preserve">
<value>String length exceeded supported range.</value>
</data>
<data name="Arg_MustBeArrayType" xml:space="preserve">
<value>Type must be a array type.</value>
</data>
</root>
</root>
12 changes: 6 additions & 6 deletions src/libraries/System.Private.CoreLib/src/System/Array.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ public static unsafe Array CreateInstanceFromArrayType(Type arrayType, int lengt
ArgumentOutOfRangeException.ThrowIfNegative(length);

if (!arrayType.IsArray)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeArrayType, ExceptionArgument.arrayType);
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_HasToBeArrayClass, ExceptionArgument.arrayType);
if (arrayType.GetArrayRank() != 1)
ThrowHelper.ThrowArgumentException_Argument_IncompatibleArrayType();
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported, ExceptionArgument.arrayType);

return InternalCreateFromArrayType(arrayType, 1, &length, null);
}
Expand All @@ -228,9 +228,9 @@ public static unsafe Array CreateInstanceFromArrayType(Type arrayType, params in
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank);

if (!arrayType.IsArray)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeArrayType, ExceptionArgument.arrayType);
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_HasToBeArrayClass, ExceptionArgument.arrayType);
if (arrayType.GetArrayRank() != lengths.Length)
ThrowHelper.ThrowArgumentException_Argument_IncompatibleArrayType();
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices, ExceptionArgument.lengths);

// Check to make sure the lengths are all non-negative. Note that we check this here to give
// a good exception message if they are not; however we check this again inside the execution
Expand All @@ -255,9 +255,9 @@ public static unsafe Array CreateInstanceFromArrayType(Type arrayType, int[] len
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank);

if (!arrayType.IsArray)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeArrayType, ExceptionArgument.arrayType);
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_HasToBeArrayClass, ExceptionArgument.arrayType);
if (arrayType.GetArrayRank() != lengths.Length)
ThrowHelper.ThrowArgumentException_Argument_IncompatibleArrayType();
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices, ExceptionArgument.lengths);

// Check to make sure the lengths are all non-negative. Note that we check this here to give
// a good exception message if they are not; however we check this again inside the execution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1149,8 +1149,8 @@ private static string GetResourceString(ExceptionResource resource)
return SR.Format_UnclosedFormatItem;
case ExceptionResource.Format_ExpectedAsciiDigit:
return SR.Format_ExpectedAsciiDigit;
case ExceptionResource.Arg_MustBeArrayType:
return SR.Arg_MustBeArrayType;
case ExceptionResource.Argument_HasToBeArrayClass:
return SR.Argument_HasToBeArrayClass;
default:
Debug.Fail("The enum value is not defined, please check the ExceptionResource Enum.");
return "";
Expand Down Expand Up @@ -1348,6 +1348,6 @@ internal enum ExceptionResource
Format_UnexpectedClosingBrace,
Format_UnclosedFormatItem,
Format_ExpectedAsciiDigit,
Arg_MustBeArrayType,
Argument_HasToBeArrayClass,
}
}