< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Progress.ProgressReporterAccessor
Assembly: NexusLabs.Needlr.AgentFramework
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/Progress/ProgressReporterAccessor.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 34
Line coverage: 100%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
get_Current()100%22100%
BeginScope(...)100%11100%
.ctor(...)100%11100%
Dispose()50%22100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/Progress/ProgressReporterAccessor.cs

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework.Progress;
 2
 3/// <summary>
 4/// <see cref="AsyncLocal{T}"/>-backed implementation of <see cref="IProgressReporterAccessor"/>.
 5/// </summary>
 6internal sealed class ProgressReporterAccessor : IProgressReporterAccessor
 7{
 18    private static readonly AsyncLocal<IProgressReporter?> _current = new();
 9
 10    /// <inheritdoc />
 55011    public IProgressReporter Current => _current.Value ?? NullProgressReporter.Instance;
 12
 13    /// <inheritdoc />
 14    public IDisposable BeginScope(IProgressReporter reporter)
 15    {
 1616        ArgumentNullException.ThrowIfNull(reporter);
 17
 1518        var previous = _current.Value;
 1519        _current.Value = reporter;
 1520        return new Scope(previous);
 21    }
 22
 1523    private sealed class Scope(IProgressReporter? previous) : IDisposable
 24    {
 25        private bool _disposed;
 26
 27        public void Dispose()
 28        {
 1529            if (_disposed) return;
 1530            _disposed = true;
 1531            _current.Value = previous;
 1532        }
 33    }
 34}