< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 25
Coverable lines: 25
Total lines: 79
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 10
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%
.ctor(...)0%220%
Equals(...)0%220%
Equals(...)0%440%
GetHashCode()100%110%
op_Equality(...)0%220%
op_Inequality(...)100%110%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Private.CoreLib/src/System/Globalization/SortVersion.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.CodeAnalysis;
 5using System.Runtime.CompilerServices;
 6
 7namespace System.Globalization
 8{
 9    [Serializable]
 10    [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
 11    public sealed class SortVersion : IEquatable<SortVersion?>
 12    {
 13        private readonly int m_NlsVersion; // Do not rename (binary serialization)
 14        private readonly Guid m_SortId; // Do not rename (binary serialization)
 15
 016        public int FullVersion => m_NlsVersion;
 17
 018        public Guid SortId => m_SortId;
 19
 020        public SortVersion(int fullVersion, Guid sortId)
 21        {
 022            m_SortId = sortId;
 023            m_NlsVersion = fullVersion;
 024        }
 25
 026        internal SortVersion(int nlsVersion, int effectiveId, Guid customVersion)
 27        {
 028            m_NlsVersion = nlsVersion;
 29
 030            if (customVersion == Guid.Empty)
 31            {
 032                byte b1 = (byte)(effectiveId >> 24);
 033                byte b2 = (byte)((effectiveId & 0x00FF0000) >> 16);
 034                byte b3 = (byte)((effectiveId & 0x0000FF00) >> 8);
 035                byte b4 = (byte)(effectiveId & 0xFF);
 036                customVersion = new Guid(0, 0, 0, 0, 0, 0, 0, b1, b2, b3, b4);
 37            }
 38
 039            m_SortId = customVersion;
 040        }
 41
 42        public override bool Equals([NotNullWhen(true)] object? obj)
 43        {
 044            return obj is SortVersion otherVersion && Equals(otherVersion);
 45        }
 46
 47        public bool Equals([NotNullWhen(true)] SortVersion? other)
 48        {
 049            if (other == null)
 50            {
 051                return false;
 52            }
 53
 054            return m_NlsVersion == other.m_NlsVersion && m_SortId == other.m_SortId;
 55        }
 56
 57        public override int GetHashCode()
 58        {
 059            return m_NlsVersion * 7 | m_SortId.GetHashCode();
 60        }
 61
 62        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 63        public static bool operator ==(SortVersion? left, SortVersion? right)
 64        {
 65            // Test "right" first to allow branch elimination when inlined for null checks (== null)
 66            // so it can become a simple test
 067            if (right is null)
 68            {
 069                return left is null;
 70            }
 71
 072            return right.Equals(left);
 73        }
 74
 75        public static bool operator !=(SortVersion? left, SortVersion? right) =>
 076            !(left == right);
 77    }
 78}
 79