| | | 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 | | using System.Collections.Immutable; |
| | | 5 | | |
| | | 6 | | namespace System.Reflection.Metadata |
| | | 7 | | { |
| | | 8 | | public readonly struct MethodSpecification |
| | | 9 | | { |
| | | 10 | | private readonly MetadataReader _reader; |
| | | 11 | | |
| | | 12 | | // Workaround: JIT doesn't generate good code for nested structures, so use RowId. |
| | | 13 | | private readonly int _rowId; |
| | | 14 | | |
| | | 15 | | internal MethodSpecification(MetadataReader reader, MethodSpecificationHandle handle) |
| | 0 | 16 | | { |
| | 0 | 17 | | _reader = reader; |
| | 0 | 18 | | _rowId = handle.RowId; |
| | 0 | 19 | | } |
| | | 20 | | |
| | | 21 | | private MethodSpecificationHandle Handle |
| | | 22 | | { |
| | 0 | 23 | | get { return MethodSpecificationHandle.FromRowId(_rowId); } |
| | | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// MethodDef or MemberRef handle specifying to which generic method this <see cref="MethodSpecification"/> refe |
| | | 28 | | /// that is which generic method is it an instantiation of. |
| | | 29 | | /// </summary> |
| | | 30 | | public EntityHandle Method |
| | | 31 | | { |
| | | 32 | | get |
| | 0 | 33 | | { |
| | 0 | 34 | | return _reader.MethodSpecTable.GetMethod(Handle); |
| | 0 | 35 | | } |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Gets a handle to the signature blob. |
| | | 40 | | /// </summary> |
| | | 41 | | public BlobHandle Signature |
| | | 42 | | { |
| | | 43 | | get |
| | 0 | 44 | | { |
| | 0 | 45 | | return _reader.MethodSpecTable.GetInstantiation(Handle); |
| | 0 | 46 | | } |
| | | 47 | | } |
| | | 48 | | |
| | | 49 | | public ImmutableArray<TType> DecodeSignature<TType, TGenericContext>(ISignatureTypeProvider<TType, TGenericConte |
| | 0 | 50 | | { |
| | 0 | 51 | | var decoder = new Ecma335.SignatureDecoder<TType, TGenericContext>(provider, _reader, genericContext); |
| | 0 | 52 | | var blobReader = _reader.GetBlobReader(Signature); |
| | 0 | 53 | | return decoder.DecodeMethodSpecificationSignature(ref blobReader); |
| | 0 | 54 | | } |
| | | 55 | | |
| | | 56 | | public CustomAttributeHandleCollection GetCustomAttributes() |
| | 0 | 57 | | { |
| | 0 | 58 | | return new CustomAttributeHandleCollection(_reader, Handle); |
| | 0 | 59 | | } |
| | | 60 | | } |
| | | 61 | | } |
| | | 62 | | |