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