Skip to content

Commit 2024071

Browse files
jkotaspull[bot]
authored andcommitted
Fix error message for byref of byref TypeLoadException (#98548)
Related to #98426
1 parent 3cb0e15 commit 2024071

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/coreclr/dlls/mscorrc/mscorrc.rc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,12 @@ BEGIN
309309
IDS_CLASSLOAD_GENERICTYPE_RECURSIVE "Could not load type '%1' from assembly '%2' because it has recursive generic definition."
310310
IDS_CLASSLOAD_TOOMANYGENERICARGS "Could not load type '%1' from assembly '%2'. Internal limitation: Too many generic arguments."
311311

312-
IDS_CLASSLOAD_INLINE_ARRAY_FIELD_COUNT "InlineArrayAttribute requires that the target type has a single instance field. Type: '%1'. Assembly: '%2'."
313-
IDS_CLASSLOAD_INLINE_ARRAY_LENGTH "InlineArrayAttribute requires that the length argument is greater than 0. Type: '%1'. Assembly: '%2'."
314-
IDS_CLASSLOAD_INLINE_ARRAY_EXPLICIT "InlineArrayAttribute cannot be applied to a type with explicit layout. Type: '%1'. Assembly: '%2'."
312+
IDS_CLASSLOAD_INLINE_ARRAY_FIELD_COUNT "InlineArrayAttribute requires that the target type has a single instance field. Type: '%1'. Assembly: '%2'."
313+
IDS_CLASSLOAD_INLINE_ARRAY_LENGTH "InlineArrayAttribute requires that the length argument is greater than 0. Type: '%1'. Assembly: '%2'."
314+
IDS_CLASSLOAD_INLINE_ARRAY_EXPLICIT "InlineArrayAttribute cannot be applied to a type with explicit layout. Type: '%1'. Assembly: '%2'."
315+
316+
IDS_CLASSLOAD_BYREF_OF_BYREF "Could not create a ByRef of a ByRef. Type: '%1'. Assembly: '%2'."
317+
IDS_CLASSLOAD_POINTER_OF_BYREF "Could not create a pointer to a ByRef. Type: '%1'. Assembly: '%2'."
315318

316319
IDS_INVALID_RECURSIVE_GENERIC_FIELD_LOAD "Could not load type '%1' from assembly '%2' because of an invalid self-referential generic field."
317320

src/coreclr/dlls/mscorrc/resource.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@
174174
#define IDS_CLASSLOAD_INLINE_ARRAY_LENGTH 0x17ad
175175
#define IDS_CLASSLOAD_INLINE_ARRAY_EXPLICIT 0x17ae
176176

177+
#define IDS_CLASSLOAD_BYREF_OF_BYREF 0x17af
178+
#define IDS_CLASSLOAD_POINTER_OF_BYREF 0x17b0
179+
177180
#define IDS_DEBUG_USERBREAKPOINT 0x17b6
178181

179182
#define IDS_PERFORMANCEMON_FUNCNOTFOUND 0x17bb

src/coreclr/vm/clsload.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2751,7 +2751,7 @@ TypeHandle ClassLoader::CreateTypeHandleForTypeKey(const TypeKey* pKey, AllocMem
27512751
// no parameterized type allowed on a reference
27522752
if (paramType.GetInternalCorElementType() == ELEMENT_TYPE_BYREF)
27532753
{
2754-
ThrowTypeLoadException(pKey, IDS_CLASSLOAD_GENERAL);
2754+
ThrowTypeLoadException(pKey, (kind == ELEMENT_TYPE_BYREF) ? IDS_CLASSLOAD_BYREF_OF_BYREF : IDS_CLASSLOAD_POINTER_OF_BYREF);
27552755
}
27562756

27572757
// We do allow parameterized types of ByRefLike types. Languages may restrict them to produce safe or verifiable code,

0 commit comments

Comments
 (0)