< Summary

Information
Class: NGql.Core.Builders.SpanPathBuilder
Assembly: NGql.Core
File(s): /home/runner/work/NGql/NGql/src/Core/Builders/SpanPathBuilder.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 37
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
.ctor(...)100%11100%
Append(...)100%88100%
AsSpan()100%11100%
ToString()100%11100%

File(s)

/home/runner/work/NGql/NGql/src/Core/Builders/SpanPathBuilder.cs

#LineLine coverage
 1using System.Runtime.CompilerServices;
 2
 3namespace NGql.Core.Builders;
 4
 5/// <summary>
 6/// Ref struct for building paths using spans without allocations
 7/// </summary>
 8internal ref struct SpanPathBuilder(Span<char> buffer)
 9{
 425110    private Span<char> _buffer = buffer;
 425111    private int _length = 0;
 12
 13    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 14    public void Append(ReadOnlySpan<char> segment)
 15    {
 1179616        if (_length > 0)
 17        {
 754518            if (_length >= _buffer.Length)
 319                throw new InvalidOperationException($"SpanPathBuilder buffer overflow: cannot append separator, buffer l
 754220            _buffer[_length++] = '.';
 21        }
 22
 1179323        if (segment.Length > 0)
 24        {
 1179325            if (_length + segment.Length > _buffer.Length)
 626                throw new InvalidOperationException($"SpanPathBuilder buffer overflow: cannot append segment of length {
 1178727            segment.CopyTo(_buffer[_length..]);
 1178728            _length += segment.Length;
 29        }
 1178730    }
 31
 32    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 907833    public readonly ReadOnlySpan<char> AsSpan() => _buffer[.._length];
 34
 35    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 1236    public readonly override string ToString() => _buffer[.._length].ToString();
 37}