< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 20
Coverable lines: 20
Total lines: 90
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
GetCustomAttributes()100%110%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/ExportedType.cs

#LineLine coverage
 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
 4namespace 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)
 014        {
 015            this.reader = reader;
 016            this.rowId = rowId;
 017        }
 18
 19        private ExportedTypeHandle Handle
 20        {
 021            get { return ExportedTypeHandle.FromRowId(rowId); }
 22        }
 23
 24        public TypeAttributes Attributes
 25        {
 026            get { return reader.ExportedTypeTable.GetFlags(rowId); }
 27        }
 28
 29        public bool IsForwarder
 30        {
 031            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        {
 039            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
 048            {
 049                return reader.ExportedTypeTable.GetTypeNamespaceString(rowId);
 050            }
 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
 059            {
 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.
 062                return reader.ExportedTypeTable.GetTypeNamespace(rowId);
 063            }
 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
 079            {
 080                return reader.ExportedTypeTable.GetImplementation(rowId);
 081            }
 82        }
 83
 84        public CustomAttributeHandleCollection GetCustomAttributes()
 085        {
 086            return new CustomAttributeHandleCollection(reader, Handle);
 087        }
 88    }
 89}
 90