| | | 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 GenericParameterConstraint |
| | | 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 GenericParameterConstraint(MetadataReader reader, GenericParameterConstraintHandle handle) |
| | 0 | 14 | | { |
| | 0 | 15 | | _reader = reader; |
| | 0 | 16 | | _rowId = handle.RowId; |
| | 0 | 17 | | } |
| | | 18 | | |
| | | 19 | | private GenericParameterConstraintHandle Handle |
| | | 20 | | { |
| | 0 | 21 | | get { return GenericParameterConstraintHandle.FromRowId(_rowId); } |
| | | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// The constrained <see cref="GenericParameterHandle"/>. |
| | | 26 | | /// </summary> |
| | | 27 | | /// <remarks> |
| | | 28 | | /// Corresponds to Owner field of GenericParamConstraint table in ECMA-335 Standard. |
| | | 29 | | /// </remarks> |
| | | 30 | | public GenericParameterHandle Parameter |
| | | 31 | | { |
| | 0 | 32 | | get { return _reader.GenericParamConstraintTable.GetOwner(Handle); } |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Handle (<see cref="TypeDefinitionHandle"/>, <see cref="TypeReferenceHandle"/>, or <see cref="TypeSpecificati |
| | | 37 | | /// specifying from which type this generic parameter is constrained to derive, |
| | | 38 | | /// or which interface this generic parameter is constrained to implement. |
| | | 39 | | /// </summary> |
| | | 40 | | /// <remarks> |
| | | 41 | | /// Corresponds to Constraint field of GenericParamConstraint table in ECMA-335 Standard. |
| | | 42 | | /// </remarks> |
| | | 43 | | public EntityHandle Type |
| | | 44 | | { |
| | 0 | 45 | | get { return _reader.GenericParamConstraintTable.GetConstraint(Handle); } |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | public CustomAttributeHandleCollection GetCustomAttributes() |
| | 0 | 49 | | { |
| | 0 | 50 | | return new CustomAttributeHandleCollection(_reader, Handle); |
| | 0 | 51 | | } |
| | | 52 | | } |
| | | 53 | | } |
| | | 54 | | |