< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 23
Coverable lines: 23
Total lines: 91
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

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

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/GenericParameter.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 GenericParameter
 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 GenericParameter(MetadataReader reader, GenericParameterHandle handle)
 014        {
 015            _reader = reader;
 016            _rowId = handle.RowId;
 017        }
 18
 19        private GenericParameterHandle Handle
 20        {
 021            get { return GenericParameterHandle.FromRowId(_rowId); }
 22        }
 23
 24        /// <summary>
 25        /// <see cref="TypeDefinitionHandle"/> or <see cref="MethodDefinitionHandle"/>.
 26        /// </summary>
 27        /// <remarks>
 28        /// Corresponds to Owner field of GenericParam table in ECMA-335 Standard.
 29        /// </remarks>
 30        public EntityHandle Parent
 31        {
 32            get
 033            {
 034                return _reader.GenericParamTable.GetOwner(Handle);
 035            }
 36        }
 37
 38        /// <summary>
 39        /// Attributes specifying variance and constraints.
 40        /// </summary>
 41        /// <remarks>
 42        /// Corresponds to Flags field of GenericParam table in ECMA-335 Standard.
 43        /// </remarks>
 44        public GenericParameterAttributes Attributes
 45        {
 46            get
 047            {
 048                return _reader.GenericParamTable.GetFlags(Handle);
 049            }
 50        }
 51
 52        /// <summary>
 53        /// Zero-based index of the parameter within the declaring generic type or method declaration.
 54        /// </summary>
 55        /// <remarks>
 56        /// Corresponds to Number field of GenericParam table in ECMA-335 Standard.
 57        /// </remarks>
 58        public int Index
 59        {
 60            get
 061            {
 062                return _reader.GenericParamTable.GetNumber(Handle);
 063            }
 64        }
 65
 66        /// <summary>
 67        /// The name of the generic parameter.
 68        /// </summary>
 69        /// <remarks>
 70        /// Corresponds to Name field of GenericParam table in ECMA-335 Standard.
 71        /// </remarks>
 72        public StringHandle Name
 73        {
 74            get
 075            {
 076                return _reader.GenericParamTable.GetName(Handle);
 077            }
 78        }
 79
 80        public GenericParameterConstraintHandleCollection GetConstraints()
 081        {
 082            return _reader.GenericParamConstraintTable.FindConstraintsForGenericParam(Handle);
 083        }
 84
 85        public CustomAttributeHandleCollection GetCustomAttributes()
 086        {
 087            return new CustomAttributeHandleCollection(_reader, Handle);
 088        }
 89    }
 90}
 91