< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Logging.Enrichers.Extensions.ErrorRecordExtensions
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Logging/Enrichers/Extensions/ErrorRecordExtensions.cs
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
100%
Covered lines: 27
Uncovered lines: 0
Coverable lines: 27
Total lines: 61
Line coverage: 100%
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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ToTable(...)100%11100%
ToTable(...)50%22100%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Logging/Enrichers/Extensions/ErrorRecordExtensions.cs

#LineLine coverage
 1using Kestrun.Logging.Data;
 2using Kestrun.Logging.Utils.Console;
 3using Kestrun.Logging.Utils.Console.Extensions;
 4
 5
 6namespace Kestrun.Logging.Enrichers.Extensions;
 7
 8/// <summary>
 9/// Provides extension methods for formatting error records and invocation info as tables.
 10/// </summary>
 11public static class ErrorRecordExtensions
 12{
 13    /// <summary>
 14    /// Formats the specified <see cref="ErrorRecordWrapper"/> as a table string.
 15    /// </summary>
 16    /// <param name="errorRecord">The error record to format.</param>
 17    /// <returns>A string representation of the error record as a table.</returns>
 18    public static string ToTable(this ErrorRecordWrapper errorRecord)
 19    {
 120        var table = new Table(new Padding(1));
 21
 122        table.AddPropertyRow("CategoryInfo", errorRecord.CategoryInfo);
 123        table.AddPropertyRow("ErrorDetails", errorRecord.ErrorDetails);
 124        table.AddPropertyRow("FullyQualifiedErrorId", errorRecord.FullyQualifiedErrorId);
 125        table.AddPropertyRow("PipelineIterationInfo", string.Join(";", errorRecord.PipelineIterationInfo));
 126        table.AddPropertyRow("ScriptStackTrace", errorRecord.ScriptStackTrace);
 127        table.AddPropertyRow("TargetObject", errorRecord.TargetObject);
 28
 129        return table.ToString();
 30    }
 31
 32    /// <summary>
 33    /// Formats the specified <see cref="InvocationInfoWrapper"/> as a table string.
 34    /// </summary>
 35    /// <param name="invocationInfo">The invocation info to format.</param>
 36    /// <returns>A string representation of the invocation info as a table.</returns>
 37    public static string ToTable(this InvocationInfoWrapper invocationInfo)
 38    {
 139        var table = new Table(new Padding(1));
 40
 141        var boundParams = string.Join(", ", invocationInfo.BoundParameters.Select(kv => $"{kv.Key}:{kv.Value}"));
 142        table.AddPropertyRow("BoundParameters", boundParams);
 143        table.AddPropertyRow("CommandOrigin", invocationInfo.CommandOrigin);
 144        table.AddPropertyRow("DisplayScriptPosition", invocationInfo.DisplayScriptPosition);
 145        table.AddPropertyRow("ExpectingInput", invocationInfo.ExpectingInput);
 146        table.AddPropertyRow("HistoryId", invocationInfo.HistoryId);
 147        table.AddPropertyRow("InvocationName", invocationInfo.InvocationName);
 148        table.AddPropertyRow("Line", invocationInfo.Line);
 149        table.AddPropertyRow("MyCommand", invocationInfo.MyCommand ?? string.Empty);
 150        table.AddPropertyRow("OffsetInLine", invocationInfo.OffsetInLine);
 151        table.AddPropertyRow("PipelineLength", invocationInfo.PipelineLength);
 152        table.AddPropertyRow("PipelinePosition", invocationInfo.PipelinePosition);
 153        table.AddPropertyRow("PSCommandPath", invocationInfo.PSCommandPath);
 154        table.AddPropertyRow("PSScriptRoot", invocationInfo.PSScriptRoot);
 155        table.AddPropertyRow("ScriptLineNumber", invocationInfo.ScriptLineNumber);
 156        table.AddPropertyRow("ScriptName", invocationInfo.ScriptName);
 157        table.AddPropertyRow("UnboundArguments", string.Join("; ", invocationInfo.UnboundArguments));
 58
 159        return table.ToString();
 60    }
 61}