Skip to content
Concord

Class ControlHandle<T>

Namespace
Concord
Assembly
Concord.Emit.dll

Control parameter passed to non-void-target injections that can inspect, replace, or supply the target method's return value.

public sealed class ControlHandle<T>

Type Parameters

T

The return type of the target method.

Inheritance
ControlHandle<T>
Inherited Members

Remarks

Concord lowers calls and property access on this type into wrapper locals while composing IL. Runtime instances are not allocated on the patched method hot path.

Properties

ReturnValue

Gets or sets the target method result carried by the wrapper.

public T ReturnValue { get; set; }

Property Value

T

Methods

Cancel()

Marks the current injection as cancelling the original target invocation.

public void Cancel()

GetState<TState>()

Reads the value stored in this call's state slot, or the type default when nothing wrote it.

[SuppressMessage("Performance", "CA1822", Justification = "Lowering matches Call/Callvirt on a ControlHandle instance; making this static would change the emitted call shape and stop ControlHandleLowering from recognising the site.")]
public TState GetState<TState>()

Returns

TState

The stored value.

Type Parameters

TState

The slot's type. Every injection in one declaration must agree on it.

SetState<TState>(TState)

Stores a value in this call's state slot. The slot is scoped to the declaring patch declaration and lives for one target call.

[SuppressMessage("Performance", "CA1822", Justification = "Lowering matches Call/Callvirt on a ControlHandle instance; making this static would change the emitted call shape and stop ControlHandleLowering from recognising the site.")]
public void SetState<TState>(TState value)

Parameters

value TState

The value to store.

Type Parameters

TState

The slot's type. Every injection in one declaration must agree on it.