< Summary

Information
Class: Chronicler.ChronicleHashSerializer
Assembly: Chronicler
File(s): /home/runner/work/Chronicler/Chronicler/src/Chronicler/Recording/ChronicleHashSerializer.cs
Line coverage
100%
Covered lines: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 54
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
Compute(...)100%11100%
Compute(...)100%44100%
Contribute(...)100%11100%
Contribute(...)100%44100%

File(s)

/home/runner/work/Chronicler/Chronicler/src/Chronicler/Recording/ChronicleHashSerializer.cs

#LineLine coverage
 1using System;
 2
 3namespace Chronicler;
 4
 5/// <summary>
 6/// Computes deterministic record hashes by traversing <see cref="IRecordable.RecordData(IChronicler)"/>.
 7/// </summary>
 8public static class ChronicleHashSerializer
 9{
 10    /// <summary>
 11    /// Computes a deterministic hash for a recordable state graph using an empty context.
 12    /// </summary>
 13    public static ChronicleHash Compute(IRecordable target)
 14    {
 4915        return Compute(target, new ChronicleContext());
 16    }
 17
 18    /// <summary>
 19    /// Computes a deterministic hash for a recordable state graph using the supplied context.
 20    /// </summary>
 21    public static ChronicleHash Compute(IRecordable target, ChronicleContext context)
 22    {
 7378323        if (target == null)
 124            throw new ArgumentNullException(nameof(target));
 7378225        if (context == null)
 126            throw new ArgumentNullException(nameof(context));
 27
 7378128        var writer = new ChronicleHashWriter();
 7378129        writer.WriteSection("chronicler.hash", 1);
 7378130        Contribute(target, context, ref writer);
 7377731        return writer.ToHash();
 32    }
 33
 34    /// <summary>
 35    /// Contributes a recordable state graph to an existing caller-owned hash writer using an empty context.
 36    /// </summary>
 37    public static void Contribute(IRecordable target, ref ChronicleHashWriter writer)
 38    {
 339        Contribute(target, new ChronicleContext(), ref writer);
 240    }
 41
 42    /// <summary>
 43    /// Contributes a recordable state graph to an existing caller-owned hash writer using the supplied context.
 44    /// </summary>
 45    public static void Contribute(IRecordable target, ChronicleContext context, ref ChronicleHashWriter writer)
 46    {
 7378547        if (target == null)
 148            throw new ArgumentNullException(nameof(target));
 7378449        if (context == null)
 150            throw new ArgumentNullException(nameof(context));
 51
 7378352        ChronicleHashChronicler.Contribute(target, context, ref writer);
 7377953    }
 54}