< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 29
Coverable lines: 29
Total lines: 72
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
DecodeMethodSignature(...)100%110%
DecodeLocalSignature(...)100%110%
GetCustomAttributes()100%110%
GetKind()0%440%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/StandaloneSignature.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
 4using System.Collections.Immutable;
 5using System.Reflection.Metadata.Ecma335;
 6
 7namespace System.Reflection.Metadata
 8{
 9    public readonly struct StandaloneSignature
 10    {
 11        private readonly MetadataReader _reader;
 12
 13        // Workaround: JIT doesn't generate good code for nested structures, so use RowId.
 14        private readonly int _rowId;
 15
 16        internal StandaloneSignature(MetadataReader reader, StandaloneSignatureHandle handle)
 017        {
 018            _reader = reader;
 019            _rowId = handle.RowId;
 020        }
 21
 22        private StandaloneSignatureHandle Handle
 23        {
 024            get { return StandaloneSignatureHandle.FromRowId(_rowId); }
 25        }
 26
 27        /// <summary>
 28        /// Gets a handle to the signature blob.
 29        /// </summary>
 30        public BlobHandle Signature
 31        {
 032            get { return _reader.StandAloneSigTable.GetSignature(_rowId); }
 33        }
 34
 35        public MethodSignature<TType> DecodeMethodSignature<TType, TGenericContext>(ISignatureTypeProvider<TType, TGener
 036        {
 037            var decoder = new SignatureDecoder<TType, TGenericContext>(provider, _reader, genericContext);
 038            var blobReader = _reader.GetBlobReader(Signature);
 039            return decoder.DecodeMethodSignature(ref blobReader);
 040        }
 41
 42        public ImmutableArray<TType> DecodeLocalSignature<TType, TGenericContext>(ISignatureTypeProvider<TType, TGeneric
 043        {
 044            var decoder = new SignatureDecoder<TType, TGenericContext>(provider, _reader, genericContext);
 045            var blobReader = _reader.GetBlobReader(Signature);
 046            return decoder.DecodeLocalSignature(ref blobReader);
 047        }
 48
 49        public CustomAttributeHandleCollection GetCustomAttributes()
 050        {
 051            return new CustomAttributeHandleCollection(_reader, Handle);
 052        }
 53
 54        /// <summary>
 55        /// Determines the kind of signature, which can be <see cref="SignatureKind.Method"/> or <see cref="SignatureKin
 56        /// </summary>
 57        /// <exception cref="BadImageFormatException">The signature is invalid.</exception>
 58        public StandaloneSignatureKind GetKind()
 059        {
 060            BlobReader blobReader = _reader.GetBlobReader(this.Signature);
 061            SignatureHeader header = blobReader.ReadSignatureHeader();
 62
 063            return header.Kind switch
 064            {
 065                SignatureKind.Method => StandaloneSignatureKind.Method,
 066                SignatureKind.LocalVariables => StandaloneSignatureKind.LocalVariables,
 067                _ => throw new BadImageFormatException(),
 068            };
 069        }
 70    }
 71}
 72