< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Utilities.Yaml.BigIntegerTypeConverter
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Utilities/Yaml/BigIntegerTypeConverter.cs
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
50%
Covered lines: 5
Uncovered lines: 5
Coverable lines: 10
Total lines: 53
Line coverage: 50%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 10/13/2025 - 16:52:37 Line coverage: 50% (5/10) Branch coverage: 50% (1/2) Total lines: 53 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e 10/13/2025 - 16:52:37 Line coverage: 50% (5/10) Branch coverage: 50% (1/2) Total lines: 53 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Accepts(...)100%11100%
ReadYaml(...)100%210%
WriteYaml(...)50%2266.66%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Utilities/Yaml/BigIntegerTypeConverter.cs

#LineLine coverage
 1
 2using System.Numerics;
 3using YamlDotNet.Core;
 4using YamlDotNet.Core.Events;
 5using YamlDotNet.Serialization;
 6
 7namespace Kestrun.Utilities.Yaml;
 8
 9/// <summary>
 10/// YAML type converter for BigInteger
 11/// </summary>
 12public class BigIntegerTypeConverter : IYamlTypeConverter
 13{
 14    /// <summary>
 15    /// Check if the type is BigInteger
 16    /// </summary>
 17    /// <param name="type">The type to check</param>
 18    /// <returns>true if the type is BigInteger; otherwise, false.</returns>
 10619    public bool Accepts(Type type) => typeof(BigInteger).IsAssignableFrom(type);
 20
 21    /// <summary>
 22    /// Read a BigInteger from YAML
 23    /// </summary>
 24    /// <param name="parser">The YAML parser</param>
 25    /// <param name="type">The type to deserialize to</param>
 26    /// <param name="rootDeserializer">The root deserializer</param>
 27    /// <returns>The deserialized BigInteger</returns>
 28    public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer)
 29    {
 030        var value = parser.Consume<Scalar>().Value;
 031        var bigNr = BigInteger.Parse(value);
 032        return bigNr;
 33    }
 34
 35    /// <summary>
 36    /// Write a BigInteger to YAML
 37    /// </summary>
 38    /// <param name="emitter">The YAML emitter</param>
 39    /// <param name="value">The BigInteger value</param>
 40    /// <param name="type">The type of the value</param>
 41    /// <param name="serializer">The object serializer</param>
 42    public void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializer serializer)
 43    {
 144        if (value is null)
 45        {
 046            emitter.Emit(new Scalar(AnchorName.Empty, TagName.Empty, "null", ScalarStyle.Plain, true, false));
 047            return;
 48        }
 49
 150        var bigNr = (BigInteger)value;
 151        emitter.Emit(new Scalar(AnchorName.Empty, TagName.Empty, bigNr.ToString(), ScalarStyle.Plain, true, false));
 152    }
 53}