Class ShieldTaskExtensions
- Namespace
- Kevlar
- Assembly
- Kevlar.dll
Task-based execution overloads. Most application code returns
Task<TResult> rather than ValueTask<TResult>; these overloads let such
delegates flow straight into a shield: shield.ExecuteAsync(ct => LoadUserAsync(id, ct)).
public static class ShieldTaskExtensions
- Inheritance
-
ShieldTaskExtensions
- Inherited Members
Remarks
They are extension methods deliberately: the instance ValueTask overloads always win
overload resolution when both apply (async lambdas), so these only kick in for delegates that
genuinely return Task — with no ambiguity and no behavior change elsewhere.
Methods
ExecuteAsync(Shield, Func<CancellationToken, Task>, CancellationToken)
Executes the Task-returning void delegate through the pipeline.
public static ValueTask ExecuteAsync(this Shield shield, Func<CancellationToken, Task> action, CancellationToken cancellationToken = default)
Parameters
shieldShieldactionFunc<CancellationToken, Task>cancellationTokenCancellationToken
Returns
ExecuteAsync<T>(Shield, Func<CancellationToken, Task<T>>, CancellationToken)
Executes the Task<TResult>-returning delegate through the pipeline.
public static ValueTask<T> ExecuteAsync<T>(this Shield shield, Func<CancellationToken, Task<T>> action, CancellationToken cancellationToken = default)
Parameters
shieldShieldactionFunc<CancellationToken, Task<T>>cancellationTokenCancellationToken
Returns
- ValueTask<T>
Type Parameters
T
ExecuteAsync<TState>(Shield, TState, Func<TState, CancellationToken, Task>, CancellationToken)
Executes the Task-returning void delegate through the pipeline, threading state to avoid closure allocations.
public static ValueTask ExecuteAsync<TState>(this Shield shield, TState state, Func<TState, CancellationToken, Task> action, CancellationToken cancellationToken = default)
Parameters
shieldShieldstateTStateactionFunc<TState, CancellationToken, Task>cancellationTokenCancellationToken
Returns
Type Parameters
TState
ExecuteAsync<TResult>(Shield<TResult>, Func<CancellationToken, Task<TResult>>, CancellationToken)
Executes the Task<TResult>-returning delegate through the pipeline.
public static ValueTask<TResult> ExecuteAsync<TResult>(this Shield<TResult> shield, Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken = default)
Parameters
shieldShield<TResult>actionFunc<CancellationToken, Task<TResult>>cancellationTokenCancellationToken
Returns
- ValueTask<TResult>
Type Parameters
TResult
ExecuteAsync<T, TState>(Shield, TState, Func<TState, CancellationToken, Task<T>>, CancellationToken)
Executes the Task<TResult>-returning delegate through the pipeline, threading state to avoid closure allocations.
public static ValueTask<T> ExecuteAsync<T, TState>(this Shield shield, TState state, Func<TState, CancellationToken, Task<T>> action, CancellationToken cancellationToken = default)
Parameters
shieldShieldstateTStateactionFunc<TState, CancellationToken, Task<T>>cancellationTokenCancellationToken
Returns
- ValueTask<T>
Type Parameters
TTState
ExecuteAsync<TResult, TState>(Shield<TResult>, TState, Func<TState, CancellationToken, Task<TResult>>, CancellationToken)
Executes the Task<TResult>-returning delegate through the pipeline, threading state to avoid closure allocations.
public static ValueTask<TResult> ExecuteAsync<TResult, TState>(this Shield<TResult> shield, TState state, Func<TState, CancellationToken, Task<TResult>> action, CancellationToken cancellationToken = default)
Parameters
shieldShield<TResult>stateTStateactionFunc<TState, CancellationToken, Task<TResult>>cancellationTokenCancellationToken
Returns
- ValueTask<TResult>
Type Parameters
TResultTState
ExecuteOutcomeAsync(Shield, Func<CancellationToken, Task>, CancellationToken)
Executes a Task-returning void delegate and returns its outcome.
public static ValueTask<Outcome> ExecuteOutcomeAsync(this Shield shield, Func<CancellationToken, Task> action, CancellationToken cancellationToken = default)
Parameters
shieldShieldactionFunc<CancellationToken, Task>cancellationTokenCancellationToken
Returns
ExecuteOutcomeAsync<T>(Shield, Func<CancellationToken, Task<T>>, CancellationToken)
Executes the Task<TResult>-returning delegate through the pipeline and returns the outcome instead of throwing.
public static ValueTask<Outcome<T>> ExecuteOutcomeAsync<T>(this Shield shield, Func<CancellationToken, Task<T>> action, CancellationToken cancellationToken = default)
Parameters
shieldShieldactionFunc<CancellationToken, Task<T>>cancellationTokenCancellationToken
Returns
Type Parameters
T
ExecuteOutcomeAsync<TState>(Shield, TState, Func<TState, CancellationToken, Task>, CancellationToken)
Executes a Task-returning void delegate, threading state to
avoid closure allocations, and returns its outcome.
public static ValueTask<Outcome> ExecuteOutcomeAsync<TState>(this Shield shield, TState state, Func<TState, CancellationToken, Task> action, CancellationToken cancellationToken = default)
Parameters
shieldShieldstateTStateactionFunc<TState, CancellationToken, Task>cancellationTokenCancellationToken
Returns
Type Parameters
TState
ExecuteOutcomeAsync<TResult>(Shield<TResult>, Func<CancellationToken, Task<TResult>>, CancellationToken)
Executes the Task<TResult>-returning delegate through the pipeline and returns the outcome instead of throwing.
public static ValueTask<Outcome<TResult>> ExecuteOutcomeAsync<TResult>(this Shield<TResult> shield, Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken = default)
Parameters
shieldShield<TResult>actionFunc<CancellationToken, Task<TResult>>cancellationTokenCancellationToken
Returns
Type Parameters
TResult
ExecuteOutcomeAsync<T, TState>(Shield, TState, Func<TState, CancellationToken, Task<T>>, CancellationToken)
Executes the Task<TResult>-returning delegate through the pipeline, threading state to avoid closure allocations, and returns the outcome instead of throwing.
public static ValueTask<Outcome<T>> ExecuteOutcomeAsync<T, TState>(this Shield shield, TState state, Func<TState, CancellationToken, Task<T>> action, CancellationToken cancellationToken = default)
Parameters
shieldShieldstateTStateactionFunc<TState, CancellationToken, Task<T>>cancellationTokenCancellationToken
Returns
Type Parameters
TTState
ExecuteOutcomeAsync<TResult, TState>(Shield<TResult>, TState, Func<TState, CancellationToken, Task<TResult>>, CancellationToken)
Executes the Task<TResult>-returning delegate through the pipeline, threading state to avoid closure allocations, and returns the outcome instead of throwing.
public static ValueTask<Outcome<TResult>> ExecuteOutcomeAsync<TResult, TState>(this Shield<TResult> shield, TState state, Func<TState, CancellationToken, Task<TResult>> action, CancellationToken cancellationToken = default)
Parameters
shieldShield<TResult>stateTStateactionFunc<TState, CancellationToken, Task<TResult>>cancellationTokenCancellationToken
Returns
Type Parameters
TResultTState
ExecuteWithContextAsync(Shield, KevlarContext, Func<KevlarContext, Task>)
Executes a context-aware Task delegate using state inherited from parentContext.
public static ValueTask ExecuteWithContextAsync(this Shield shield, KevlarContext parentContext, Func<KevlarContext, Task> action)
Parameters
shieldShieldparentContextKevlarContextactionFunc<KevlarContext, Task>
Returns
ExecuteWithContextAsync(Shield, Func<KevlarContext, Task>, CancellationToken)
Executes a context-aware Task-returning void delegate without seeding execution properties. The context is pooled; never retain it beyond the delegate.
public static ValueTask ExecuteWithContextAsync(this Shield shield, Func<KevlarContext, Task> action, CancellationToken cancellationToken = default)
Parameters
shieldShieldactionFunc<KevlarContext, Task>cancellationTokenCancellationToken
Returns
ExecuteWithContextAsync<T>(Shield, KevlarContext, Func<KevlarContext, Task<T>>)
Executes a context-aware Task<TResult> delegate using state inherited from parentContext.
public static ValueTask<T> ExecuteWithContextAsync<T>(this Shield shield, KevlarContext parentContext, Func<KevlarContext, Task<T>> action)
Parameters
shieldShieldparentContextKevlarContextactionFunc<KevlarContext, Task<T>>
Returns
- ValueTask<T>
Type Parameters
T
ExecuteWithContextAsync<TState>(Shield, KevlarContext, TState, Func<TState, KevlarContext, Task>)
Executes a context-aware Task delegate using state inherited from parentContext, threading state to avoid closure allocations.
public static ValueTask ExecuteWithContextAsync<TState>(this Shield shield, KevlarContext parentContext, TState state, Func<TState, KevlarContext, Task> action)
Parameters
shieldShieldparentContextKevlarContextstateTStateactionFunc<TState, KevlarContext, Task>
Returns
Type Parameters
TState
ExecuteWithContextAsync<T>(Shield, Func<KevlarContext, Task<T>>, CancellationToken)
Executes a context-aware Task<TResult>-returning delegate without seeding execution properties. The context is pooled; never retain it beyond the delegate.
public static ValueTask<T> ExecuteWithContextAsync<T>(this Shield shield, Func<KevlarContext, Task<T>> action, CancellationToken cancellationToken = default)
Parameters
shieldShieldactionFunc<KevlarContext, Task<T>>cancellationTokenCancellationToken
Returns
- ValueTask<T>
Type Parameters
T
ExecuteWithContextAsync<TState>(Shield, TState, Action<TState, KevlarProperties>, Func<TState, KevlarContext, Task>, Action<TState, KevlarProperties>, CancellationToken)
Initializes execution properties, executes a context-aware Task delegate, then exposes final properties before the pooled context is returned.
public static ValueTask ExecuteWithContextAsync<TState>(this Shield shield, TState state, Action<TState, KevlarProperties> initializeProperties, Func<TState, KevlarContext, Task> action, Action<TState, KevlarProperties> onCompleted, CancellationToken cancellationToken = default)
Parameters
shieldShieldstateTStateinitializePropertiesAction<TState, KevlarProperties>actionFunc<TState, KevlarContext, Task>onCompletedAction<TState, KevlarProperties>cancellationTokenCancellationToken
Returns
Type Parameters
TState
ExecuteWithContextAsync<TState>(Shield, TState, Action<TState, KevlarProperties>, Func<TState, KevlarContext, Task>, CancellationToken)
Initializes execution properties, then executes a context-aware Task-returning void delegate.
public static ValueTask ExecuteWithContextAsync<TState>(this Shield shield, TState state, Action<TState, KevlarProperties> initializeProperties, Func<TState, KevlarContext, Task> action, CancellationToken cancellationToken = default)
Parameters
shieldShieldstateTStateinitializePropertiesAction<TState, KevlarProperties>actionFunc<TState, KevlarContext, Task>cancellationTokenCancellationToken
Returns
Type Parameters
TState
ExecuteWithContextAsync<TResult>(Shield<TResult>, KevlarContext, Func<KevlarContext, Task<TResult>>)
Executes a context-aware Task<TResult> delegate using state inherited from parentContext.
public static ValueTask<TResult> ExecuteWithContextAsync<TResult>(this Shield<TResult> shield, KevlarContext parentContext, Func<KevlarContext, Task<TResult>> action)
Parameters
shieldShield<TResult>parentContextKevlarContextactionFunc<KevlarContext, Task<TResult>>
Returns
- ValueTask<TResult>
Type Parameters
TResult
ExecuteWithContextAsync<TResult>(Shield<TResult>, Func<KevlarContext, Task<TResult>>, CancellationToken)
Executes a context-aware Task<TResult>-returning delegate without seeding execution properties. The context is pooled; never retain it beyond the delegate.
public static ValueTask<TResult> ExecuteWithContextAsync<TResult>(this Shield<TResult> shield, Func<KevlarContext, Task<TResult>> action, CancellationToken cancellationToken = default)
Parameters
shieldShield<TResult>actionFunc<KevlarContext, Task<TResult>>cancellationTokenCancellationToken
Returns
- ValueTask<TResult>
Type Parameters
TResult
ExecuteWithContextAsync<T, TState>(Shield, KevlarContext, TState, Func<TState, KevlarContext, Task<T>>)
Executes a context-aware Task<TResult> delegate using state inherited from parentContext, threading state to avoid closure allocations.
public static ValueTask<T> ExecuteWithContextAsync<T, TState>(this Shield shield, KevlarContext parentContext, TState state, Func<TState, KevlarContext, Task<T>> action)
Parameters
shieldShieldparentContextKevlarContextstateTStateactionFunc<TState, KevlarContext, Task<T>>
Returns
- ValueTask<T>
Type Parameters
TTState
ExecuteWithContextAsync<T, TState>(Shield, TState, Action<TState, KevlarProperties>, Func<TState, KevlarContext, Task<T>>, Action<TState, KevlarProperties>, CancellationToken)
Initializes execution properties, executes a context-aware Task<TResult> delegate, then exposes final properties before the pooled context is returned.
public static ValueTask<T> ExecuteWithContextAsync<T, TState>(this Shield shield, TState state, Action<TState, KevlarProperties> initializeProperties, Func<TState, KevlarContext, Task<T>> action, Action<TState, KevlarProperties> onCompleted, CancellationToken cancellationToken = default)
Parameters
shieldShieldstateTStateinitializePropertiesAction<TState, KevlarProperties>actionFunc<TState, KevlarContext, Task<T>>onCompletedAction<TState, KevlarProperties>cancellationTokenCancellationToken
Returns
- ValueTask<T>
Type Parameters
TTState
ExecuteWithContextAsync<T, TState>(Shield, TState, Action<TState, KevlarProperties>, Func<TState, KevlarContext, Task<T>>, CancellationToken)
Initializes execution properties, then executes a context-aware Task<TResult>-returning delegate.
public static ValueTask<T> ExecuteWithContextAsync<T, TState>(this Shield shield, TState state, Action<TState, KevlarProperties> initializeProperties, Func<TState, KevlarContext, Task<T>> action, CancellationToken cancellationToken = default)
Parameters
shieldShieldstateTStateinitializePropertiesAction<TState, KevlarProperties>actionFunc<TState, KevlarContext, Task<T>>cancellationTokenCancellationToken
Returns
- ValueTask<T>
Type Parameters
TTState
ExecuteWithContextAsync<TResult, TState>(Shield<TResult>, KevlarContext, TState, Func<TState, KevlarContext, Task<TResult>>)
Executes a context-aware Task<TResult> delegate using state inherited from parentContext, threading state to avoid closure allocations.
public static ValueTask<TResult> ExecuteWithContextAsync<TResult, TState>(this Shield<TResult> shield, KevlarContext parentContext, TState state, Func<TState, KevlarContext, Task<TResult>> action)
Parameters
shieldShield<TResult>parentContextKevlarContextstateTStateactionFunc<TState, KevlarContext, Task<TResult>>
Returns
- ValueTask<TResult>
Type Parameters
TResultTState
ExecuteWithContextAsync<TResult, TState>(Shield<TResult>, TState, Action<TState, KevlarProperties>, Func<TState, KevlarContext, Task<TResult>>, Action<TState, KevlarProperties>, CancellationToken)
Initializes execution properties, executes a context-aware Task<TResult> delegate, then exposes final properties before the pooled context is returned.
public static ValueTask<TResult> ExecuteWithContextAsync<TResult, TState>(this Shield<TResult> shield, TState state, Action<TState, KevlarProperties> initializeProperties, Func<TState, KevlarContext, Task<TResult>> action, Action<TState, KevlarProperties> onCompleted, CancellationToken cancellationToken = default)
Parameters
shieldShield<TResult>stateTStateinitializePropertiesAction<TState, KevlarProperties>actionFunc<TState, KevlarContext, Task<TResult>>onCompletedAction<TState, KevlarProperties>cancellationTokenCancellationToken
Returns
- ValueTask<TResult>
Type Parameters
TResultTState
ExecuteWithContextAsync<TResult, TState>(Shield<TResult>, TState, Action<TState, KevlarProperties>, Func<TState, KevlarContext, Task<TResult>>, CancellationToken)
Initializes execution properties, then executes a context-aware Task<TResult>-returning delegate.
public static ValueTask<TResult> ExecuteWithContextAsync<TResult, TState>(this Shield<TResult> shield, TState state, Action<TState, KevlarProperties> initializeProperties, Func<TState, KevlarContext, Task<TResult>> action, CancellationToken cancellationToken = default)
Parameters
shieldShield<TResult>stateTStateinitializePropertiesAction<TState, KevlarProperties>actionFunc<TState, KevlarContext, Task<TResult>>cancellationTokenCancellationToken
Returns
- ValueTask<TResult>
Type Parameters
TResultTState