public unsafe void PeekReference() { var table = new byte[] { 0xff, 0xff, 0xff, 0x00, // offset 0 0xff, 0xff, 0xff, 0x01, // offset 4 0xff, 0xff, 0xff, 0x1f, // offset 8 0xff, 0xff, 0xff, 0x2f, // offset 12 0xff, 0xff, 0xff, 0xff, // offset 16 }; fixed(byte *tablePtr = table) { var block = new MemoryBlock(tablePtr, table.Length); Assert.Equal(0x0000ffff, block.PeekReference(0, smallRefSize: true)); Assert.Equal(0x0000ffff, block.PeekHeapReference(0, smallRefSize: true)); Assert.Equal(0x0000ffffu, block.PeekReferenceUnchecked(0, smallRefSize: true)); Assert.Equal(0x00ffffff, block.PeekReference(0, smallRefSize: false)); Assert.Throws <BadImageFormatException>(() => block.PeekReference(4, smallRefSize: false)); Assert.Throws <BadImageFormatException>(() => block.PeekReference(16, smallRefSize: false)); Assert.Equal(0x1fffffff, block.PeekHeapReference(8, smallRefSize: false)); Assert.Throws <BadImageFormatException>(() => block.PeekHeapReference(12, smallRefSize: false)); Assert.Throws <BadImageFormatException>(() => block.PeekHeapReference(16, smallRefSize: false)); Assert.Equal(0x01ffffffu, block.PeekReferenceUnchecked(4, smallRefSize: false)); Assert.Equal(0x1fffffffu, block.PeekReferenceUnchecked(8, smallRefSize: false)); Assert.Equal(0x2fffffffu, block.PeekReferenceUnchecked(12, smallRefSize: false)); Assert.Equal(0xffffffffu, block.PeekReferenceUnchecked(16, smallRefSize: false)); } }
internal GuidHandle GetKind(CustomDebugInformationHandle handle) { int rowOffset = (handle.RowId - 1) * RowSize; return(GuidHandle.FromIndex(Block.PeekHeapReference(rowOffset + _kindOffset, _isGuidHeapRefSizeSmall))); }
internal BlobHandle GetImports(ImportScopeHandle handle) { int rowOffset = (handle.RowId - 1) * RowSize; return(BlobHandle.FromOffset(Block.PeekHeapReference(rowOffset + _importsOffset, _isBlobHeapRefSizeSmall))); }
internal DocumentNameBlobHandle GetName(DocumentHandle handle) { int rowOffset = (handle.RowId - 1) * RowSize; return(DocumentNameBlobHandle.FromOffset(Block.PeekHeapReference(rowOffset + NameOffset, _isBlobHeapRefSizeSmall))); }
internal StringHandle GetName(LocalConstantHandle handle) { int rowOffset = (handle.RowId - 1) * RowSize; return(StringHandle.FromOffset(Block.PeekHeapReference(rowOffset + NameOffset, _isStringHeapRefSizeSmall))); }
internal BlobHandle GetSequencePoints(MethodDebugInformationHandle handle) { int rowOffset = (handle.RowId - 1) * RowSize; return(BlobHandle.FromOffset(Block.PeekHeapReference(rowOffset + _sequencePointsOffset, _isBlobHeapRefSizeSmall))); }