Skip to content

The test StartAsTaskCancellation contains a Debugger.Break(), can it be removed safely? #3605

@abelbraaksma

Description

@abelbraaksma

My test runner hiccups on Debugger.Break() in tests (not surprisingly, a normal executable would do too). I was wondering if this break is intentional and serves a purpose, or was left their as a remnant of some temporary debugging situation.

Also, the |> ignore is redundant.

The test:

    [<Test>]
    member this.StartAsTaskCancellation () =
        let cts = new CancellationTokenSource()
        let tcs = TaskCompletionSource<unit>()
        let a = async {
            cts.CancelAfter (100)
            do! tcs.Task |> Async.AwaitTask }
#if FSCORE_PORTABLE_NEW || coreclr
        let t : Task<unit> =
#else
        use t : Task<unit> =
#endif
            Async.StartAsTask(a, cancellationToken = cts.Token)

        // Should not finish
        try
            let result = t.Wait(300)
            Assert.IsFalse (result)
        with :? AggregateException -> Assert.Fail "Task should not finish, jet"

        tcs.SetCanceled()
        
        try
            this.WaitASec t
        with :? AggregateException as a ->
            match a.InnerException with
            | :? TaskCanceledException as t -> ()
            | _ -> reraise()
        System.Diagnostics.Debugger.Break() |> ignore
        Assert.IsTrue (t.IsCompleted, "Task is not completed")

I can remove this line if nobody objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions