| | | 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.Reflection.Metadata.Ecma335; |
| | | 5 | | |
| | | 6 | | namespace System.Reflection.Metadata |
| | | 7 | | { |
| | | 8 | | public readonly struct TypeSpecification |
| | | 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 TypeSpecification(MetadataReader reader, TypeSpecificationHandle handle) |
| | 0 | 16 | | { |
| | 0 | 17 | | _reader = reader; |
| | 0 | 18 | | _rowId = handle.RowId; |
| | 0 | 19 | | } |
| | | 20 | | |
| | | 21 | | private TypeSpecificationHandle Handle |
| | | 22 | | { |
| | 0 | 23 | | get { return TypeSpecificationHandle.FromRowId(_rowId); } |
| | | 24 | | } |
| | | 25 | | |
| | | 26 | | public BlobHandle Signature |
| | | 27 | | { |
| | 0 | 28 | | get { return _reader.TypeSpecTable.GetSignature(Handle); } |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | public TType DecodeSignature<TType, TGenericContext>(ISignatureTypeProvider<TType, TGenericContext> provider, TG |
| | 0 | 32 | | { |
| | 0 | 33 | | var decoder = new SignatureDecoder<TType, TGenericContext>(provider, _reader, genericContext); |
| | 0 | 34 | | var blobReader = _reader.GetBlobReader(Signature); |
| | 0 | 35 | | return decoder.DecodeType(ref blobReader); |
| | 0 | 36 | | } |
| | | 37 | | |
| | | 38 | | public CustomAttributeHandleCollection GetCustomAttributes() |
| | 0 | 39 | | { |
| | 0 | 40 | | return new CustomAttributeHandleCollection(_reader, Handle); |
| | 0 | 41 | | } |
| | | 42 | | } |
| | | 43 | | } |
| | | 44 | | |