< Summary

Information
Class: NexusLabs.Needlr.VerificationOptionsBuilder
Assembly: NexusLabs.Needlr
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr/VerificationOptionsBuilder.cs
Line coverage
70%
Covered lines: 14
Uncovered lines: 6
Coverable lines: 20
Total lines: 68
Line coverage: 70%
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%
OnLifetimeMismatch(...)100%11100%
OnCircularDependency(...)100%11100%
ReportIssuesTo(...)100%11100%
Strict()100%210%
Disabled()100%210%
Build()100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr/VerificationOptionsBuilder.cs

#LineLine coverage
 1namespace NexusLabs.Needlr;
 2
 3/// <summary>
 4/// Builder for creating <see cref="VerificationOptions"/> with a fluent API.
 5/// </summary>
 6public sealed class VerificationOptionsBuilder
 7{
 28    private VerificationBehavior _lifetimeMismatchBehavior = VerificationBehavior.Warn;
 29    private VerificationBehavior _circularDependencyBehavior = VerificationBehavior.Throw;
 10    private Action<VerificationIssue>? _issueReporter;
 11
 12    /// <summary>
 13    /// Sets the behavior when lifetime mismatches are detected.
 14    /// </summary>
 15    public VerificationOptionsBuilder OnLifetimeMismatch(VerificationBehavior behavior)
 16    {
 217        _lifetimeMismatchBehavior = behavior;
 218        return this;
 19    }
 20
 21    /// <summary>
 22    /// Sets the behavior when circular dependencies are detected.
 23    /// </summary>
 24    public VerificationOptionsBuilder OnCircularDependency(VerificationBehavior behavior)
 25    {
 126        _circularDependencyBehavior = behavior;
 127        return this;
 28    }
 29
 30    /// <summary>
 31    /// Sets a custom reporter for verification issues.
 32    /// </summary>
 33    public VerificationOptionsBuilder ReportIssuesTo(Action<VerificationIssue> reporter)
 34    {
 135        _issueReporter = reporter;
 136        return this;
 37    }
 38
 39    /// <summary>
 40    /// Throws on any verification issue.
 41    /// </summary>
 42    public VerificationOptionsBuilder Strict()
 43    {
 044        _lifetimeMismatchBehavior = VerificationBehavior.Throw;
 045        _circularDependencyBehavior = VerificationBehavior.Throw;
 046        return this;
 47    }
 48
 49    /// <summary>
 50    /// Disables all verification.
 51    /// </summary>
 52    public VerificationOptionsBuilder Disabled()
 53    {
 054        _lifetimeMismatchBehavior = VerificationBehavior.Silent;
 055        _circularDependencyBehavior = VerificationBehavior.Silent;
 056        return this;
 57    }
 58
 59    /// <summary>
 60    /// Builds the configured <see cref="VerificationOptions"/>.
 61    /// </summary>
 262    public VerificationOptions Build() => new()
 263    {
 264        LifetimeMismatchBehavior = _lifetimeMismatchBehavior,
 265        CircularDependencyBehavior = _circularDependencyBehavior,
 266        IssueReporter = _issueReporter
 267    };
 68}