Skip to content

Commit eee8bd0

Browse files
authored
Fix method signature change in RuntimeContext 7.2.5 (#157)
* Fix method signature change in RuntimeContext * Proper version
1 parent 02eb74e commit eee8bd0

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

src/OrleansTestKit/OrleansTestKit.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageTags>Orleans Cloud-Computing Actor-Model Actors Distributed-Systems C# .NET Test Testing</PackageTags>
1313
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1414
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
15-
<Version>4.0.0</Version>
15+
<Version>4.0.1</Version>
1616
</PropertyGroup>
1717

1818
<PropertyGroup>
@@ -24,9 +24,9 @@
2424
<PrivateAssets>all</PrivateAssets>
2525
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2626
</PackageReference>
27-
<PackageReference Include="Microsoft.Orleans.Reminders" Version="7.2.4" />
28-
<PackageReference Include="Microsoft.Orleans.Streaming" Version="7.2.4" />
29-
<PackageReference Include="Microsoft.Orleans.Runtime" Version="7.2.4" />
27+
<PackageReference Include="Microsoft.Orleans.Reminders" Version="7.2.5" />
28+
<PackageReference Include="Microsoft.Orleans.Streaming" Version="7.2.5" />
29+
<PackageReference Include="Microsoft.Orleans.Runtime" Version="7.2.5" />
3030
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
3131
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
3232
<PrivateAssets>all</PrivateAssets>

src/OrleansTestKit/Reminders/ReminderContextHolder.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ private ReminderContextHolder()
2020
_slim = new SemaphoreSlim(1);
2121
var assembly = typeof(GrainId).Assembly;
2222
var contextType = assembly.GetType(RuntimeNamespace)!;
23-
_runtimeContextMethod = contextType.GetMethod(RuntimeMethod, BindingFlags.NonPublic | BindingFlags.Static, new Type[] { typeof(IGrainContext) })!;
23+
_runtimeContextMethod = contextType.GetMethod(RuntimeMethod,
24+
BindingFlags.NonPublic | BindingFlags.Static,
25+
new Type[] { typeof(IGrainContext), typeof(IGrainContext).MakeByRefType() })!;
2426
}
2527

2628
public static ReminderContextHolder Instance =>
@@ -33,7 +35,7 @@ public void ReleaseReminderContext()
3335
{
3436
try
3537
{
36-
_runtimeContextMethod.Invoke(null, new object?[] { null });
38+
_runtimeContextMethod.Invoke(null, new object?[] { null, null });
3739
}
3840
finally
3941
{
@@ -44,6 +46,6 @@ public void ReleaseReminderContext()
4446
public async Task SetReminderContext(IGrainContext context, CancellationToken token = default)
4547
{
4648
await _slim.WaitAsync(token);
47-
_runtimeContextMethod.Invoke(null, new object[] { context });
49+
_runtimeContextMethod.Invoke(null, new object[] { context, null });
4850
}
4951
}

src/OrleansTestKit/Utilities/RuntimeContextManager.cs

+12-7
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,33 @@ namespace Orleans.TestKit.Reminders;
55

66
internal sealed class RuntimeContextManager
77
{
8+
public delegate void SetExecutionContextDelegate(IGrainContext? newContext, out IGrainContext currentContext);
9+
810
private RuntimeContextManager()
911
{
1012
var assembly = typeof(GrainId).Assembly;
1113
var contextType = assembly.GetType("Orleans.Runtime.RuntimeContext")!;
1214

13-
SetExecutionContext = contextType
14-
.GetMethod("SetExecutionContext", BindingFlags.NonPublic | BindingFlags.Static, new Type[] { typeof(IGrainContext) })!
15-
.CreateDelegate<Action<IGrainContext?>>()
16-
;
15+
var methodInfo = contextType
16+
.GetMethod("SetExecutionContext",
17+
BindingFlags.NonPublic | BindingFlags.Static,
18+
new Type[] { typeof(IGrainContext), typeof(IGrainContext).MakeByRefType() });
19+
SetExecutionContext = methodInfo!
20+
.CreateDelegate<SetExecutionContextDelegate>()
21+
;
1722
}
1823

1924
public static RuntimeContextManager Instance { get; } = new RuntimeContextManager();
2025

21-
public Action<IGrainContext?> SetExecutionContext { get; }
26+
public SetExecutionContextDelegate SetExecutionContext { get; }
2227

2328
public static IDisposable StartExecutionContext(IGrainContext context) => new RuntimeContextScope(context);
2429

25-
public void ResetExecutionContext() => SetExecutionContext(null);
30+
public void ResetExecutionContext() => SetExecutionContext(null, out _);
2631

2732
private sealed class RuntimeContextScope : IDisposable
2833
{
29-
public RuntimeContextScope(IGrainContext context) => Instance.SetExecutionContext(context);
34+
public RuntimeContextScope(IGrainContext context) => Instance.SetExecutionContext(context, out _);
3035

3136
public void Dispose() => Instance.ResetExecutionContext();
3237
}

test/OrleansTestKit.Tests/OrleansTestKit.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="FluentAssertions" Version="6.12.0" />
1515
<PackageReference Include="Microsoft.CodeCoverage" Version="17.8.0" />
1616
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
17-
<PackageReference Include="Microsoft.Orleans.Sdk" Version="7.2.4" />
17+
<PackageReference Include="Microsoft.Orleans.Sdk" Version="7.2.5" />
1818
<PackageReference Include="NSubstitute" Version="5.1.0" />
1919
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
2020
<PackageReference Include="xunit" Version="2.6.5" />

0 commit comments

Comments
 (0)