From 8e7643240944cba3edc2d3dbdb45fdd64bf60b51 Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Tue, 21 Feb 2023 20:41:54 +0700 Subject: [PATCH 1/2] Reintroduce old code and mark them obsolete --- .../testkits/Akka.TestKit.Xunit2/TestKit.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs b/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs index 393f553df35..bfa3583aca5 100644 --- a/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs +++ b/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs @@ -132,8 +132,19 @@ public TestKit(string config, ITestOutputHelper output = null) /// protected virtual async Task AfterAllAsync() { +#pragma warning disable CS0618 + AfterAll(); +#pragma warning restore CS0618 await ShutdownAsync(); } + + /// + /// This method is called when a test ends. + /// + [Obsolete("AfterAll() is deprecated, please use AfterAllAsync() instead")] + protected virtual void AfterAll() + { + } /// /// Initializes a new used to log messages. @@ -168,7 +179,24 @@ public virtual Task InitializeAsync() public virtual async Task DisposeAsync() { +#pragma warning disable CS0618 + Dispose(true); +#pragma warning restore CS0618 await AfterAllAsync(); } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + /// + /// if set to true the method has been called directly or indirectly by a user's code. + /// Managed and unmanaged resources will be disposed.
if set to false the method + /// has been called by the runtime from inside the finalizer and only unmanaged resources can + /// be disposed. + /// + [Obsolete("Dispose(bool) is deprecated, please use DisposeAsync() instead")] + protected virtual void Dispose(bool disposing) + { + } } } From e2bd4b07e08ab5962d532c5df4f223c7e9cdf3aa Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Tue, 21 Feb 2023 21:09:11 +0700 Subject: [PATCH 2/2] Reintroduce IDisposable --- src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs b/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs index bfa3583aca5..cdb70c8231e 100644 --- a/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs +++ b/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs @@ -21,7 +21,7 @@ namespace Akka.TestKit.Xunit2 /// This class represents an Akka.NET TestKit that uses xUnit /// as its testing framework. ///
- public class TestKit : TestKitBase, IAsyncLifetime + public class TestKit : TestKitBase, IAsyncLifetime, IDisposable { private class PrefixedOutput : ITestOutputHelper { @@ -179,10 +179,10 @@ public virtual Task InitializeAsync() public virtual async Task DisposeAsync() { + await AfterAllAsync(); #pragma warning disable CS0618 - Dispose(true); + Dispose(); #pragma warning restore CS0618 - await AfterAllAsync(); } /// @@ -198,5 +198,11 @@ public virtual async Task DisposeAsync() protected virtual void Dispose(bool disposing) { } + + [Obsolete("Dispose() is obsolete, please use DisposeAsync() instead")] + public void Dispose() + { + Dispose(true); + } } }