Skip to content

Commit

Permalink
?
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmaturtle committed Jul 1, 2023
1 parent 5697937 commit 4869c93
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/Hedgehog.Xunit/InternalLogic.fs
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,13 @@ let rec yieldAndCheckReturnValue (x: obj) =
match x with
| :? bool as b -> if not b then TestReturnedFalseException() |> raise
| :? Task<unit> as t -> Async.AwaitTask t |> yieldAndCheckReturnValue
| :? Task<bool> as t -> Async.AwaitTask t |> yieldAndCheckReturnValue
| _ when x <> null && x.GetType().IsGenericType && x.GetType().GetGenericTypeDefinition().IsSubclassOf typeof<Task> ->
let genType = x.GetType().GetGenericTypeDefinition()
if not genType.ContainsGenericParameters then
let t = x :?> Task
Async.AwaitTask t |> yieldAndCheckReturnValue
else
typeof<Async>
.GetMethods()
.First(fun x -> x.Name = "AwaitTask" && x.IsGenericMethod)
.MakeGenericMethod(x.GetType().GetGenericArguments())
.Invoke(null, [|x|])
|> yieldAndCheckReturnValue
typeof<Async>
.GetMethods()
.First(fun x -> x.Name = "AwaitTask" && x.IsGenericMethod)
.MakeGenericMethod(x.GetType().GetGenericArguments())
.Invoke(null, [|x|])
|> yieldAndCheckReturnValue
| :? Task as t -> Async.AwaitTask t |> yieldAndCheckReturnValue
| :? Async<unit> as a -> Async.RunSynchronously(a, cancellationToken = CancellationToken.None) |> yieldAndCheckReturnValue
| _ when x <> null && x.GetType().IsGenericType && x.GetType().GetGenericTypeDefinition() = typedefof<Async<_>> ->
Expand Down

0 comments on commit 4869c93

Please sign in to comment.