< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Workspace.WorkspaceResult<T>
Assembly: NexusLabs.Needlr.AgentFramework
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/Workspace/WorkspaceResult.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 43
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
get_Success()100%11100%
get_Value()100%11100%
get_Exception()100%11100%
.ctor(...)100%11100%
.ctor(...)100%11100%
Ok(...)100%11100%
Fail(...)100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/Workspace/WorkspaceResult.cs

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework.Workspace;
 2
 3/// <summary>
 4/// Result of a workspace operation — either a success value of type
 5/// <typeparamref name="T"/> or a failure carrying an <see cref="System.Exception"/>.
 6/// </summary>
 7/// <typeparam name="T">The operation-specific success data type.</typeparam>
 8public sealed class WorkspaceResult<T>
 9{
 10    /// <summary>Whether the operation succeeded.</summary>
 1611    public bool Success { get; }
 12
 13    /// <summary>
 14    /// The success value. Only meaningful when <see cref="Success"/> is
 15    /// <see langword="true"/>.
 16    /// </summary>
 3017    public T Value { get; }
 18
 19    /// <summary>
 20    /// The exception that caused the failure. Only meaningful when
 21    /// <see cref="Success"/> is <see langword="false"/>.
 22    /// </summary>
 823    public Exception? Exception { get; }
 24
 14825    private WorkspaceResult(T value)
 26    {
 14827        Success = true;
 14828        Value = value;
 14829    }
 30
 631    private WorkspaceResult(Exception exception)
 32    {
 633        Success = false;
 634        Exception = exception;
 635        Value = default!;
 636    }
 37
 38    /// <summary>Creates a success result carrying <paramref name="value"/>.</summary>
 14839    public static WorkspaceResult<T> Ok(T value) => new(value);
 40
 41    /// <summary>Creates a failure result carrying <paramref name="exception"/>.</summary>
 642    public static WorkspaceResult<T> Fail(Exception exception) => new(exception);
 43}