Class PreviewDispatchProxy

Runtime dispatch handler for the stub produced by Mock<TService>(Action<IStub<TService>>). Returns configured values for set-up members and safe defaults for everything else. Async is determined by inspecting the method's return type — never by method name.

This is not a System.Reflection.DispatchProxy: the proxy type is emitted per load context by BlazorToolkit.Previews.StubProxyFactory and forwards every interface call here via Invoke(MethodInfo?, object?[]?). The framework's System.Reflection.DispatchProxy keeps a single process-global proxy assembly bound to the first load context, which breaks Mock<T> after a rebuild in the long-lived sidecar (the returned proxy implements the previous build's interface). See BlazorToolkit.Previews.StubProxyFactory.

Inheritance
PreviewDispatchProxy
Namespace: BlazorToolkit.Previews
Assembly: BlazorToolkit.Previews.dll
Syntax
public class PreviewDispatchProxy

Constructors

PreviewDispatchProxy()

Declaration
public PreviewDispatchProxy()

Methods

Invoke(MethodInfo?, object?[]?)

Dispatches an intercepted call to its configured stub value, or a safe default. Called by the emitted proxy (a separate dynamic assembly), so it must be public.

Declaration
public object? Invoke(MethodInfo? targetMethod, object?[]? args)
Parameters
Type Name Description
MethodInfo targetMethod
object[] args
Returns
Type Description
object