< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.AsyncLocalScopedAttribute
Assembly: NexusLabs.Needlr.AgentFramework
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/AsyncLocalScopedAttribute.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 1
Coverable lines: 1
Total lines: 42
Line coverage: 0%
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_Mutable()100%210%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/AsyncLocalScopedAttribute.cs

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework;
 2
 3/// <summary>
 4/// Marks an interface for source generation of an <see cref="AsyncLocal{T}"/>-backed
 5/// implementation. The generator emits an <c>internal sealed class</c> that implements
 6/// the interface with proper scope nesting and dispose semantics.
 7/// </summary>
 8/// <remarks>
 9/// <para>
 10/// The interface must declare:
 11/// <list type="bullet">
 12///   <item>A nullable read-only property named <c>Current</c> (determines the value type).</item>
 13///   <item>A method returning <see cref="IDisposable"/> (the scope entry point).</item>
 14/// </list>
 15/// </para>
 16/// <para>
 17/// When <see cref="Mutable"/> is <see langword="true"/>, the generated implementation uses
 18/// a mutable holder object in the <see cref="AsyncLocal{T}"/> slot so that writes from child
 19/// async flows are visible to the parent scope (the pattern used by diagnostics accessors).
 20/// </para>
 21/// </remarks>
 22/// <example>
 23/// <code>
 24/// [AsyncLocalScoped]
 25/// public interface IMyContextAccessor
 26/// {
 27///     MyContext? Current { get; }
 28///     IDisposable BeginScope(MyContext value);
 29/// }
 30/// // Generator emits: internal sealed class MyContextAccessor : IMyContextAccessor { ... }
 31/// </code>
 32/// </example>
 33[AttributeUsage(AttributeTargets.Interface, AllowMultiple = false, Inherited = false)]
 34public sealed class AsyncLocalScopedAttribute : Attribute
 35{
 36    /// <summary>
 37    /// When <see langword="true"/>, the generated implementation uses a mutable holder object
 38    /// so that values set from child async flows are visible to the parent scope.
 39    /// Default is <see langword="false"/> (simple <see cref="AsyncLocal{T}"/> with scope restore).
 40    /// </summary>
 041    public bool Mutable { get; init; }
 42}

Methods/Properties

get_Mutable()