< Summary

Information
Class: SwiftCollections.SwiftDictionaryState<T1, T2>
Assembly: SwiftCollections
File(s): /home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Serialization/State/SwiftDictionaryState.cs
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 48
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/SwiftDictionaryState.cs

#LineLine coverage
 1//=======================================================================
 2// SwiftDictionaryState.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.Collections.Generic;
 11using System.Text.Json.Serialization;
 12
 13namespace SwiftCollections;
 14
 15/// <summary>
 16/// Represents an immutable snapshot of the key-value pairs contained in a dictionary at a specific point in time.
 17/// </summary>
 18/// <remarks>
 19/// This struct is typically used to serialize or transfer the state of a dictionary.
 20/// The contents are read-only and reflect the state of the dictionary when the snapshot was taken.
 21/// </remarks>
 22/// <typeparam name="TKey">The type of keys in the dictionary.</typeparam>
 23/// <typeparam name="TValue">The type of values in the dictionary.</typeparam>
 24[Serializable]
 25[MemoryPackable]
 26public readonly partial struct SwiftDictionaryState<TKey, TValue>
 27{
 28    /// <summary>
 29    /// Gets the collection of key/value pairs contained in the object.
 30    /// </summary>
 31    [JsonInclude]
 32    [MemoryPackInclude]
 33    public readonly KeyValuePair<TKey, TValue>[] Items;
 34
 35    /// <summary>
 36    /// Initializes a new instance of the SwiftDictionaryState class with the specified key-value pairs.
 37    /// </summary>
 38    /// <remarks>
 39    /// This constructor is typically used during deserialization to restore the state of the dictionary from a serializ
 40    /// </remarks>
 41    /// <param name="items">An array of key-value pairs to initialize the dictionary state. Cannot be null.</param>
 42    [JsonConstructor]
 43    [MemoryPackConstructor]
 44    public SwiftDictionaryState(KeyValuePair<TKey, TValue>[] items)
 45    {
 3246        Items = items;
 3247    }
 48}