dotnet/runtime

[MetadataReader] document format and constrains of -Ptr tables

Open

#14,721 opened on Jun 15, 2015

View on GitHub
 (3 comments) (0 reactions) (0 assignees)C# (5,445 forks)batch import
area-System.Reflection.Metadataenhancementhelp wantedinvestigate

Repository metrics

Stars
 (17,886 stars)
PR merge metrics
 (Avg merge 12d 11h) (661 merged PRs in 30d)

Description

InitializeTableReaders method contains the following code:

// Compute ref sizes for tables that can have pointer tables
            int fieldRefSizeSorted = GetReferenceSize(rowCounts, TableIndex.FieldPtr) > SmallIndexSize ? LargeIndexSize : GetReferenceSize(rowCounts, TableIndex.Field);
            int methodRefSizeSorted = GetReferenceSize(rowCounts, TableIndex.MethodPtr) > SmallIndexSize ? LargeIndexSize : GetReferenceSize(rowCounts, TableIndex.MethodDef);
            int paramRefSizeSorted = GetReferenceSize(rowCounts, TableIndex.ParamPtr) > SmallIndexSize ? LargeIndexSize : GetReferenceSize(rowCounts, TableIndex.Param);
            int eventRefSizeSorted = GetReferenceSize(rowCounts, TableIndex.EventPtr) > SmallIndexSize ? LargeIndexSize : GetReferenceSize(rowCounts, TableIndex.Event);
            int propertyRefSizeSorted = GetReferenceSize(rowCounts, TableIndex.PropertyPtr) > SmallIndexSize ? LargeIndexSize : GetReferenceSize(rowCounts, TableIndex.Property);

It's not clear if any of these conditions are ever true. I'd think that the size of XxxPtr table is always the same as the corresponding Xxx table, since the Ptr table is used as an index. It might make sense that XxxPtr table is smaller than the Xxx table. But I don't see how it can have more rows.

Do we have tests that cover these?

Contributor guide