Esempio n. 1
0
        // internal for testing
        internal static void ReadStandalonePortablePdbStream(MemoryBlock block, out DebugMetadataHeader debugMetadataHeader, out int[] externalTableRowCounts)
        {
            var reader = new BlobReader(block);

            const int PdbIdSize = 20;

            byte[] pdbId = reader.ReadBytes(PdbIdSize);

            // ECMA-335 15.4.1.2:
            // The entry point to an application shall be static.
            // This entry point method can be a global method or it can appear inside a type.
            // The entry point method shall either accept no arguments or a vector of strings.
            // The return type of the entry point method shall be void, int32, or unsigned int32.
            // The entry point method cannot be defined in a generic class.
            uint entryPointToken = reader.ReadUInt32();
            int  entryPointRowId = (int)(entryPointToken & TokenTypeIds.RIDMask);

            if (entryPointToken != 0 && ((entryPointToken & TokenTypeIds.TypeMask) != TokenTypeIds.MethodDef || entryPointRowId == 0))
            {
                throw new BadImageFormatException("InvalidEntryPointToken");
            }

            ulong externalTableMask = reader.ReadUInt64();

            // EnC & Ptr tables can't be referenced from standalone PDB metadata:
            const ulong validTables = (ulong)TableMask.ValidPortablePdbExternalTables;

            if ((externalTableMask & ~validTables) != 0)
            {
                throw new BadImageFormatException("UnknownTables");
            }

            externalTableRowCounts = ReadMetadataTableRowCounts(ref reader, externalTableMask);

            debugMetadataHeader = new DebugMetadataHeader(
                new ImmutableArray <byte>(pdbId),
                MethodDefinitionHandle.FromRowId(entryPointRowId));
        }
Esempio n. 2
0
 /// <summary>
 /// Returns a handle to <see cref="MethodDefinition"/> corresponding to this handle.
 /// </summary>
 /// <remarks>
 /// The resulting handle is only valid within the context of a <see cref="MetadataReader"/> open on the type system metadata blob,
 /// which in case of standalone PDB file is a different reader than the one containing this method debug information.
 /// </remarks>
 public MethodDefinitionHandle ToDefinitionHandle()
 {
     return(MethodDefinitionHandle.FromRowId(_rowId));
 }