Example #1
0
        private ILeafContainer ReadType(out long dataSize)
        {
            ushort length = ReadUInt16();

            if (length == 0)
            {
                dataSize = sizeof(ushort);
                return(null);
            }
            dataSize  = sizeof(ushort) + length;
            Position -= sizeof(ushort);

#if false //$TODO
            {
                var leafDataBuf = ReadBytes((int)length + sizeof(ushort));

                UInt32 leafHash = HasherV2.HashBufferV8(leafDataBuf, 0xFFFFFFFF);
                UInt32 hash     = HasherV2.HashData(leafDataBuf, Header.Hash.NumHashBuckets);

                Position -= sizeof(ushort) + length;
            }
#endif

            //OnLeafData?.Invoke(leafDataBuf);

            var            typeSpan = Memory.Slice((int)Position, (int)dataSize);
            TypeDataReader rdr      = new TypeDataReader(ctx, new SpanStream(typeSpan));
            Position += dataSize;

            return(rdr.ReadTypeLazy());
        }
Example #2
0
        public LeafContainerBase ReadTypeDirect(bool hasSize = true)
        {
            long typeStartOffset = Position;

            UInt16 size = 0;

            if (hasSize)
            {
                size = ReadUInt16();
                if (size == 0)
                {
                    throw new InvalidDataException("Leaf size field cannot be 0");
                }
            }
            LeafType leafType = ReadEnum <LeafType>();

            ILeaf typeSym = CreateLeafStream(leafType);

            typeSym.Read();

            Position += (typeSym as LeafBase).Length;
            ConsumePadding();

            // for PDB 1.0: hash collides with padding, and is not properly encoded sometimes
            AlignStream(2);

#if !PEFF
            long   typeDataSize = size + sizeof(UInt16);
            UInt32 typeHash     = PerformAt(typeStartOffset, () => {
                byte[] typeData = ReadBytes((int)typeDataSize);
                return(HasherV2.HashBufferV8(typeData, 0xFFFFFFFF));
            });
#endif

            return(new DirectLeafProvider(0, leafType, typeSym));
        }