Skip to content

Commit 7bd82da

Browse files
ReubenBondCopilot
andcommitted
fix(codegen): initialize compatibility activations
Chain parameterless pooled-invokable construction through the pool-aware constructor so custom initializer methods run for reflection and legacy activation paths. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 7bcaf5b commit 7bd82da

8 files changed

Lines changed: 20 additions & 11 deletions

src/Orleans.CodeGenerator/InvokableGenerator.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ public GeneratedInvokableDescription Generate(InvokableMethodDescription invokab
2929
var compatibilityCtor = fieldDescriptions.OfType<PoolFieldDescription>().Any()
3030
? ConstructorDeclaration(generatedClassName)
3131
.AddModifiers(Token(SyntaxKind.PublicKeyword))
32+
.WithInitializer(
33+
ConstructorInitializer(
34+
SyntaxKind.ThisConstructorInitializer,
35+
ArgumentList(
36+
SingletonSeparatedList(
37+
Argument(
38+
PostfixUnaryExpression(
39+
SyntaxKind.SuppressNullableWarningExpression,
40+
LiteralExpression(SyntaxKind.NullLiteralExpression)))))))
3241
.WithBody(Block())
3342
: null;
3443
var accessibility = GetAccessibility(method);

test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestBasicGrain.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public sealed class Invokable_IBasicGrain_GrainReference_6B0E24A1 : global::Orle
1818
global::TestProject.IBasicGrain _target;
1919
private static readonly global::System.Reflection.MethodInfo MethodBackingField = OrleansGeneratedCodeHelper.GetMethodInfoOrDefault(typeof(global::TestProject.IBasicGrain), "SayHello", null, new[] { typeof(string) });
2020
private readonly global::Orleans.Serialization.Invocation.InvokablePool<Invokable_IBasicGrain_GrainReference_6B0E24A1> _pool;
21-
public Invokable_IBasicGrain_GrainReference_6B0E24A1()
21+
public Invokable_IBasicGrain_GrainReference_6B0E24A1() : this(null !)
2222
{
2323
}
2424

test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassWithGenerateMethodSerializersAnnotation.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public sealed class Invokable_IMyGrain_GrainReference_6D39E404 : global::Orleans
1818
global::IMyGrain _target;
1919
private static readonly global::System.Reflection.MethodInfo MethodBackingField = OrleansGeneratedCodeHelper.GetMethodInfoOrDefault(typeof(global::IMyGrain), "SayHello", null, new[] { typeof(string) });
2020
private readonly global::Orleans.Serialization.Invocation.InvokablePool<Invokable_IMyGrain_GrainReference_6D39E404> _pool;
21-
public Invokable_IMyGrain_GrainReference_6D39E404()
21+
public Invokable_IMyGrain_GrainReference_6D39E404() : this(null !)
2222
{
2323
}
2424

test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestGrainComplexGrain.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public sealed class Invokable_IComplexGrain_GrainReference_67FE5808 : global::Or
2222
private static readonly global::System.Reflection.MethodInfo MethodBackingField = OrleansGeneratedCodeHelper.GetMethodInfoOrDefault(typeof(global::TestProject.IComplexGrain), "ProcessData", null, new[] { typeof(int), typeof(string), typeof(global::TestProject.ComplexData), typeof(global::System.Threading.CancellationToken) });
2323
global::System.Threading.CancellationTokenSource _cts;
2424
private readonly global::Orleans.Serialization.Invocation.InvokablePool<Invokable_IComplexGrain_GrainReference_67FE5808> _pool;
25-
public Invokable_IComplexGrain_GrainReference_67FE5808()
25+
public Invokable_IComplexGrain_GrainReference_67FE5808() : this(null !)
2626
{
2727
}
2828

test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestGrainMethodAnnotatedWithInvokableBaseType.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public sealed class Invokable_IHelloGrain_GrainReference_5336307F : global::Orle
1818
global::TestProject.IHelloGrain _target;
1919
private static readonly global::System.Reflection.MethodInfo MethodBackingField = OrleansGeneratedCodeHelper.GetMethodInfoOrDefault(typeof(global::TestProject.IHelloGrain), "SayHello", null, new[] { typeof(string) });
2020
private readonly global::Orleans.Serialization.Invocation.InvokablePool<Invokable_IHelloGrain_GrainReference_5336307F> _pool;
21-
public Invokable_IHelloGrain_GrainReference_5336307F()
21+
public Invokable_IHelloGrain_GrainReference_5336307F() : this(null !)
2222
{
2323
}
2424

test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestGrainMethodAnnotatedWithResponseTimeout.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public sealed class Invokable_IResponseTimeoutGrain_GrainReference_6BE752C8 : gl
1818
global::TestProject.IResponseTimeoutGrain _target;
1919
private static readonly global::System.Reflection.MethodInfo MethodBackingField = OrleansGeneratedCodeHelper.GetMethodInfoOrDefault(typeof(global::TestProject.IResponseTimeoutGrain), "LongRunningMethod", null, new[] { typeof(string) });
2020
private readonly global::Orleans.Serialization.Invocation.InvokablePool<Invokable_IResponseTimeoutGrain_GrainReference_6BE752C8> _pool;
21-
public Invokable_IResponseTimeoutGrain_GrainReference_6BE752C8()
21+
public Invokable_IResponseTimeoutGrain_GrainReference_6BE752C8() : this(null !)
2222
{
2323
}
2424

test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestGrainWithDifferentKeyTypes.verified.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public sealed class Invokable_IMyGrainWithGuidKey_GrainReference_8F0FEC0E : glob
1717
global::TestProject.IMyGrainWithGuidKey _target;
1818
private static readonly global::System.Reflection.MethodInfo MethodBackingField = OrleansGeneratedCodeHelper.GetMethodInfoOrDefault(typeof(global::TestProject.IMyGrainWithGuidKey), "GetGuidValue", null, null);
1919
private readonly global::Orleans.Serialization.Invocation.InvokablePool<Invokable_IMyGrainWithGuidKey_GrainReference_8F0FEC0E> _pool;
20-
public Invokable_IMyGrainWithGuidKey_GrainReference_8F0FEC0E()
20+
public Invokable_IMyGrainWithGuidKey_GrainReference_8F0FEC0E() : this(null !)
2121
{
2222
}
2323

@@ -64,7 +64,7 @@ public sealed class Invokable_IMyGrainWithStringKey_GrainReference_43570316 : gl
6464
global::TestProject.IMyGrainWithStringKey _target;
6565
private static readonly global::System.Reflection.MethodInfo MethodBackingField = OrleansGeneratedCodeHelper.GetMethodInfoOrDefault(typeof(global::TestProject.IMyGrainWithStringKey), "GetStringKey", null, null);
6666
private readonly global::Orleans.Serialization.Invocation.InvokablePool<Invokable_IMyGrainWithStringKey_GrainReference_43570316> _pool;
67-
public Invokable_IMyGrainWithStringKey_GrainReference_43570316()
67+
public Invokable_IMyGrainWithStringKey_GrainReference_43570316() : this(null !)
6868
{
6969
}
7070

@@ -111,7 +111,7 @@ public sealed class Invokable_IMyGrainWithGuidCompoundKey_GrainReference_A9FEF7A
111111
global::TestProject.IMyGrainWithGuidCompoundKey _target;
112112
private static readonly global::System.Reflection.MethodInfo MethodBackingField = OrleansGeneratedCodeHelper.GetMethodInfoOrDefault(typeof(global::TestProject.IMyGrainWithGuidCompoundKey), "GetGuidAndStringKey", null, null);
113113
private readonly global::Orleans.Serialization.Invocation.InvokablePool<Invokable_IMyGrainWithGuidCompoundKey_GrainReference_A9FEF7AF> _pool;
114-
public Invokable_IMyGrainWithGuidCompoundKey_GrainReference_A9FEF7AF()
114+
public Invokable_IMyGrainWithGuidCompoundKey_GrainReference_A9FEF7AF() : this(null !)
115115
{
116116
}
117117

@@ -158,7 +158,7 @@ public sealed class Invokable_IMyGrainWithIntegerCompoundKey_GrainReference_9814
158158
global::TestProject.IMyGrainWithIntegerCompoundKey _target;
159159
private static readonly global::System.Reflection.MethodInfo MethodBackingField = OrleansGeneratedCodeHelper.GetMethodInfoOrDefault(typeof(global::TestProject.IMyGrainWithIntegerCompoundKey), "GetIntegerAndStringKey", null, null);
160160
private readonly global::Orleans.Serialization.Invocation.InvokablePool<Invokable_IMyGrainWithIntegerCompoundKey_GrainReference_9814021A> _pool;
161-
public Invokable_IMyGrainWithIntegerCompoundKey_GrainReference_9814021A()
161+
public Invokable_IMyGrainWithIntegerCompoundKey_GrainReference_9814021A() : this(null !)
162162
{
163163
}
164164

test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestGrainWithMultipleInterfaces.verified.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public sealed class Invokable_IGrainA_GrainReference_11405B98 : global::Orleans.
1818
global::TestProject.IGrainA _target;
1919
private static readonly global::System.Reflection.MethodInfo MethodBackingField = OrleansGeneratedCodeHelper.GetMethodInfoOrDefault(typeof(global::TestProject.IGrainA), "MethodA", null, new[] { typeof(string) });
2020
private readonly global::Orleans.Serialization.Invocation.InvokablePool<Invokable_IGrainA_GrainReference_11405B98> _pool;
21-
public Invokable_IGrainA_GrainReference_11405B98()
21+
public Invokable_IGrainA_GrainReference_11405B98() : this(null !)
2222
{
2323
}
2424

@@ -93,7 +93,7 @@ public sealed class Invokable_IGrainB_GrainReference_6B5D7809 : global::Orleans.
9393
global::TestProject.IGrainB _target;
9494
private static readonly global::System.Reflection.MethodInfo MethodBackingField = OrleansGeneratedCodeHelper.GetMethodInfoOrDefault(typeof(global::TestProject.IGrainB), "MethodB", null, new[] { typeof(string) });
9595
private readonly global::Orleans.Serialization.Invocation.InvokablePool<Invokable_IGrainB_GrainReference_6B5D7809> _pool;
96-
public Invokable_IGrainB_GrainReference_6B5D7809()
96+
public Invokable_IGrainB_GrainReference_6B5D7809() : this(null !)
9797
{
9898
}
9999

0 commit comments

Comments
 (0)