@@ -39,19 +39,6 @@ module Task =
3939 /// <returns >A Task that is completed successfully with the specified value.</returns >
4040 let result ( value : 'T ) : Task < 'T > = Task.FromResult value
4141
42-
43- /// <summary >Creates a Task that's completed unsuccessfully with the specified exception.</summary >
44- /// <param name =" exn " >The exception to be raised.</param >
45- /// <returns >A Task that is completed unsuccessfully with the specified exception.</returns >
46- let raise < 'T > ( exn : exn ) : Task < 'T > =
47- #if NET5_ 0_ OR_ GREATER
48- Task.FromException< 'T> exn
49- #else
50- let tcs = TaskCompletionSource< 'T> tcsOptions
51- tcs.SetException exn
52- tcs.Task
53- #endif
54-
5542 /// <summary >Creates a Task that's completed unsuccessfully with the specified exceptions.</summary >
5643 /// <param name =" aex " >The AggregateException to be raised.</param >
5744 /// <returns >A Task that is completed unsuccessfully with the specified exceptions.</returns >
@@ -483,14 +470,30 @@ module Task =
483470 /// <param name =" source " >The source task.</param >
484471 /// <returns >A successful resulting task.</returns >
485472 /// <remarks >The result is always a successful task, unless the mapping function itself throws an exception.</remarks >
473+ #if ! NET45
474+ let inline recover ( [<InlineIfLambda>] mapper : exn -> 'T ) ( source : Task < 'T >) : Task < 'T > =
475+ #else
486476 let inline recover ( mapper : exn -> 'T ) ( source : Task < 'T >) : Task < 'T > =
477+ #endif
487478 #if ! NET45
488479 let source = nullArgCheck ( nameof source) source
489480 #else
490481 raiseIfNull " source" source
491482 #endif
492483
493- tryWith ( fun () -> source) ( mapper >> result)
484+ tryWith ( fun () -> source) ( mapper >> Task.FromResult)
485+
486+ /// <summary >Creates a Task that's completed unsuccessfully with the specified exception.</summary >
487+ /// <param name =" exn " >The exception to be raised.</param >
488+ /// <returns >A Task that is completed unsuccessfully with the specified exception.</returns >
489+ let raise < 'T > ( exn : exn ) : Task < 'T > =
490+ #if NET5_ 0_ OR_ GREATER
491+ Task.FromException< 'T> exn
492+ #else
493+ let tcs = TaskCompletionSource< 'T> tcsOptions
494+ tcs.SetException exn
495+ tcs.Task
496+ #endif
494497
495498 /// <summary >Maps the exception of a faulted task to another exception.</summary >
496499 /// <param name =" mapper " >Mapping function from exception to exception.</param >
@@ -525,8 +528,6 @@ module Task =
525528 match source with
526529 | Ok x -> result x
527530 | Error exn -> raise exn
528-
529-
530531/// Workaround to fix signatures without breaking binary compatibility.
531532[<AutoOpen>]
532533module Task_v2 =
0 commit comments