< Summary

Information
Class: Chronicler.ChronicleHash
Assembly: Chronicler
File(s): /home/runner/work/Chronicler/Chronicler/src/Chronicler/Recording/ChronicleHash.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 79
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Equals(...)100%22100%
Equals(...)100%22100%
GetHashCode()100%11100%
ToString()100%11100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%

File(s)

/home/runner/work/Chronicler/Chronicler/src/Chronicler/Recording/ChronicleHash.cs

#LineLine coverage
 1using System;
 2using System.Globalization;
 3
 4namespace Chronicler;
 5
 6/// <summary>
 7/// Fixed-width deterministic hash value produced by a Chronicler record-hash pass.
 8/// </summary>
 9public readonly struct ChronicleHash : IEquatable<ChronicleHash>
 10{
 11    /// <summary>
 12    /// Creates a new hash value from its two 64-bit lanes.
 13    /// </summary>
 14    public ChronicleHash(ulong low, ulong high)
 15    {
 11066616        Low = low;
 11066617        High = high;
 11066618    }
 19
 20    /// <summary>
 21    /// Gets the low 64-bit lane.
 22    /// </summary>
 23    public ulong Low { get; }
 24
 25    /// <summary>
 26    /// Gets the high 64-bit lane.
 27    /// </summary>
 28    public ulong High { get; }
 29
 30    /// <inheritdoc />
 31    public bool Equals(ChronicleHash other)
 32    {
 4733        return Low == other.Low && High == other.High;
 34    }
 35
 36    /// <inheritdoc />
 37    public override bool Equals(object? obj)
 38    {
 2739        return obj is ChronicleHash other && Equals(other);
 40    }
 41
 42    /// <inheritdoc />
 43    public override int GetHashCode()
 44    {
 45        unchecked
 46        {
 247            ulong mixed = Low ^ (High * 0x9e3779b97f4a7c15UL);
 248            mixed ^= mixed >> 33;
 249            mixed *= 0xff51afd7ed558ccdUL;
 250            mixed ^= mixed >> 33;
 251            return (int)(mixed ^ (mixed >> 32));
 52        }
 53    }
 54
 55    /// <summary>
 56    /// Returns a lowercase 32-character hexadecimal hash string as high lane followed by low lane.
 57    /// </summary>
 58    public override string ToString()
 59    {
 460        return High.ToString("x16", CultureInfo.InvariantCulture)
 461            + Low.ToString("x16", CultureInfo.InvariantCulture);
 62    }
 63
 64    /// <summary>
 65    /// Compares two hash values for equality.
 66    /// </summary>
 67    public static bool operator ==(ChronicleHash left, ChronicleHash right)
 68    {
 169        return left.Equals(right);
 70    }
 71
 72    /// <summary>
 73    /// Compares two hash values for inequality.
 74    /// </summary>
 75    public static bool operator !=(ChronicleHash left, ChronicleHash right)
 76    {
 2077        return !left.Equals(right);
 78    }
 79}