Fix typeloader error messages for invalid byref fields (#72102)
authorJan Kotas <jkotas@microsoft.com>
Wed, 13 Jul 2022 19:42:14 +0000 (12:42 -0700)
committerGitHub <noreply@github.com>
Wed, 13 Jul 2022 19:42:14 +0000 (12:42 -0700)
Fixes #72090

Co-authored-by: Stephen Toub <stoub@microsoft.com>
src/coreclr/dlls/mscorrc/mscorrc.rc
src/coreclr/dlls/mscorrc/resource.h
src/coreclr/vm/methodtablebuilder.cpp

index 6a96d6c..892c1f1 100644 (file)
@@ -336,8 +336,8 @@ BEGIN
     IDS_CLASSLOAD_NOTINTERFACE              "Could not load type '%1' from assembly '%2' because it attempts to implement a class as an interface."
     IDS_CLASSLOAD_VALUEINSTANCEFIELD        "Could not load the value type '%1' from assembly '%2' because it has an instance field of itself."
 
-    IDS_CLASSLOAD_BYREFLIKE_STATICFIELD     "A ByRef-like type cannot be used as the type for a static field."
-    IDS_CLASSLOAD_BYREFLIKE_INSTANCEFIELD   "A ByRef-like type cannot be used as the type for an instance field in a non-ByRef-like type."
+    IDS_CLASSLOAD_BYREF_OR_BYREFLIKE_STATICFIELD    "A ByRef or ByRef-like type cannot be used as the type for a static field."
+    IDS_CLASSLOAD_BYREF_OR_BYREFLIKE_INSTANCEFIELD  "A ByRef or ByRef-like type cannot be used as the type for an instance field in a non-ByRef-like type."
 
     IDS_CLASSLOAD_RANK_TOOLARGE             "'%1' from assembly '%2' has too many dimensions."
     IDS_CLASSLOAD_BAD_UNMANAGED_RVA         "Native method '%3' on type '%1' from assembly '%2' is not supported."
index 351ff69..d2177bd 100644 (file)
 
 #define IDS_NATIVE_IMAGE_CANNOT_BE_LOADED_MULTIPLE_TIMES                               0x263a
 
-#define IDS_CLASSLOAD_BYREFLIKE_STATICFIELD        0x263b
-#define IDS_CLASSLOAD_BYREFLIKE_INSTANCEFIELD      0x263c
+#define IDS_CLASSLOAD_BYREF_OR_BYREFLIKE_STATICFIELD    0x263b
+#define IDS_CLASSLOAD_BYREF_OR_BYREFLIKE_INSTANCEFIELD  0x263c
 #define IDS_EE_NDIRECT_LOADLIB_LINUX               0x263e
 #define IDS_EE_NDIRECT_LOADLIB_MAC                 0x263f
 #define IDS_EE_NDIRECT_GETPROCADDRESS_UNIX         0x2640
index 01d1f13..e20c0d5 100644 (file)
@@ -3925,12 +3925,12 @@ VOID    MethodTableBuilder::InitializeFieldDescs(FieldDesc *pFieldDescList,
                 if (fIsStatic)
                 {
                     // Byref-like types cannot be used for static fields
-                    BuildMethodTableThrowException(IDS_CLASSLOAD_BYREFLIKE_STATICFIELD);
+                    BuildMethodTableThrowException(IDS_CLASSLOAD_BYREF_OR_BYREFLIKE_STATICFIELD);
                 }
                 if (!bmtFP->fIsByRefLikeType)
                 {
                     // Non-byref-like types cannot contain byref-like instance fields
-                    BuildMethodTableThrowException(IDS_CLASSLOAD_BYREFLIKE_INSTANCEFIELD);
+                    BuildMethodTableThrowException(IDS_CLASSLOAD_BYREF_OR_BYREFLIKE_INSTANCEFIELD);
                 }
                 break;
             }
@@ -4100,12 +4100,12 @@ IS_VALUETYPE:
                     if (fIsStatic)
                     {
                         // Byref-like types cannot be used for static fields
-                        BuildMethodTableThrowException(IDS_CLASSLOAD_BYREFLIKE_STATICFIELD);
+                        BuildMethodTableThrowException(IDS_CLASSLOAD_BYREF_OR_BYREFLIKE_STATICFIELD);
                     }
                     if (!bmtFP->fIsByRefLikeType)
                     {
                         // Non-byref-like types cannot contain byref-like instance fields
-                        BuildMethodTableThrowException(IDS_CLASSLOAD_BYREFLIKE_INSTANCEFIELD);
+                        BuildMethodTableThrowException(IDS_CLASSLOAD_BYREF_OR_BYREFLIKE_INSTANCEFIELD);
                     }
                 }