Visual Studio debugging “quick watch” tool and lam

2019-01-03 13:36发布

9条回答
家丑人穷心不美
2楼-- · 2019-01-03 14:33

To answer your question, here's the Visual Studio Program Manager's official explanation of why you can't do this. In short, because "it's really, really hard" to implement in VS. But the feature is currently in progress (as updated on Aug 2014).

Allow the evaluation of lambda expressions while debugging

Add your vote while you're there!

查看更多
孤傲高冷的网名
3楼-- · 2019-01-03 14:36

Lambda expressions are not supported by the debugger's expression evaluator... which is hardly surprising since at compile time they are used to create methods (or Expression Trees) rather than expressions (take a look in Reflector with the display switched to .NET 2 to see them).

Plus of course they could form a closure, another whole layer of structure.

查看更多
疯言疯语
4楼-- · 2019-01-03 14:37

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.

查看更多
登录 后发表回答