diff --git a/src/OrleansTestKit/OrleansTestKit.csproj b/src/OrleansTestKit/OrleansTestKit.csproj index 1940da3..545b724 100644 --- a/src/OrleansTestKit/OrleansTestKit.csproj +++ b/src/OrleansTestKit/OrleansTestKit.csproj @@ -1,4 +1,4 @@ - + @@ -12,7 +12,7 @@ Orleans Cloud-Computing Actor-Model Actors Distributed-Systems C# .NET Test Testing true snupkg - 8.0.0 + 8.1.0 @@ -24,9 +24,9 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + runtime; build; native; contentfiles; analyzers all diff --git a/src/OrleansTestKit/Reminders/ReminderContextHolder.cs b/src/OrleansTestKit/Reminders/ReminderContextHolder.cs index 73764f2..becd4b5 100644 --- a/src/OrleansTestKit/Reminders/ReminderContextHolder.cs +++ b/src/OrleansTestKit/Reminders/ReminderContextHolder.cs @@ -20,7 +20,7 @@ private ReminderContextHolder() _slim = new SemaphoreSlim(1); var assembly = typeof(GrainId).Assembly; var contextType = assembly.GetType(RuntimeNamespace)!; - _runtimeContextMethod = contextType.GetMethod(RuntimeMethod, BindingFlags.NonPublic | BindingFlags.Static, new Type[] { typeof(IGrainContext) })!; + _runtimeContextMethod = contextType.GetMethod(RuntimeMethod, BindingFlags.NonPublic | BindingFlags.Static)!; } public static ReminderContextHolder Instance => @@ -33,7 +33,7 @@ public void ReleaseReminderContext() { try { - _runtimeContextMethod.Invoke(null, new object?[] { null }); + _runtimeContextMethod.Invoke(null, new object?[] { null, null }); } finally { @@ -44,6 +44,6 @@ public void ReleaseReminderContext() public async Task SetReminderContext(IGrainContext context, CancellationToken token = default) { await _slim.WaitAsync(token); - _runtimeContextMethod.Invoke(null, new object[] { context }); + _runtimeContextMethod.Invoke(null, new object?[] { context, null }); } } diff --git a/src/OrleansTestKit/Utilities/RuntimeContextManager.cs b/src/OrleansTestKit/Utilities/RuntimeContextManager.cs index bfe7bf1..5270ddf 100644 --- a/src/OrleansTestKit/Utilities/RuntimeContextManager.cs +++ b/src/OrleansTestKit/Utilities/RuntimeContextManager.cs @@ -5,28 +5,30 @@ namespace Orleans.TestKit.Reminders; internal sealed class RuntimeContextManager { + public delegate void SetExecutionContextAction(IGrainContext? newContext, out IGrainContext currentContext); + private RuntimeContextManager() { var assembly = typeof(GrainId).Assembly; var contextType = assembly.GetType("Orleans.Runtime.RuntimeContext")!; SetExecutionContext = contextType - .GetMethod("SetExecutionContext", BindingFlags.NonPublic | BindingFlags.Static, new Type[] { typeof(IGrainContext) })! - .CreateDelegate>() + .GetMethod("SetExecutionContext", BindingFlags.NonPublic | BindingFlags.Static)! + .CreateDelegate() ; } public static RuntimeContextManager Instance { get; } = new RuntimeContextManager(); - public Action SetExecutionContext { get; } + public SetExecutionContextAction SetExecutionContext { get; } public static IDisposable StartExecutionContext(IGrainContext context) => new RuntimeContextScope(context); - public void ResetExecutionContext() => SetExecutionContext(null); + public void ResetExecutionContext() => SetExecutionContext(null, out _); private sealed class RuntimeContextScope : IDisposable { - public RuntimeContextScope(IGrainContext context) => Instance.SetExecutionContext(context); + public RuntimeContextScope(IGrainContext context) => Instance.SetExecutionContext(context, out _); public void Dispose() => Instance.ResetExecutionContext(); } diff --git a/test/OrleansTestKit.Tests/OrleansTestKit.Tests.csproj b/test/OrleansTestKit.Tests/OrleansTestKit.Tests.csproj index 7c76e58..9dd68db 100644 --- a/test/OrleansTestKit.Tests/OrleansTestKit.Tests.csproj +++ b/test/OrleansTestKit.Tests/OrleansTestKit.Tests.csproj @@ -14,7 +14,7 @@ - +