< Summary

Information
Class: Chronicler.Diagnostics.ThrowInterpolatedStringHandler
Assembly: Chronicler.Diagnostics
File(s): /home/runner/work/Chronicler/Chronicler/src/Chronicler.Diagnostics/ThrowInterpolatedStringHandler.cs
Line coverage
100%
Covered lines: 26
Uncovered lines: 0
Coverable lines: 26
Total lines: 107
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%
get_IsEnabled()100%11100%
GetFormattedText()100%11100%
AppendLiteral(...)100%11100%
AppendFormatted(...)100%11100%
AppendFormatted(...)100%11100%
AppendFormatted(...)100%11100%
AppendFormatted(...)100%11100%
AppendFormatted(...)100%11100%
AppendFormatted(...)100%11100%
AppendFormatted(...)100%11100%
AppendFormatted(...)100%11100%
AppendFormatted(...)100%11100%
AppendFormatted(...)100%11100%

File(s)

/home/runner/work/Chronicler/Chronicler/src/Chronicler.Diagnostics/ThrowInterpolatedStringHandler.cs

#LineLine coverage
 1//=======================================================================
 2// ThrowInterpolatedStringHandler.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
 8namespace Chronicler.Diagnostics;
 9
 10using System;
 11using System.Runtime.CompilerServices;
 12
 13/// <summary>Builds an exception message only for a failing guard.</summary>
 14/// <remarks>The compiler uses the constructor's gate to skip interpolation expressions when disabled. Append calls on a
 15[InterpolatedStringHandler]
 16public ref struct ThrowInterpolatedStringHandler
 17{
 18    private DiagnosticInterpolatedStringHandler _message;
 19
 20    /// <summary>
 21    /// Initializes a new instance of the <see cref="ThrowInterpolatedStringHandler"/> struct.
 22    /// </summary>
 23    /// <param name="literalLength">The compiler-supplied count of literal UTF-16 code units.</param>
 24    /// <param name="formattedCount">The compiler-supplied number of interpolation holes.</param>
 25    /// <param name="condition">The throw condition that controls whether formatting occurs.</param>
 26    /// <param name="isEnabled">Set to true to evaluate interpolation expressions, or false to skip them.</param>
 27    public ThrowInterpolatedStringHandler(
 28        int literalLength,
 29        int formattedCount,
 30        bool condition,
 31        out bool isEnabled)
 32    {
 2233        _message = new DiagnosticInterpolatedStringHandler(literalLength, formattedCount, condition, out isEnabled);
 2234    }
 35
 36    /// <summary>Gets the captured formatting gate.</summary>
 37    /// <value>True when the handler was constructed to build a message.</value>
 238    public bool IsEnabled => _message.IsEnabled;
 39
 1040    internal string GetFormattedText() => _message.GetFormattedText();
 41
 42    /// <inheritdoc cref="DiagnosticInterpolatedStringHandler.AppendLiteral(string)"/>
 43    public void AppendLiteral(string value)
 44    {
 2745        _message.AppendLiteral(value);
 2746    }
 47
 48    /// <inheritdoc cref="DiagnosticInterpolatedStringHandler.AppendFormatted{T}(T)"/>
 49    public void AppendFormatted<T>(T value)
 50    {
 951        _message.AppendFormatted(value);
 952    }
 53
 54    /// <inheritdoc cref="DiagnosticInterpolatedStringHandler.AppendFormatted{T}(T, string)"/>
 55    public void AppendFormatted<T>(T value, string? format)
 56    {
 157        _message.AppendFormatted(value, format);
 158    }
 59
 60    /// <inheritdoc cref="DiagnosticInterpolatedStringHandler.AppendFormatted{T}(T, int)"/>
 61    public void AppendFormatted<T>(T value, int alignment)
 62    {
 163        _message.AppendFormatted(value, alignment);
 164    }
 65
 66    /// <inheritdoc cref="DiagnosticInterpolatedStringHandler.AppendFormatted{T}(T, int, string)"/>
 67    public void AppendFormatted<T>(T value, int alignment, string? format)
 68    {
 169        _message.AppendFormatted(value, alignment, format);
 170    }
 71
 72    /// <inheritdoc cref="DiagnosticInterpolatedStringHandler.AppendFormatted(string)"/>
 73    public void AppendFormatted(string? value)
 74    {
 175        _message.AppendFormatted(value);
 176    }
 77
 78    /// <inheritdoc cref="DiagnosticInterpolatedStringHandler.AppendFormatted(string, int)"/>
 79    public void AppendFormatted(string? value, int alignment)
 80    {
 181        _message.AppendFormatted(value, alignment);
 182    }
 83
 84    /// <inheritdoc cref="DiagnosticInterpolatedStringHandler.AppendFormatted(string, int, string)"/>
 85    public void AppendFormatted(string? value, int alignment, string? format)
 86    {
 187        _message.AppendFormatted(value, alignment, format);
 188    }
 89
 90    /// <inheritdoc cref="DiagnosticInterpolatedStringHandler.AppendFormatted(ReadOnlySpan{char})"/>
 91    public void AppendFormatted(ReadOnlySpan<char> value)
 92    {
 193        _message.AppendFormatted(value);
 194    }
 95
 96    /// <inheritdoc cref="DiagnosticInterpolatedStringHandler.AppendFormatted(ReadOnlySpan{char}, int)"/>
 97    public void AppendFormatted(ReadOnlySpan<char> value, int alignment)
 98    {
 199        _message.AppendFormatted(value, alignment);
 1100    }
 101
 102    /// <inheritdoc cref="DiagnosticInterpolatedStringHandler.AppendFormatted(ReadOnlySpan{char}, int, string)"/>
 103    public void AppendFormatted(ReadOnlySpan<char> value, int alignment, string? format)
 104    {
 1105        _message.AppendFormatted(value, alignment, format);
 1106    }
 107}