< Summary

Information
Class: GridForge.Configuration.GridConfigurationKey
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Configuration/GridConfigurationKey.cs
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 80
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
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%
GetHashCode()100%11100%
Equals(...)100%66100%
Equals(...)100%22100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Configuration/GridConfigurationKey.cs

#LineLine coverage
 1//=======================================================================
 2// GridConfigurationKey.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 FixedMathSharp;
 9using GridForge.Grids.Topology;
 10using SwiftCollections.Utility;
 11using System;
 12
 13namespace GridForge.Configuration;
 14
 15/// <summary>
 16/// Exact identity key for a grid's snapped bounds and topology.
 17/// </summary>
 18public readonly struct GridConfigurationKey : IEquatable<GridConfigurationKey>
 19{
 20    /// <summary>
 21    /// The minimum snapped bounds of the grid.
 22    /// </summary>
 23    public readonly Vector3d BoundsMin;
 24
 25    /// <summary>
 26    /// The maximum snapped bounds of the grid.
 27    /// </summary>
 28    public readonly Vector3d BoundsMax;
 29
 30    /// <summary>
 31    /// The grid topology used by these bounds.
 32    /// </summary>
 33    public readonly GridTopologyKind TopologyKind;
 34
 35    /// <summary>
 36    /// The topology metrics used by these bounds.
 37    /// </summary>
 38    public readonly GridTopologyMetrics TopologyMetrics;
 39
 40    /// <summary>
 41    /// Initializes a new grid configuration key.
 42    /// </summary>
 43    public GridConfigurationKey(
 44        Vector3d boundsMin,
 45        Vector3d boundsMax,
 46        GridTopologyKind topologyKind,
 47        GridTopologyMetrics topologyMetrics)
 48    {
 43849        BoundsMin = boundsMin;
 43850        BoundsMax = boundsMax;
 43851        TopologyKind = topologyKind;
 43852        TopologyMetrics = topologyMetrics;
 43853    }
 54
 55    /// <inheritdoc/>
 56    public override readonly int GetHashCode()
 57    {
 83458        int hash = SwiftHashTools.CombineHashCodes(BoundsMin.GetHashCode(), BoundsMax.GetHashCode());
 83459        hash = SwiftHashTools.CombineHashCodes(hash, TopologyKind.GetHashCode());
 83460        return SwiftHashTools.CombineHashCodes(hash, TopologyMetrics.GetHashCode());
 61    }
 62
 63    /// <inheritdoc/>
 64    public readonly bool Equals(GridConfigurationKey other)
 65    {
 3566        return BoundsMin == other.BoundsMin
 3567            && BoundsMax == other.BoundsMax
 3568            && TopologyKind == other.TopologyKind
 3569            && TopologyMetrics == other.TopologyMetrics;
 70    }
 71
 72    /// <inheritdoc/>
 273    public override readonly bool Equals(object? obj) => obj is GridConfigurationKey other && Equals(other);
 74
 75    /// <inheritdoc/>
 276    public static bool operator ==(GridConfigurationKey left, GridConfigurationKey right) => left.Equals(right);
 77
 78    /// <inheritdoc/>
 279    public static bool operator !=(GridConfigurationKey left, GridConfigurationKey right) => !left.Equals(right);
 80}