< Summary - AsyncResponse (Release / net8.0+net10.0 / unit+integration)

Information
Class: AsyncResponse.Placeholder
Assembly: AsyncResponse.Abstractions
File(s): /home/runner/work/AsyncResponse/AsyncResponse/src/AsyncResponse.Abstractions/Placeholder.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 29
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
Payload<TPayload>()100%11100%
Exception()100%11100%
CorrelationId()100%11100%
MarkerInvoked()100%11100%

File(s)

/home/runner/work/AsyncResponse/AsyncResponse/src/AsyncResponse.Abstractions/Placeholder.cs

#LineLine coverage
 1namespace AsyncResponse;
 2
 3/// <summary>
 4/// Expression markers for registering recoverable lost-subscriber callbacks with compile-time safety.
 5/// Use them inside the lambda passed to <c>OnLostSubscriberResume</c>/<c>OnLostSubscriberFailure</c>
 6/// to mark which arguments the runtime should substitute when the callback fires:
 7/// <code>
 8/// recoverableBuilder.For&lt;OrderResult&gt;(correlationId)
 9///                   .OnLostSubscriberResume&lt;IOrderFlow&gt;(flow =>
 10///                       flow.ResumeAsync(orderId, Placeholder.Payload&lt;OrderResult&gt;(), Placeholder.CorrelationId(
 11/// </code>
 12/// The marker methods are never executed; they only exist inside expression trees and throw if
 13/// invoked directly.
 14/// </summary>
 15public static class Placeholder
 16{
 17    /// <summary>Marks an argument to be replaced by the response payload at invocation time.</summary>
 218    public static TPayload Payload<TPayload>() => throw MarkerInvoked();
 19
 20    /// <summary>Marks an argument to be replaced by the exception at invocation time.</summary>
 221    public static Exception Exception() => throw MarkerInvoked();
 22
 23    /// <summary>Marks an argument to be replaced by the correlation id at invocation time.</summary>
 224    public static string CorrelationId() => throw MarkerInvoked();
 25
 26    private static InvalidOperationException MarkerInvoked()
 327        => new("Placeholder methods are expression-tree markers and must not be invoked at runtime. " +
 328               "Use them only inside OnLostSubscriberResume/OnLostSubscriberFailure lambdas.");
 29}