Skip to content

Cannot put a breakpoint on the last line of a function if it's a complex boolean expression #1390

@asik

Description

@asik

I noticed this while writing property tests with FsCheck.Xunit.
Let's say you're writing a simple property test like this:

[<Property>]
let fact seed =
    let rng = Random seed
    let a = rng.Next() % 2 = 0
    let b = rng.Next() % 2 = 0
    a && b

You cannot step or put a breakpoint on the last line (which would be nice, because you'd like to know for which reason the test is failing). This is especially annoying because Visual Studio will let you put the breakpoint, but then when you start debugging, strange things can happen like the debugger never actually breaking inside your code, or in my case, the test runner failing with cryptic errors. Wasted a lot of time figuring out what was actually going on yesterday.

A simple workaround is to bind the expression to a local and return that instead:

[<Property>]
let fact seed  =
    let rng = Random seed
    let a = rng.Next() % 2 = 0
    let b = rng.Next() % 2 = 0
    let result = a && b
    result

But I think the the compiler should do the work for me.

Tested on Visual Studio 2015 Enterprise Update 3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Debugstepping, debug points, stacks and moreBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions