| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | namespace System.Reflection.Metadata |
| | | 5 | | { |
| | | 6 | | /// <summary> |
| | | 7 | | /// Lexical scope within which a group of imports are available. Stored in debug metadata. |
| | | 8 | | /// </summary> |
| | | 9 | | /// <remarks> |
| | | 10 | | /// See https://github.com/dotnet/runtime/blob/main/src/libraries/System.Reflection.Metadata/specs/PortablePdb-Metad |
| | | 11 | | /// </remarks> |
| | | 12 | | public readonly struct ImportScope |
| | | 13 | | { |
| | | 14 | | private readonly MetadataReader _reader; |
| | | 15 | | |
| | | 16 | | // Workaround: JIT doesn't generate good code for nested structures, so use RowId. |
| | | 17 | | private readonly int _rowId; |
| | | 18 | | |
| | | 19 | | internal ImportScope(MetadataReader reader, ImportScopeHandle handle) |
| | 0 | 20 | | { |
| | 0 | 21 | | _reader = reader; |
| | 0 | 22 | | _rowId = handle.RowId; |
| | 0 | 23 | | } |
| | | 24 | | |
| | 0 | 25 | | private ImportScopeHandle Handle => ImportScopeHandle.FromRowId(_rowId); |
| | | 26 | | |
| | 0 | 27 | | public ImportScopeHandle Parent => _reader.ImportScopeTable.GetParent(Handle); |
| | 0 | 28 | | public BlobHandle ImportsBlob => _reader.ImportScopeTable.GetImports(Handle); |
| | | 29 | | |
| | | 30 | | public ImportDefinitionCollection GetImports() |
| | 0 | 31 | | { |
| | 0 | 32 | | return new ImportDefinitionCollection(_reader.BlobHeap.GetMemoryBlock(ImportsBlob)); |
| | 0 | 33 | | } |
| | | 34 | | } |
| | | 35 | | } |
| | | 36 | | |