dudeNumber4
dudeNumber4

Reputation: 4687

How to set conditional breakpoint while debugging F# in Visual Studio

Consider this:

let hank = "hank"
let bill = "bill"
printfn "%A" hank  // for breakpoint

Now if I set a conditional breakpoint in VS2015, condition being "hank = bill" (assuming F# expression) I get the following error:

The condition for a breakpoint failed to execute. The condition was 'hank = bill'. The error returned was 'The breakpoint condition must evaluate to a boolean operation'.

When the condition is "hank == bill" (maybe try C# expression?) the error is:

The condition for a breakpoint failed to execute. The condition was 'hank == bill'. The error returned was 'The runtime has refused to evaluate the expression at this time.'.

Upvotes: 6

Views: 654

Answers (1)

Tomas Petricek
Tomas Petricek

Reputation: 243041

The debugger uses C# syntax for conditions in breakpoints (in all versions of F# in Visual Studio, as far as I know), so the expression to use is hank == bill. I certainly used conditional breakpoints in F# with VS 2015 - some assorted thoughts on what might help:

  • I think the debugger sometimes starts behaving oddly when you do too many things. Did you try to set the breakpoint in the second way after restarting the debugger?

  • Sometimes, setting breakpoints immediately on let is a bit odd (the compiled code first initializes the variable to defaultof<'T>). Can you try adding some no-op statement like printfn "test" and setting conditional breakpoint on that?

Upvotes: 4

Related Questions