Fix TestGenericAddStaticField (#89145)
authormikelle-rogers <45022607+mikelle-rogers@users.noreply.github.com>
Fri, 21 Jul 2023 21:39:12 +0000 (14:39 -0700)
committerGitHub <noreply@github.com>
Fri, 21 Jul 2023 21:39:12 +0000 (14:39 -0700)
* Fix TestGenericAddStaticField

* use the correct Method Table to gather fields

src/coreclr/vm/memberload.cpp
src/libraries/System.Runtime.Loader/tests/ApplyUpdateTest.cs

index 1cb98fd..7192bd3 100644 (file)
@@ -365,18 +365,9 @@ void MemberLoader::GetDescFromMemberRef(ModuleBase * pModule,
 
         if (pFD->IsStatic() && pMT->HasGenericsStaticsInfo())
         {
-            //
-            // <NICE> this is duplicated logic GetFieldDescByIndex </NICE>
-            //
-            INDEBUG(mdFieldDef token = pFD->GetMemberDef();)
-
-            DWORD pos = static_cast<DWORD>(pFD - (pMT->GetApproxFieldDescListRaw() + pMT->GetNumIntroducedInstanceFields()));
-            _ASSERTE(pos >= 0 && pos < pMT->GetNumStaticFields());
-
-            pFD = pMT->GetGenericsStaticFieldDescs() + pos;
-            _ASSERTE(pFD->GetMemberDef() == token);
-            _ASSERTE(!pFD->IsSharedByGenericInstantiations());
-            _ASSERTE(pFD->GetEnclosingMethodTable() == pMT);
+           MethodTable* pFieldMT = pFD->GetApproxEnclosingMethodTable();
+           DWORD index = pFieldMT->GetIndexForFieldDesc(pFD);
+           pFD = pMT->GetFieldDescByIndex(index);
         }
 
         *ppFD = pFD;
index 799381f..05b3736 100644 (file)
@@ -837,7 +837,6 @@ namespace System.Reflection.Metadata
             });
         }
 
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/87574", TestRuntimes.CoreCLR)]
         [ConditionalFact(typeof(ApplyUpdateUtil), nameof(ApplyUpdateUtil.IsSupported))]
         public static void TestGenericAddStaticField()
         {