From 08a6e06d8fdc29efebc5c0ec7d2b6ba215810e71 Mon Sep 17 00:00:00 2001 From: mikelle-rogers <45022607+mikelle-rogers@users.noreply.github.com> Date: Fri, 21 Jul 2023 14:39:12 -0700 Subject: [PATCH] Fix TestGenericAddStaticField (#89145) * Fix TestGenericAddStaticField * use the correct Method Table to gather fields --- src/coreclr/vm/memberload.cpp | 15 +++------------ .../System.Runtime.Loader/tests/ApplyUpdateTest.cs | 1 - 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/coreclr/vm/memberload.cpp b/src/coreclr/vm/memberload.cpp index 1cb98fd..7192bd3 100644 --- a/src/coreclr/vm/memberload.cpp +++ b/src/coreclr/vm/memberload.cpp @@ -365,18 +365,9 @@ void MemberLoader::GetDescFromMemberRef(ModuleBase * pModule, if (pFD->IsStatic() && pMT->HasGenericsStaticsInfo()) { - // - // this is duplicated logic GetFieldDescByIndex - // - INDEBUG(mdFieldDef token = pFD->GetMemberDef();) - - DWORD pos = static_cast(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; diff --git a/src/libraries/System.Runtime.Loader/tests/ApplyUpdateTest.cs b/src/libraries/System.Runtime.Loader/tests/ApplyUpdateTest.cs index 799381f..05b3736 100644 --- a/src/libraries/System.Runtime.Loader/tests/ApplyUpdateTest.cs +++ b/src/libraries/System.Runtime.Loader/tests/ApplyUpdateTest.cs @@ -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() { -- 2.7.4