Skip to content

Missing support for ref- and out args for sync calls #4

Description

@crystalgreen

Async calls don't support ref- or out arguments but synchronous calls do. But this doesn't work in DispatchProxyAsync.

When calling via Invoke, those arg types should be supported but I get an exception. The original DispatchProxy does support it.

See my example on dotnetfiddle.
Also try only out- args or only ref-args.

Activity

  1. chekhlov commented on Nov 25, 2025

    @chekhlov

    [DispatchProxyAsync] is have a bag - the author incorrectly added the processing of out and ref parameters.
    Copying the parameters back occurs before calling the invoke method.
    Fix: move block in row 682
    for (int i = 0; i < parameters.Length; i++)
    {
    if (parameters[i].ParameterType.IsByRef)
    {
    args.BeginSet(i);
    argsArr.Get(i);
    args.EndSet(i, typeof(object));
    }
    }
    after row 707 il.Emit(OpCodes.Callvirt, invokeMethod);
    is now work fine
    There is also a bug with out parameters: out parameter values ​​are not passed to invoke
    comment row 627 if (!parameters[i].IsOut)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions