< Summary

Information
Class: NexusLabs.Needlr.VerificationIssue
Assembly: NexusLabs.Needlr
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr/VerificationOptions.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 102
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_Type()100%11100%
get_Message()100%11100%
get_DetailedMessage()100%11100%
get_ConfiguredBehavior()100%11100%
get_InvolvedTypes()100%11100%

File(s)

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

#LineLine coverage
 1using Microsoft.Extensions.DependencyInjection;
 2
 3namespace NexusLabs.Needlr;
 4
 5/// <summary>
 6/// Options for controlling container verification behavior.
 7/// </summary>
 8public sealed record VerificationOptions
 9{
 10    /// <summary>
 11    /// Gets or sets the behavior when lifetime mismatches are detected.
 12    /// Default is <see cref="VerificationBehavior.Warn"/>.
 13    /// </summary>
 14    public VerificationBehavior LifetimeMismatchBehavior { get; init; } = VerificationBehavior.Warn;
 15
 16    /// <summary>
 17    /// Gets or sets the behavior when circular dependencies are detected.
 18    /// Default is <see cref="VerificationBehavior.Throw"/>.
 19    /// </summary>
 20    public VerificationBehavior CircularDependencyBehavior { get; init; } = VerificationBehavior.Throw;
 21
 22    /// <summary>
 23    /// Gets or sets a callback for reporting verification issues.
 24    /// If null, issues are written to Console.Error.
 25    /// </summary>
 26    public Action<VerificationIssue>? IssueReporter { get; init; }
 27
 28    /// <summary>
 29    /// Default verification options - warns on lifetime mismatches, throws on circular dependencies.
 30    /// </summary>
 31    public static VerificationOptions Default => new();
 32
 33    /// <summary>
 34    /// Strict verification options - throws on any verification issue.
 35    /// </summary>
 36    public static VerificationOptions Strict => new()
 37    {
 38        LifetimeMismatchBehavior = VerificationBehavior.Throw,
 39        CircularDependencyBehavior = VerificationBehavior.Throw
 40    };
 41
 42    /// <summary>
 43    /// Disabled verification - no checks performed.
 44    /// </summary>
 45    public static VerificationOptions Disabled => new()
 46    {
 47        LifetimeMismatchBehavior = VerificationBehavior.Silent,
 48        CircularDependencyBehavior = VerificationBehavior.Silent
 49    };
 50}
 51
 52/// <summary>
 53/// Specifies the behavior when a verification issue is detected.
 54/// </summary>
 55public enum VerificationBehavior
 56{
 57    /// <summary>
 58    /// Ignore the issue silently.
 59    /// </summary>
 60    Silent = 0,
 61
 62    /// <summary>
 63    /// Log a warning but continue.
 64    /// </summary>
 65    Warn = 1,
 66
 67    /// <summary>
 68    /// Throw an exception to prevent the application from starting.
 69    /// </summary>
 70    Throw = 2
 71}
 72
 73/// <summary>
 74/// Represents a verification issue detected during container analysis.
 75/// </summary>
 1476public sealed record VerificationIssue(
 1277    VerificationIssueType Type,
 378    string Message,
 279    string DetailedMessage,
 2480    VerificationBehavior ConfiguredBehavior)
 81{
 82    /// <summary>
 83    /// Gets the service types involved in this issue.
 84    /// </summary>
 2785    public IReadOnlyList<Type> InvolvedTypes { get; init; } = [];
 86}
 87
 88/// <summary>
 89/// The type of verification issue detected.
 90/// </summary>
 91public enum VerificationIssueType
 92{
 93    /// <summary>
 94    /// A longer-lived service depends on a shorter-lived service.
 95    /// </summary>
 96    LifetimeMismatch,
 97
 98    /// <summary>
 99    /// A circular dependency was detected in the dependency graph.
 100    /// </summary>
 101    CircularDependency
 102}