From 5c820f6434fca3f7293ad23eebf9a5633342250a Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 30 Jun 2026 03:45:54 +0000
Subject: [PATCH 1/3] Initial plan
From 2a0c8a83080ece241c54ac3554cbaec18e482f38 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 30 Jun 2026 04:33:59 +0000
Subject: [PATCH 2/3] Fix NativeAOT max array element size validation
Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
---
.../CompilerTypeSystemContext.Validation.cs | 2 +-
.../InlineArray/MaxArrayElementSize.cs | 24 +++++++++++++++++++
.../InlineArray/MaxArrayElementSize.csproj | 11 +++++++++
3 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.cs
create mode 100644 src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.csproj
diff --git a/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.Validation.cs b/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.Validation.cs
index 6c0b5f9fe2e693..ff34b94f3b43a6 100644
--- a/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.Validation.cs
+++ b/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.Validation.cs
@@ -266,7 +266,7 @@ private static TypeDesc EnsureLoadableTypeUncached(TypeDesc type)
if (parameterizedType.IsArray)
{
LayoutInt elementSize = parameterType.GetElementSize();
- if (!elementSize.IsIndeterminate && elementSize.AsInt >= ushort.MaxValue)
+ if (!elementSize.IsIndeterminate && elementSize.AsInt > ushort.MaxValue)
{
// Element size over 64k can't be encoded in the GCDesc
ThrowHelper.ThrowTypeLoadException(ExceptionStringID.ClassLoadValueClassTooLarge, parameterType);
diff --git a/src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.cs b/src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.cs
new file mode 100644
index 00000000000000..d226e967b2ae30
--- /dev/null
+++ b/src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.cs
@@ -0,0 +1,24 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+public unsafe class MaxArrayElementSize
+{
+ [InlineArray(65535)]
+ struct MaxSizedArrayElement
+ {
+ byte b;
+ }
+
+ [Fact]
+ public static int TestEntryPoint()
+ {
+ return sizeof(MaxSizedArrayElement) == ushort.MaxValue
+ && new MaxSizedArrayElement[1].Length == 1
+ ? 100
+ : 101;
+ }
+}
diff --git a/src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.csproj b/src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.csproj
new file mode 100644
index 00000000000000..c9fd3d77540f45
--- /dev/null
+++ b/src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.csproj
@@ -0,0 +1,11 @@
+
+
+ true
+
+
+
+
+
+
+
+
From ccaaf84ebfd0e71333a9ab2284ddb8240743d3ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?=
Date: Tue, 30 Jun 2026 13:39:39 +0900
Subject: [PATCH 3/3] Remove IlcCompile item group from project file
---
.../Loader/classloader/InlineArray/MaxArrayElementSize.csproj | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.csproj b/src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.csproj
index c9fd3d77540f45..042e92733f2758 100644
--- a/src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.csproj
+++ b/src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.csproj
@@ -5,7 +5,4 @@
-
-
-