< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 32
Coverable lines: 32
Total lines: 83
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%
FromOffset(...)100%110%
op_Implicit(...)100%110%
op_Explicit(...)0%220%
Equals(...)0%220%
Equals(...)100%110%
GetHashCode()100%110%
op_Equality(...)100%110%
op_Inequality(...)100%110%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.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.Diagnostics;
 5using System.Diagnostics.CodeAnalysis;
 6using System.Reflection.Internal;
 7using System.Reflection.Metadata.Ecma335;
 8
 9namespace System.Reflection.Metadata
 10{
 11    /// <summary>
 12    /// <see cref="BlobHandle"/> representing a blob on #Blob heap in Portable PDB
 13    /// structured as Document Name.
 14    /// </summary>
 15    /// <remarks>
 16    /// The kind of the handle is <see cref="HandleKind.Blob"/>.
 17    /// The handle is a specialization of <see cref="BlobHandle"/> and doesn't have a distinct kind.
 18    /// </remarks>
 19    public readonly struct DocumentNameBlobHandle : IEquatable<DocumentNameBlobHandle>
 20    {
 21        // bits:
 22        // 29..31: 0
 23        //  0..28: #Blob heap offset
 24        private readonly int _heapOffset;
 25
 26        private DocumentNameBlobHandle(int heapOffset)
 027        {
 028            Debug.Assert(HeapHandleType.IsValidHeapOffset((uint)heapOffset));
 029            _heapOffset = heapOffset;
 030        }
 31
 32        internal static DocumentNameBlobHandle FromOffset(int heapOffset)
 033        {
 034            return new DocumentNameBlobHandle(heapOffset);
 035        }
 36
 37        public static implicit operator BlobHandle(DocumentNameBlobHandle handle)
 038        {
 039            return BlobHandle.FromOffset(handle._heapOffset);
 040        }
 41
 42        public static explicit operator DocumentNameBlobHandle(BlobHandle handle)
 043        {
 044            if (handle.IsVirtual)
 045            {
 046                Throw.InvalidCast();
 47            }
 48
 049            return FromOffset(handle.GetHeapOffset());
 050        }
 51
 52        public bool IsNil
 53        {
 054            get { return _heapOffset == 0; }
 55        }
 56
 57        public override bool Equals([NotNullWhen(true)] object? obj)
 058        {
 059            return obj is DocumentNameBlobHandle documentHandle && Equals(documentHandle);
 060        }
 61
 62        public bool Equals(DocumentNameBlobHandle other)
 063        {
 064            return _heapOffset == other._heapOffset;
 065        }
 66
 67        public override int GetHashCode()
 068        {
 069            return _heapOffset;
 070        }
 71
 72        public static bool operator ==(DocumentNameBlobHandle left, DocumentNameBlobHandle right)
 073        {
 074            return left.Equals(right);
 075        }
 76
 77        public static bool operator !=(DocumentNameBlobHandle left, DocumentNameBlobHandle right)
 078        {
 079            return !left.Equals(right);
 080        }
 81    }
 82}
 83