diff --git a/src/coreclr/md/enc/metamodelrw.cpp b/src/coreclr/md/enc/metamodelrw.cpp index c033ae063c5727..6d9f52fd4b7b67 100644 --- a/src/coreclr/md/enc/metamodelrw.cpp +++ b/src/coreclr/md/enc/metamodelrw.cpp @@ -4903,6 +4903,14 @@ CMiniMdRW::AddPropertyToPropertyMap( IfFailGo(AddChildRowIndirectForParent(TBL_PropertyMap, PropertyMapRec::COL_PropertyList, TBL_PropertyPtr, pmd, &pPtr)); hr = PutCol(TBL_PropertyPtr, PropertyPtrRec::COL_Property, pPtr, pd); + + // Add the to the property parent lookup table. + // This mirrors what AddMethodToTypeDef/AddFieldToTypeDef do for their + // respective lookup tables, and what emit.cpp:DefineProperty does. + PropertyMapRec *pPropertyMapRec; + IfFailGo(GetPropertyMapRecord(pmd, &pPropertyMapRec)); + IfFailGo(AddPropertyToLookUpTable(TokenFromRid(pd, mdtProperty), + getParentOfPropertyMap(pPropertyMapRec))); } @@ -4930,6 +4938,14 @@ CMiniMdRW::AddEventToEventMap( IfFailGo(AddChildRowIndirectForParent(TBL_EventMap, EventMapRec::COL_EventList, TBL_EventPtr, emd, &pPtr)); hr = PutCol(TBL_EventPtr, EventPtrRec::COL_Event, pPtr, ed); + + // Add the to the event parent lookup table. + // This mirrors what AddMethodToTypeDef/AddFieldToTypeDef do for their + // respective lookup tables. + EventMapRec *pEventMapRec; + IfFailGo(GetEventMapRecord(emd, &pEventMapRec)); + IfFailGo(AddEventToLookUpTable(TokenFromRid(ed, mdtEvent), + getParentOfEventMap(pEventMapRec))); } ErrExit: return hr;