| | | 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 | | public readonly struct AssemblyFile |
| | | 7 | | { |
| | | 8 | | private readonly MetadataReader _reader; |
| | | 9 | | |
| | | 10 | | // Workaround: JIT doesn't generate good code for nested structures, so use RowId. |
| | | 11 | | private readonly int _rowId; |
| | | 12 | | |
| | | 13 | | internal AssemblyFile(MetadataReader reader, AssemblyFileHandle handle) |
| | 0 | 14 | | { |
| | 0 | 15 | | _reader = reader; |
| | 0 | 16 | | _rowId = handle.RowId; |
| | 0 | 17 | | } |
| | | 18 | | |
| | | 19 | | private AssemblyFileHandle Handle |
| | | 20 | | { |
| | 0 | 21 | | get { return AssemblyFileHandle.FromRowId(_rowId); } |
| | | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// True if the file contains metadata. |
| | | 26 | | /// </summary> |
| | | 27 | | /// <remarks> |
| | | 28 | | /// Corresponds to Flags field of File table in ECMA-335 Standard. |
| | | 29 | | /// </remarks> |
| | | 30 | | public bool ContainsMetadata |
| | | 31 | | { |
| | 0 | 32 | | get { return _reader.FileTable.GetFlags(Handle) == 0; } |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// File name with extension. |
| | | 37 | | /// </summary> |
| | | 38 | | /// <remarks> |
| | | 39 | | /// Corresponds to Name field of File table in ECMA-335 Standard. |
| | | 40 | | /// </remarks> |
| | | 41 | | public StringHandle Name |
| | | 42 | | { |
| | 0 | 43 | | get { return _reader.FileTable.GetName(Handle); } |
| | | 44 | | } |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// Hash value of the file content calculated using <see cref="AssemblyDefinition.HashAlgorithm"/>. |
| | | 48 | | /// </summary> |
| | | 49 | | /// <remarks> |
| | | 50 | | /// Corresponds to HashValue field of File table in ECMA-335 Standard. |
| | | 51 | | /// </remarks> |
| | | 52 | | public BlobHandle HashValue |
| | | 53 | | { |
| | 0 | 54 | | get { return _reader.FileTable.GetHashValue(Handle); } |
| | | 55 | | } |
| | | 56 | | |
| | | 57 | | public CustomAttributeHandleCollection GetCustomAttributes() |
| | 0 | 58 | | { |
| | 0 | 59 | | return new CustomAttributeHandleCollection(_reader, Handle); |
| | 0 | 60 | | } |
| | | 61 | | } |
| | | 62 | | } |
| | | 63 | | |