< Summary

Information
Class: SwiftCollections.Array3DState<T>
Assembly: SwiftCollections
File(s): /home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Serialization/State/Array3DState.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 68
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%

File(s)

/home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Serialization/State/Array3DState.cs

#LineLine coverage
 1using MemoryPack;
 2using System;
 3using System.Text.Json.Serialization;
 4
 5namespace SwiftCollections;
 6
 7
 8/// <summary>
 9/// Represents the immutable state of a three-dimensional array, including its dimensions and underlying data.
 10/// </summary>
 11/// <remarks>
 12/// This struct is intended for scenarios where a snapshot of a 3D array's state is needed, such as
 13/// serialization or state management. The data is stored in a one-dimensional array in row-major order. The struct is
 14/// serializable and compatible with supported serialization frameworks.
 15/// </remarks>
 16/// <typeparam name="T">The type of elements stored in the array.</typeparam>
 17[Serializable]
 18[MemoryPackable]
 19public readonly partial struct Array3DState<T>
 20{
 21    /// <summary>
 22    /// Gets the width value represented by this field.
 23    /// </summary>
 24    [JsonInclude]
 25    [MemoryPackInclude]
 26    public readonly int Width;
 27
 28    /// <summary>
 29    /// Gets the height value represented by this field.
 30    /// </summary>
 31    [JsonInclude]
 32    [MemoryPackInclude]
 33    public readonly int Height;
 34
 35    /// <summary>
 36    /// Gets the depth value represented by this field.
 37    /// </summary>
 38    [JsonInclude]
 39    [MemoryPackInclude]
 40    public readonly int Depth;
 41
 42    /// <summary>
 43    /// Gets the underlying array of data elements contained in the collection.
 44    /// </summary>
 45    [JsonInclude]
 46    [MemoryPackInclude]
 47    public readonly T[] Data;
 48
 49    /// <summary>
 50    /// Initializes a new instance of the Array3DState class with the specified dimensions and data.
 51    /// </summary>
 52    /// <param name="width">The number of elements along the X-axis. Must be greater than zero.</param>
 53    /// <param name="height">The number of elements along the Y-axis. Must be greater than zero.</param>
 54    /// <param name="depth">The number of elements along the Z-axis. Must be greater than zero.</param>
 55    /// <param name="data">
 56    /// A one-dimensional array containing the elements of the 3D array, stored in row-major order.
 57    /// The length must equal width × height × depth.
 58    /// </param>
 59    [JsonConstructor]
 60    [MemoryPackConstructor]
 61    public Array3DState(int width, int height, int depth, T[] data)
 62    {
 463        Width = width;
 464        Height = height;
 465        Depth = depth;
 466        Data = data;
 467    }
 68}