Visual Studio 调试“快速观看"工具和 lambda 表达式 [英] Visual Studio debugging "quick watch" tool and lambda expressions
问题描述
为什么在快速观看"窗口中调试时不能使用 lambda 表达式?
Why can't I use lambda expressions while debugging in "Quick watch" window?
UPD:另见
http://blogs.msdn.com/b/jaredpar/archive/2009/08/26/why-no-linq-in-debugger-windows.aspx
推荐答案
Lambda 表达式,就像匿名方法一样,实际上是非常复杂的野兽.即使我们排除了 Expression
(.NET 3.5),仍然会留下很多的复杂性,尤其是被捕获的变量,这从根本上重构了使用它们的代码(你认为的变量变成了编译器生成的类上的字段),有一点烟雾和镜子.
Lambda expressions, like anonymous methods, are actually very complex beasts. Even if we rule out Expression
(.NET 3.5), that still leaves a lot of complexity, not least being captured variables, which fundamentally re-structure the code that uses them (what you think of as variables become fields on compiler-generated classes), with a bit of smoke and mirrors.
因此,您不能随意使用它们,我一点也不感到惊讶 - 很多 编译器工作(以及幕后的类型生成)支持这种魔法.
As such, I'm not in the least surprised that you can't use them idly - there is a lot of compiler work (and type generation behind the scenes) that supports this magic.
这篇关于Visual Studio 调试“快速观看"工具和 lambda 表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!