Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 24 additions & 0 deletions src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="MaxArrayElementSize.cs" />
</ItemGroup>
</Project>
Loading