IReadOnlyList <T> LoadDirectChildrenFromMap <T>( MetadataTable mapTable, MetadataTable childTable, UnsafeSelector <OneBasedIndex> parentSelector, GetTokenDelegate tokenSelector, CreateObjectDelegate <T> factory ) where T : class { //It is valid for the map table to not be sorted. However, I don't expect this to happen in //practice, so for now we throw an exception in that case. If we do end up needing to support //assemblies with unsorted meta-data tables then we will need to add some sort of fallback //here. mapTable.IsSorted(Module.PEFile).Assume("The table is not sorted"); var mapIndex = mapTable.Find( (OneBasedIndex)MetadataTable.TypeDef.RowIndex(m_pRow, Module.PEFile), parentSelector, Module.PEFile ); IReadOnlyList <T> ret; if (mapIndex < 0) { ret = new List <T>(0).AsReadOnly(); } else { ret = Module.PEFile.LoadDirectChildren( childTable, tokenSelector, factory, mapTable, mapTable.GetRow(mapIndex, Module.PEFile) ); } return(ret); }