diff --git a/src/Proto.Cluster.CodeGen/Template.cs b/src/Proto.Cluster.CodeGen/Template.cs index 05483c8e34..b1405328c2 100644 --- a/src/Proto.Cluster.CodeGen/Template.cs +++ b/src/Proto.Cluster.CodeGen/Template.cs @@ -209,7 +209,17 @@ public async Task ReceiveAsync(global::Proto.IContext context) => new global::Proto.Cluster.ClusterKind(Kind, global::Proto.Props.FromProducer(() => new {{Name}}Actor(innerFactory))); public static global::Proto.Cluster.ClusterKind GetClusterKind(global::System.IServiceProvider serviceProvider, params object[] parameters) where T : {{Name}}Base - => new global::Proto.Cluster.ClusterKind(Kind, global::Proto.Props.FromProducer(() => new {{Name}}Actor((ctx, id) => global::Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(serviceProvider, ctx, id, parameters)))); + => new global::Proto.Cluster.ClusterKind(Kind, global::Proto.Props.FromProducer(() => new {{Name}}Actor((ctx, id) => + { + var allParameters = new object[parameters.Length + 2]; + allParameters[0] = ctx; + allParameters[1] = id; + if (parameters.Length > 0) + { + parameters.CopyTo(allParameters, 2); + } + return global::Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(serviceProvider, allParameters); + }))); } {{/each}} } diff --git a/tests/Proto.Cluster.CodeGen.Tests/ExpectedOutput.cs b/tests/Proto.Cluster.CodeGen.Tests/ExpectedOutput.cs index 05ed73156f..53163c6158 100644 --- a/tests/Proto.Cluster.CodeGen.Tests/ExpectedOutput.cs +++ b/tests/Proto.Cluster.CodeGen.Tests/ExpectedOutput.cs @@ -365,6 +365,16 @@ public async Task ReceiveAsync(global::Proto.IContext context) => new global::Proto.Cluster.ClusterKind(Kind, global::Proto.Props.FromProducer(() => new TestGrainActor(innerFactory))); public static global::Proto.Cluster.ClusterKind GetClusterKind(global::System.IServiceProvider serviceProvider, params object[] parameters) where T : TestGrainBase - => new global::Proto.Cluster.ClusterKind(Kind, global::Proto.Props.FromProducer(() => new TestGrainActor((ctx, id) => global::Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(serviceProvider, ctx, id, parameters)))); + => new global::Proto.Cluster.ClusterKind(Kind, global::Proto.Props.FromProducer(() => new TestGrainActor((ctx, id) => + { + var allParameters = new object[parameters.Length + 2]; + allParameters[0] = ctx; + allParameters[1] = id; + if (parameters.Length > 0) + { + parameters.CopyTo(allParameters, 2); + } + return global::Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(serviceProvider, allParameters); + }))); } } \ No newline at end of file diff --git a/tests/Proto.Cluster.CodeGen.Tests/ExpectedOutputPackageless.cs b/tests/Proto.Cluster.CodeGen.Tests/ExpectedOutputPackageless.cs index 2f972e41c6..2b218321ba 100644 --- a/tests/Proto.Cluster.CodeGen.Tests/ExpectedOutputPackageless.cs +++ b/tests/Proto.Cluster.CodeGen.Tests/ExpectedOutputPackageless.cs @@ -365,6 +365,16 @@ public async Task ReceiveAsync(global::Proto.IContext context) => new global::Proto.Cluster.ClusterKind(Kind, global::Proto.Props.FromProducer(() => new TestGrainActor(innerFactory))); public static global::Proto.Cluster.ClusterKind GetClusterKind(global::System.IServiceProvider serviceProvider, params object[] parameters) where T : TestGrainBase - => new global::Proto.Cluster.ClusterKind(Kind, global::Proto.Props.FromProducer(() => new TestGrainActor((ctx, id) => global::Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(serviceProvider, ctx, id, parameters)))); + => new global::Proto.Cluster.ClusterKind(Kind, global::Proto.Props.FromProducer(() => new TestGrainActor((ctx, id) => + { + var allParameters = new object[parameters.Length + 2]; + allParameters[0] = ctx; + allParameters[1] = id; + if (parameters.Length > 0) + { + parameters.CopyTo(allParameters, 2); + } + return global::Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(serviceProvider, allParameters); + }))); } } \ No newline at end of file