| | | 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 | | /// Source document in debug metadata. |
| | | 8 | | /// </summary> |
| | | 9 | | /// <remarks> |
| | | 10 | | /// See also https://github.com/dotnet/runtime/blob/main/src/libraries/System.Reflection.Metadata/specs/PortablePdb- |
| | | 11 | | /// </remarks> |
| | | 12 | | public readonly struct Document |
| | | 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 Document(MetadataReader reader, DocumentHandle handle) |
| | 0 | 20 | | { |
| | 0 | 21 | | _reader = reader; |
| | 0 | 22 | | _rowId = handle.RowId; |
| | 0 | 23 | | } |
| | | 24 | | |
| | 0 | 25 | | private DocumentHandle Handle => DocumentHandle.FromRowId(_rowId); |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Returns Document Name Blob. |
| | | 29 | | /// </summary> |
| | 0 | 30 | | public DocumentNameBlobHandle Name => _reader.DocumentTable.GetName(Handle); |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Source code language (C#, VB, F#, etc.) |
| | | 34 | | /// </summary> |
| | 0 | 35 | | public GuidHandle Language => _reader.DocumentTable.GetLanguage(Handle); |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Hash algorithm used to calculate <see cref="Hash"/> (SHA1, SHA256, etc.) |
| | | 39 | | /// </summary> |
| | 0 | 40 | | public GuidHandle HashAlgorithm => _reader.DocumentTable.GetHashAlgorithm(Handle); |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Document content hash. |
| | | 44 | | /// </summary> |
| | | 45 | | /// <remarks> |
| | | 46 | | /// <see cref="HashAlgorithm"/> determines the algorithm used to produce this hash. |
| | | 47 | | /// The source document is hashed in its binary form as stored in the file. |
| | | 48 | | /// </remarks> |
| | 0 | 49 | | public BlobHandle Hash => _reader.DocumentTable.GetHash(Handle); |
| | | 50 | | } |
| | | 51 | | } |
| | | 52 | | |