Remove Obsolete attributes and update FirstAsync behavior
Removed Obsolete attributes from FirstAsync and Exceptions class. Changed FirstAsync return type to non-nullable Task<T> and updated its logic to throw the provided exception when the sequence is empty, instead of returning null.
This commit is contained in:
@@ -74,22 +74,19 @@ public static class TaskExtensions
|
|||||||
/// <param name="task"></param>
|
/// <param name="task"></param>
|
||||||
/// <param name="factory"></param>
|
/// <param name="factory"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Obsolete("Implement Mediator behaviors in the Osolete .NET project.")]
|
public static Task<T> FirstAsync<T, TException>(this Task<IEnumerable<T>> task, Func<TException> factory)
|
||||||
public static Task<T?> FirstAsync<T, TException>(this Task<IEnumerable<T>> task, Func<TException> factory)
|
|
||||||
where TException : Exception
|
where TException : Exception
|
||||||
=> task.Then(t => t.FirstOrDefault()) ?? throw factory();
|
=> task.Then(t => t.FirstOrDefault() ?? throw factory());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("Implement Mediator behaviors in the Osolete .NET project.")]
|
|
||||||
public static class Exceptions
|
public static class Exceptions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("Implement Mediator behaviors in the Osolete .NET project.")]
|
|
||||||
public static NotFoundException NotFound() => new();
|
public static NotFoundException NotFound() => new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user