Visual Studio 2015 debugging lambda expressions

Debugging Lambda expressions is certainly a very welcome feature of Visual Studio 2015. Before when trying to evaluate lambda expressions within either the watch or immediate windows we would see the message “Expression cannot contain lambda expressions”.

The great thing about this feature is that it really speeds up the diagnoses of possible bugs being faced within your application and being able to really dig in to your collections and query the data right there and then on the fly.

For instance if you are retrieving a result set from a collection but not getting the results you are expecting, you can now query the collection using lambda expressions within either the immediate or watch window during debug to give you a direct view of what data is resident within your collection that particular point in time, from there you can then dynamically make changes to your query within the immediate or watch windows necessary to confirm your hypothesis of why you are not seeing the results you were expecting – all while in debug mode without having to perform that oh so fun process of stop debugging –> make a change –> re-run –> confirm results if yes stop else go again.

Once you confirm that you are now getting the results expected from your changes you can then go ahead an make the necessary adjustments to your source code.

This is really well demonstrated by Andrew Hall in the below video.