| | | 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 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) |
| | 0 | 14 | | { |
| | 0 | 15 | | _reader = reader; |
| | 0 | 16 | | _rowId = handle.RowId; |
| | 0 | 17 | | } |
| | | 18 | | |
| | | 19 | | private GenericParameterHandle Handle |
| | | 20 | | { |
| | 0 | 21 | | 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 |
| | 0 | 33 | | { |
| | 0 | 34 | | return _reader.GenericParamTable.GetOwner(Handle); |
| | 0 | 35 | | } |
| | | 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 |
| | 0 | 47 | | { |
| | 0 | 48 | | return _reader.GenericParamTable.GetFlags(Handle); |
| | 0 | 49 | | } |
| | | 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 |
| | 0 | 61 | | { |
| | 0 | 62 | | return _reader.GenericParamTable.GetNumber(Handle); |
| | 0 | 63 | | } |
| | | 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 |
| | 0 | 75 | | { |
| | 0 | 76 | | return _reader.GenericParamTable.GetName(Handle); |
| | 0 | 77 | | } |
| | | 78 | | } |
| | | 79 | | |
| | | 80 | | public GenericParameterConstraintHandleCollection GetConstraints() |
| | 0 | 81 | | { |
| | 0 | 82 | | return _reader.GenericParamConstraintTable.FindConstraintsForGenericParam(Handle); |
| | 0 | 83 | | } |
| | | 84 | | |
| | | 85 | | public CustomAttributeHandleCollection GetCustomAttributes() |
| | 0 | 86 | | { |
| | 0 | 87 | | return new CustomAttributeHandleCollection(_reader, Handle); |
| | 0 | 88 | | } |
| | | 89 | | } |
| | | 90 | | } |
| | | 91 | | |