Skip to content

Commit

Permalink
Merge pull request #506 from AArnott/fixLongSignatures
Browse files Browse the repository at this point in the history
Fixed proxy generation for methods with many parameters
  • Loading branch information
AArnott authored Jul 23, 2020
2 parents f59fa62 + 7653dd9 commit f4be865
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/StreamJsonRpc.Tests/JsonRpcProxyGenerationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public interface IServer

Task IncrementAsync();

ValueTask<bool> ManyParameters(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10, CancellationToken cancellationToken);

Task Dispose();
}

Expand Down Expand Up @@ -718,6 +720,11 @@ public async Task<int> SumOfParameterObject(Newtonsoft.Json.Linq.JToken paramObj

public ValueTask<int> AddValueAsync(int a, int b) => new ValueTask<int>(a + b);

public ValueTask<bool> ManyParameters(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}

internal void OnItHappened(EventArgs args) => this.ItHappened?.Invoke(this, args);

internal void OnTreeGrown(CustomEventArgs args) => this.TreeGrown?.Invoke(this, args);
Expand Down
4 changes: 2 additions & 2 deletions src/StreamJsonRpc/ProxyGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ internal static TypeInfo Get(TypeInfo serviceInterface)
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ldfld, optionsField);
il.EmitCall(OpCodes.Callvirt, ServerRequiresNamedArgumentsPropertyGetter, null);
il.Emit(OpCodes.Brfalse_S, positionalArgsLabel);
il.Emit(OpCodes.Brfalse, positionalArgsLabel);

// The second argument is a single parameter object.
{
Expand Down Expand Up @@ -389,7 +389,7 @@ private static void LoadParameterTypeArrayField(TypeBuilder proxyTypeBuilder, Pa
// Load the Type[] field, and skip initializing it if it's non-null.
il.Emit(OpCodes.Ldsfld, field);
il.Emit(OpCodes.Dup); // keep a copy on the stack after the test in case it's non-null.
il.Emit(OpCodes.Brtrue_S, skipInitLabel);
il.Emit(OpCodes.Brtrue, skipInitLabel);

// Initialize the field.
il.Emit(OpCodes.Pop); // pop off the extra null.
Expand Down

0 comments on commit f4be865

Please sign in to comment.