| | | 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 ExportedType |
| | | 7 | | { |
| | | 8 | | internal readonly MetadataReader reader; |
| | | 9 | | |
| | | 10 | | // Workaround: JIT doesn't generate good code for nested structures, so use RowId. |
| | | 11 | | internal readonly int rowId; |
| | | 12 | | |
| | | 13 | | internal ExportedType(MetadataReader reader, int rowId) |
| | 0 | 14 | | { |
| | 0 | 15 | | this.reader = reader; |
| | 0 | 16 | | this.rowId = rowId; |
| | 0 | 17 | | } |
| | | 18 | | |
| | | 19 | | private ExportedTypeHandle Handle |
| | | 20 | | { |
| | 0 | 21 | | get { return ExportedTypeHandle.FromRowId(rowId); } |
| | | 22 | | } |
| | | 23 | | |
| | | 24 | | public TypeAttributes Attributes |
| | | 25 | | { |
| | 0 | 26 | | get { return reader.ExportedTypeTable.GetFlags(rowId); } |
| | | 27 | | } |
| | | 28 | | |
| | | 29 | | public bool IsForwarder |
| | | 30 | | { |
| | 0 | 31 | | get { return Attributes.IsForwarder() && Implementation.Kind == HandleKind.AssemblyReference; } |
| | | 32 | | } |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Name of the target type, or nil if the type is nested or defined in a root namespace. |
| | | 36 | | /// </summary> |
| | | 37 | | public StringHandle Name |
| | | 38 | | { |
| | 0 | 39 | | get { return reader.ExportedTypeTable.GetTypeName(rowId); } |
| | | 40 | | } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Full name of the namespace where the target type, or nil if the type is nested or defined in a root namespac |
| | | 44 | | /// </summary> |
| | | 45 | | public StringHandle Namespace |
| | | 46 | | { |
| | | 47 | | get |
| | 0 | 48 | | { |
| | 0 | 49 | | return reader.ExportedTypeTable.GetTypeNamespaceString(rowId); |
| | 0 | 50 | | } |
| | | 51 | | } |
| | | 52 | | |
| | | 53 | | /// <summary> |
| | | 54 | | /// The definition handle of the namespace where the target type is defined, or nil if the type is nested or def |
| | | 55 | | /// </summary> |
| | | 56 | | public NamespaceDefinitionHandle NamespaceDefinition |
| | | 57 | | { |
| | | 58 | | get |
| | 0 | 59 | | { |
| | | 60 | | // NOTE: NamespaceDefinitionHandle currently relies on never having virtual values. If this ever gets pr |
| | | 61 | | // to a virtual namespace name, then that assumption will need to be removed. |
| | 0 | 62 | | return reader.ExportedTypeTable.GetTypeNamespace(rowId); |
| | 0 | 63 | | } |
| | | 64 | | } |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Handle to resolve the implementation of the target type. |
| | | 68 | | /// </summary> |
| | | 69 | | /// <returns> |
| | | 70 | | /// <list type="bullet"> |
| | | 71 | | /// <item><description><see cref="AssemblyFileHandle"/> representing another module in the assembly.</descriptio |
| | | 72 | | /// <item><description><see cref="AssemblyReferenceHandle"/> representing another assembly if <see cref="IsForwa |
| | | 73 | | /// <item><description><see cref="ExportedTypeHandle"/> representing the declaring exported type in which this w |
| | | 74 | | /// </list> |
| | | 75 | | /// </returns> |
| | | 76 | | public EntityHandle Implementation |
| | | 77 | | { |
| | | 78 | | get |
| | 0 | 79 | | { |
| | 0 | 80 | | return reader.ExportedTypeTable.GetImplementation(rowId); |
| | 0 | 81 | | } |
| | | 82 | | } |
| | | 83 | | |
| | | 84 | | public CustomAttributeHandleCollection GetCustomAttributes() |
| | 0 | 85 | | { |
| | 0 | 86 | | return new CustomAttributeHandleCollection(reader, Handle); |
| | 0 | 87 | | } |
| | | 88 | | } |
| | | 89 | | } |
| | | 90 | | |