From 12f4bf88288c52fb8dc85de92e8982e5575269d8 Mon Sep 17 00:00:00 2001 From: TekH Date: Wed, 20 May 2026 13:21:01 +0200 Subject: [PATCH] Mark TaskSyncExtensions methods as obsolete The `TaskSyncExtensions` class and its methods (`Sync` and `Sync`) have been marked as `[System.Obsolete]`. These methods are no longer recommended due to the risk of deadlocks and unexpected behavior caused by synchronous blocking. Developers are advised to use `async/await` patterns instead. The warning messages indicate that these methods will be removed in a future release. --- src/ReC.Client/TaskSyncExtensions.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ReC.Client/TaskSyncExtensions.cs b/src/ReC.Client/TaskSyncExtensions.cs index 2effd36..e9edcad 100644 --- a/src/ReC.Client/TaskSyncExtensions.cs +++ b/src/ReC.Client/TaskSyncExtensions.cs @@ -7,12 +7,14 @@ namespace ReC.Client /// /// Provides synchronous wrappers for Task-based operations. /// + [System.Obsolete("Synchronous blocking helpers (Task.Sync) are no longer recommended. These methods can cause deadlocks or unexpected behavior. Rewrite calling code to use async/await (e.g. async Task tests). This helper class will be removed in a future release.", false)] public static class TaskSyncExtensions { /// /// Blocks until the task completes and propagates any exception. /// /// The task to wait for. + [System.Obsolete("Use async/await instead of synchronous blocking. This method can cause deadlocks.", false)] public static void Sync(this Task task) => task.ConfigureAwait(false).GetAwaiter().GetResult(); /// @@ -21,6 +23,7 @@ namespace ReC.Client /// The type of the task result. /// The task to wait for. /// The result of the completed task. + [System.Obsolete("Use async/await instead of synchronous blocking. This method can cause deadlocks.", false)] public static TResult Sync(this Task task) => task.ConfigureAwait(false).GetAwaiter().GetResult(); } } \ No newline at end of file