{"id":383,"date":"2014-11-12T07:34:00","date_gmt":"2014-11-12T07:34:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2014\/11\/12\/support-for-debugging-lambda-expressions-with-visual-studio-2015\/"},"modified":"2024-02-28T15:20:43","modified_gmt":"2024-02-28T23:20:43","slug":"support-for-debugging-lambda-expressions-with-visual-studio-2015","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/support-for-debugging-lambda-expressions-with-visual-studio-2015\/","title":{"rendered":"Support for debugging lambda expressions with Visual Studio 2015"},"content":{"rendered":"<p>Anyone who uses LINQ (or lambdas in general) and the debugger will quickly discover the dreaded message \u201cExpression cannot contain lambda expressions\u201d. Lack of lambda support has been a limitation of the Visual Studio Debugger ever since Lambdas were added to C# and Visual Basic. We\u2019ve heard <a href=\"http:\/\/visualstudio.uservoice.com\/forums\/121579-visual-studio\/suggestions\/2049821-debug-lambda-expressions-planned\">your feedback<\/a> and we are pleased to announce that the debugger now supports evaluation of lambda expressions!<\/p>\n<p>Let\u2019s first look at an example, and then I\u2019ll walk you through current limitations.<\/p>\n<h3>Example<\/h3>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/11\/3527.image_thumb_462D3EA4-1.png\"><img decoding=\"async\" style=\"border-width: 0px\" title=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/11\/3527.image_thumb_462D3EA4-1.png\" alt=\"image\" width=\"783\" height=\"315\" border=\"0\" \/><\/a><\/p>\n<p>To try this yourself, create a new C# Console app with this code:<\/p>\n<pre>using System.Diagnostics;\nusing System.Linq;\n\nclass Program\n{\n    static void Main()\n    {\n        float[] values = Enumerable.Range(0, 100).Select(i =&gt; (float)i \/ 10).ToArray();\n\n        Debugger.Break();\n    }\n}<\/pre>\n<p>Then compile, start debugging, and add \u201cvalues.Where(v => (int)v == 3).ToArray()\u201d in the Watch window. You\u2019ll be happy to see the same as what the screenshot above shows you.<\/p>\n<p>NOTE: Lambda expressions that require native functions to run (e.g. LINQ-to-SQL) are not supported.<\/p>\n<h3>Summary<\/h3>\n<p>Please let us know how it works for you and what we can do to improve the experience below through the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/zzszcehe.aspx\">Send a Smile feature in Visual Studio<\/a> or <a href=\"https:\/\/twitter.com\/vs_debugger\">via twitter<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Anyone who uses LINQ (or lambdas in general) and the debugger will quickly discover the dreaded message \u201cExpression cannot contain lambda expressions\u201d. Lack of lambda support has been a limitation of the Visual Studio Debugger ever since Lambdas were added to C# and Visual Basic. We\u2019ve heard your feedback and we are pleased to announce [&hellip;]<\/p>\n","protected":false},"author":84,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,225],"tags":[],"class_list":["post-383","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","category-git"],"acf":[],"blog_post_summary":"<p>Anyone who uses LINQ (or lambdas in general) and the debugger will quickly discover the dreaded message \u201cExpression cannot contain lambda expressions\u201d. Lack of lambda support has been a limitation of the Visual Studio Debugger ever since Lambdas were added to C# and Visual Basic. We\u2019ve heard your feedback and we are pleased to announce [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/84"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=383"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/383\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}