Skip to content

Commit

Permalink
Fix DispatchProxy not working with in parameters (#49214)
Browse files Browse the repository at this point in the history
* Fix DispatchProxy not working with in parameters

* Correct typo

Co-authored-by: Christopher Watford <[email protected]>

* Fixed Calling Convention

Removed unneeded mods

Co-authored-by: Christopher Watford <[email protected]>
  • Loading branch information
wzchua and watfordgnf authored Apr 12, 2021
1 parent d2cf673 commit 486757d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,19 @@ internal void AddInterfaceImpl([DynamicallyAccessedMembers(DynamicallyAccessedMe
private MethodBuilder AddMethodImpl(MethodInfo mi, int methodInfoIndex)
{
ParameterInfo[] parameters = mi.GetParameters();
Type[] paramTypes = ParamTypes(parameters, false);
Type[] paramTypes = new Type[parameters.Length];
Type[][] paramReqMods = new Type[paramTypes.Length][];

for (int i = 0; i < parameters.Length; i++)
{
paramTypes[i] = parameters[i].ParameterType;
paramReqMods[i] = parameters[i].GetRequiredCustomModifiers();
}

MethodBuilder mdb = _tb.DefineMethod(mi.Name, MethodAttributes.Public | MethodAttributes.Virtual, CallingConventions.Standard,
mi.ReturnType, null, null,
paramTypes, paramReqMods, null);

MethodBuilder mdb = _tb.DefineMethod(mi.Name, MethodAttributes.Public | MethodAttributes.Virtual, mi.ReturnType, paramTypes);
if (mi.ContainsGenericParameters)
{
Type[] ts = mi.GetGenericArguments();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ public static void Invoke_Ref_Out_In_Method()
testRefOutInInvocation(p => p.Out(out _), null);
testRefOutInInvocation(p => p.OutAttribute(value), "Hello");
testRefOutInInvocation(p => p.Ref(ref value), "Hello");
testRefOutInInvocation(p => p.In(in value), "Hello");
}

private static void testRefOutInInvocation(Action<TestType_IOut_Ref> invocation, string expected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public interface TestType_IHelloService

public interface TestType_IOut_Ref
{
void In(in string message);
void Out(out string message);
void Ref(ref string message);
void InAttribute([In] string message);
Expand Down

0 comments on commit 486757d

Please sign in to comment.