From 6aed8201967a37a389390df09bc62294ce402a9c Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 30 Jan 2026 14:20:05 +0100 Subject: [PATCH] Mark TaskExtensions and new helpers as [Obsolete] Marked TaskExtensions class and all its methods as [Obsolete] with guidance to implement Mediator behaviors instead. Added new [Obsolete] extension methods for null/empty checks and chaining. Introduced an [Obsolete] Exceptions class with factory methods for common exceptions. All changes are intended for legacy or transitional use only. --- .../Common/Extensions/TaskExtensions.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/EnvelopeGenerator.Application/Common/Extensions/TaskExtensions.cs b/EnvelopeGenerator.Application/Common/Extensions/TaskExtensions.cs index a07f9706..7360675c 100644 --- a/EnvelopeGenerator.Application/Common/Extensions/TaskExtensions.cs +++ b/EnvelopeGenerator.Application/Common/Extensions/TaskExtensions.cs @@ -5,6 +5,7 @@ namespace EnvelopeGenerator.Application.Common.Extensions; /// /// Extension methods for tasks /// +[Obsolete("Implement Mediator behaviors in the Osolete .NET project.")] public static class TaskExtensions { /// @@ -17,6 +18,7 @@ public static class TaskExtensions /// Exception provider /// The awaited result if not null. /// Thrown if the result is null. + [Obsolete("Implement Mediator behaviors in the Osolete .NET project.")] public static async Task ThrowIfNull(this Task task, Func factory) where TException : Exception { var result = await task; @@ -33,6 +35,7 @@ public static class TaskExtensions /// Exception provider /// The awaited collection if it is not null or empty. /// Thrown if the result is null or empty. + [Obsolete("Implement Mediator behaviors in the Osolete .NET project.")] public static async Task> ThrowIfEmpty(this Task> task, Func factory) where TException : Exception { var result = await task; @@ -47,32 +50,46 @@ public static class TaskExtensions /// /// /// + [Obsolete("Implement Mediator behaviors in the Osolete .NET project.")] public static async Task Then(this Task task, Func act) { var res = await task; return act(res); } + + /// + /// + /// + /// + /// + /// + [Obsolete("Implement Mediator behaviors in the Osolete .NET project.")] + public static Task FirstOrDefaultAsync(this Task> task) => task.Then(t => t.FirstOrDefault()); } /// /// /// +[Obsolete("Implement Mediator behaviors in the Osolete .NET project.")] public static class Exceptions { /// /// /// + [Obsolete("Implement Mediator behaviors in the Osolete .NET project.")] public static NotFoundException NotFound() => new(); /// /// /// /// + [Obsolete("Implement Mediator behaviors in the Osolete .NET project.")] public static BadRequestException BadRequest() => new(); /// /// /// /// + [Obsolete("Implement Mediator behaviors in the Osolete .NET project.")] public static ForbiddenException Forbidden() => new(); } \ No newline at end of file