From baabd8aca42961a8e747d7eb612f9177b2deb04e Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Mon, 9 Jun 2025 17:42:52 +0800 Subject: [PATCH] Fixing test. --- .../Scenarios/Client/TypedClient/TypedProxyTests.4.0.0.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Client/TypedClient/TypedProxyTests.4.0.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Client/TypedClient/TypedProxyTests.4.0.0.cs index 09a61318bdd..03ce5b9df0c 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Client/TypedClient/TypedProxyTests.4.0.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Client/TypedClient/TypedProxyTests.4.0.0.cs @@ -615,6 +615,10 @@ public static async Task ServiceContract_TypedProxy_Task_Call_AsyncLocal_NonCapt // Force a Gen2 GC so that the WeakReference will no longer have the OperationContextExtension as a target. GC.Collect(2); + // wait for finalizers + GC.WaitForPendingFinalizers(); + GC.Collect(2); + // *** VALIDATE *** \\ Assert.Equal(requestString, result); Assert.False(opContextReference.TryGetTarget(out OperationContextExtension opContext), "OperationContextExtension should have been collected");