3 ms·
Is there actually a way to properly debug LINQ expressions? I haven't figured out how to get Visual Studio to step through lambdas or break halfway through the
by UberMouse 13y ago
Is there actually a way to properly debug LINQ expressions? I haven't figured out how to get Visual Studio to step through lambdas or break halfway through the chain (eg break after the filter call has completed and before reduce runs in the above example).
But I'm not sure if I'm missing some blindingly obvious.
- jimmaswell 13y agoI don't know, but it just hasn't been a problem. If something's that wrong with the expression chain I can just break it up temporarily.
- jebblue 13y agoThing is though, now you've changed the recipe from what you intend to run in PROD. You linearized it to gain a debugging advantage that you lose when you re-lambdaize it.
- walljm 13y agothis probably isn't the place to start a chain on how to do this, but if you wrap the statement in the lambda in a {} block and explicitly return the expected value, you can insert line breaks and set breakpoints. i'm not familiar enough with the vocabulary to explain it perfectly, but i do it all the time. example: list.Find(o=> { if (o.prop == "foo") { return true;} // visual studio will allow a breakpoint here else { return false;} });