< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 17
Coverable lines: 17
Total lines: 49
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
ConvertToHandle(...)0%220%
ConvertToTag(...)0%440%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Internal/HasFieldMarshalTag.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.Runtime.CompilerServices;
 5
 6namespace System.Reflection.Metadata.Ecma335
 7{
 8    internal static class HasFieldMarshalTag
 9    {
 10        internal const int NumberOfBits = 1;
 11        internal const int LargeRowSize = 0x00000001 << (16 - NumberOfBits);
 12        internal const uint Field = 0x00000000;
 13        internal const uint Param = 0x00000001;
 14        internal const uint TagMask = 0x00000001;
 15        internal const TableMask TablesReferenced =
 16          TableMask.Field
 17          | TableMask.Param;
 18        internal const uint TagToTokenTypeByteVector = TokenTypeIds.FieldDef >> 24 | TokenTypeIds.ParamDef >> 16;
 19
 20        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 21        internal static EntityHandle ConvertToHandle(uint hasFieldMarshal)
 022        {
 023            uint tokenType = (TagToTokenTypeByteVector >> ((int)(hasFieldMarshal & TagMask) << 3)) << TokenTypeIds.RowId
 024            uint rowId = (hasFieldMarshal >> NumberOfBits);
 25
 026            if ((rowId & ~TokenTypeIds.RIDMask) != 0)
 027            {
 028                Throw.InvalidCodedIndex();
 29            }
 30
 031            return new EntityHandle(tokenType | rowId);
 032        }
 33
 34        internal static uint ConvertToTag(EntityHandle handle)
 035        {
 036            if (handle.Type == TokenTypeIds.FieldDef)
 037            {
 038                return (uint)handle.RowId << NumberOfBits | Field;
 39            }
 040            else if (handle.Type == TokenTypeIds.ParamDef)
 041            {
 042                return (uint)handle.RowId << NumberOfBits | Param;
 43            }
 44
 045            return 0;
 046        }
 47    }
 48}
 49