Skip to content

Commit 85a44ff

Browse files
committed
Skip handling of void arrays for this PR
1 parent 19271ef commit 85a44ff

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

src/coreclr/classlibnative/bcltype/arraynative.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ static void CheckElementType(TypeHandle elementType)
732732
COMPlusThrow(kNotSupportedException, W("NotSupported_ByRefLikeArray"));
733733

734734
// Check for open generic types.
735-
if (pMT->IsGenericTypeDefinition() || pMT->ContainsGenericVariables())
735+
if (pMT->ContainsGenericVariables())
736736
COMPlusThrow(kNotSupportedException, W("NotSupported_OpenType"));
737737

738738
// Check for Void.
@@ -765,7 +765,8 @@ void QCALLTYPE Array_CreateInstance(QCall::TypeHandle pTypeHnd, INT32 rank, INT3
765765
_ASSERTE((INT32)typeHnd.GetRank() == rank);
766766
_ASSERTE(typeHnd.IsArray());
767767

768-
CheckElementType(typeHnd.GetArrayElementTypeHandle());
768+
if (typeHnd.GetArrayElementTypeHandle().ContainsGenericVariables())
769+
COMPlusThrow(kNotSupportedException, W("NotSupported_OpenType"));
769770

770771
if (!typeHnd.AsMethodTable()->IsMultiDimArray())
771772
{

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Array.NativeAot.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ internal unsafe bool IsSzArray
5858
[RequiresDynamicCode("The code for an array of the specified type might not be available.")]
5959
private static unsafe Array InternalCreate(RuntimeType elementType, int rank, int* pLengths, int* pLowerBounds)
6060
{
61-
ValidateElementType(elementType);
61+
if (elementType.IsByRef || elementType.IsByRefLike)
62+
throw new NotSupportedException(SR.NotSupported_ByRefLikeArray);
63+
if (elementType == typeof(void))
64+
throw new NotSupportedException(SR.NotSupported_VoidArray);
65+
if (elementType.ContainsGenericParameters)
66+
throw new NotSupportedException(SR.NotSupported_OpenType);
6267

6368
if (pLowerBounds != null)
6469
{
@@ -93,7 +98,8 @@ private static unsafe Array InternalCreateFromArrayType(RuntimeType arrayType, i
9398
Debug.Assert(arrayType.IsArray);
9499
Debug.Assert(arrayType.GetArrayRank() == rank);
95100

96-
ValidateElementType(arrayType.GetElementType());
101+
if (arrayType.ContainsGenericParameters)
102+
throw new NotSupportedException(SR.NotSupported_OpenType);
97103

98104
if (pLowerBounds != null)
99105
{
@@ -125,16 +131,6 @@ private static unsafe Array InternalCreateFromArrayType(RuntimeType arrayType, i
125131
}
126132
}
127133

128-
private static void ValidateElementType(Type elementType)
129-
{
130-
if (elementType.IsByRef || elementType.IsByRefLike)
131-
throw new NotSupportedException(SR.NotSupported_ByRefLikeArray);
132-
if (elementType == typeof(void))
133-
throw new NotSupportedException(SR.NotSupported_VoidArray);
134-
if (elementType.ContainsGenericParameters)
135-
throw new NotSupportedException(SR.NotSupported_OpenType);
136-
}
137-
138134
public unsafe void Initialize()
139135
{
140136
EETypePtr pElementEEType = ElementEEType;

src/libraries/System.Runtime/tests/System.Runtime.Tests/System/ArrayTests.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,10 +1826,6 @@ public static unsafe IEnumerable<object[]> CreateInstance_TestData()
18261826
new object[] { typeof(GenericInterface<int>), default(GenericInterface<int>) },
18271827
new object[] { typeof(AbstractClass), default(AbstractClass) },
18281828
new object[] { typeof(StaticClass), default(StaticClass) },
1829-
1830-
// Arrays of void arrays
1831-
new object[] { typeof(void).MakeArrayType(), null },
1832-
new object[] { typeof(void).MakeArrayType(1), null },
18331829
};
18341830
}
18351831

@@ -1950,10 +1946,7 @@ public void CreateInstance_NotSupportedType_ThrowsNotSupportedException(Type ele
19501946
}
19511947

19521948
[Theory]
1953-
[InlineData(typeof(void))]
19541949
[InlineData(typeof(GenericClass<>))]
1955-
// not using any by-ref type here as MakeArrayType throws for them, same goes for Type.GetType("SomeByRef[]")
1956-
[ActiveIssue("https://github.com/dotnet/runtime/issues/94086", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime))]
19571950
public void CreateInstanceFromArrayType_NotSupportedArrayType_ThrowsNotSupportedException(Type elementType)
19581951
{
19591952
Assert.Throws<NotSupportedException>(() => Array.CreateInstanceFromArrayType(elementType.MakeArrayType(), 0));

0 commit comments

Comments
 (0)