< Summary

Information
Class: GridForge.Grids.GridChangeStamp
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Grids/Support/GridChangeStamp.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 65
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_IsValid()100%22100%
.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/GridForge/GridForge/src/GridForge/Grids/Support/GridChangeStamp.cs

#LineLine coverage
 1//=======================================================================
 2// GridChangeStamp.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024–present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System;
 9using System.Runtime.CompilerServices;
 10using SwiftCollections.Utility;
 11
 12namespace GridForge.Grids;
 13
 14/// <summary>
 15/// Identifies the committed order and logical cause of a GridForge world mutation.
 16/// </summary>
 17public readonly struct GridChangeStamp : IEquatable<GridChangeStamp>
 18{
 19    /// <summary>
 20    /// The world-local commit order. Zero is reserved for an invalid or default value.
 21    /// </summary>
 22    public readonly ulong Sequence;
 23
 24    /// <summary>
 25    /// The world-local logical cause shared by notifications emitted for one mutation.
 26    /// </summary>
 27    public readonly ulong CauseId;
 28
 29    /// <summary>
 30    /// Whether this value identifies a committed world mutation.
 31    /// </summary>
 32    public bool IsValid
 33    {
 34        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 435        get => Sequence != 0 && CauseId != 0;
 36    }
 37
 38    /// <summary>
 39    /// Initializes a change stamp.
 40    /// </summary>
 41    public GridChangeStamp(ulong sequence, ulong causeId)
 42    {
 349943        Sequence = sequence;
 349944        CauseId = causeId;
 349945    }
 46
 47    /// <inheritdoc />
 48    public bool Equals(GridChangeStamp other) =>
 649        Sequence == other.Sequence && CauseId == other.CauseId;
 50
 51    /// <inheritdoc />
 352    public override bool Equals(object? obj) => obj is GridChangeStamp other && Equals(other);
 53
 54    /// <inheritdoc />
 455    public override int GetHashCode() => SwiftHashTools.CombineHashCodes(Sequence, CauseId);
 56
 57    /// <inheritdoc />
 158    public override string ToString() => $"{Sequence}:{CauseId}";
 59
 60    /// <inheritdoc />
 161    public static bool operator ==(GridChangeStamp left, GridChangeStamp right) => left.Equals(right);
 62
 63    /// <inheritdoc />
 164    public static bool operator !=(GridChangeStamp left, GridChangeStamp right) => !left.Equals(right);
 65}