1

Say I have the following method:

public List<List<int>> DoSomething () {
    List<List<int>> result;

    //Do some things

    return result; //Would like to breakpoint here
}

I try to have a conditional breakpoint such as:

result.Any(i => i.Any(j => j < 0))

I get an error saying you cannot have lambda expressions in conditional breakpoints. Why is that?

Adam Modlin
  • 2,994
  • 2
  • 22
  • 39
  • 7
    Because the team did not implement, test and release that feature. – Eric J. Sep 02 '14 at 18:07
  • 1
    Since the breakpoint is a debugging feature, I would imagine the same reasoning from here applies: http://stackoverflow.com/questions/725499/vs-debugging-quick-watch-tool-and-lambda-expressions. – xDaevax Sep 02 '14 at 18:09
  • 1
    Thanks @xDaevax I didn't see the question. Although, that question is 5 and a half years old so perhaps there is a more recent explanation. – Adam Modlin Sep 02 '14 at 18:11

1 Answers1

7

UPDATE: The feature has been implemented in VS2015! You can now use lambda expressions in conditional breakpoints, watches and in the immediate window.


The only answer to this question is a boring "because they did not implement the feature". I suppose the cost vs benefit of this feature was simply not worth the development time.

An alternative to a conditional breakpoint would be to add the following code

if (result.Any(i => i.Any(j => j < 0)))
    System.Diagnostics.Debugger.Break();

Not very pretty and of course you'll want to remove that once your debugging session is over but it gets the job done.

dee-see
  • 23,668
  • 5
  • 58
  • 91