Support for debugging lambda expressions with Visual Studio 2015
Anyone who uses LINQ (or lambdas in general) and the debugger will quickly discover the dreaded message “Expression cannot contain lambda expressions”. Lack of lambda support has been a limitation of the Visual Studio Debugger ever since Lambdas were added to C# and Visual Basic. We’ve heard your feedback and we are pleased to announce that the debugger now supports evaluation of lambda expressions!
Let’s first look at an example, and then I’ll walk you through current limitations.
To try this yourself, create a new C# Console app with this code:
static void Main()
float values = Enumerable.Range(0, 100).Select(i => (float)i / 10).ToArray();
Then compile, start debugging, and add “values.Where(v => (int)v == 3).ToArray()” in the Watch window. You’ll be happy to see the same as what the screenshot above shows you.
NOTE: Lambda expressions that require native functions to run (e.g. LINQ-to-SQL) are not supported.