Roslyn: LINQ debugging is total crap

Created on 17 Feb 2019  路  4Comments  路  Source: dotnet/roslyn

The tite says it...

Really love LINQ, it produces a really clean and nice code.

But it can't be used when debugging is so bad.
So gotta convert it all to loops to be able to debug.

Please, please fix this.

_This issue has been moved from https://developercommunity.visualstudio.com/content/problem/433733/linq-debugging-is-total-crap.html
VSTS ticketId: 776232_
_These are the original issue comments:_
(no comments)
_These are the original issue solutions:_
(no solutions)

Area-Interactive Bug Developer Community Interactive-Debugging

Most helpful comment

Sad to hear you don't like to debug LINQ, many have issues with it.
I'd suggest to use an extension method like this one, makes it easier to debug somewhat.

Another suggestion is to use breakpoints set to print to Output rather than break execution, this has helped me a lot.

public static class IEnumerableExtensions
{
    public static IEnumerable<T> Pipe<T>(this IEnumerable<T> src, Action<T> action)
    {
        foreach (T item in src)
        {
            action(item);
            yield return item;
        }
    }
}

All 4 comments

Sad to hear you don't like to debug LINQ, many have issues with it.
I'd suggest to use an extension method like this one, makes it easier to debug somewhat.

Another suggestion is to use breakpoints set to print to Output rather than break execution, this has helped me a lot.

public static class IEnumerableExtensions
{
    public static IEnumerable<T> Pipe<T>(this IEnumerable<T> src, Action<T> action)
    {
        foreach (T item in src)
        {
            action(item);
            yield return item;
        }
    }
}

Just as an FYI - OzCode, which is a commercial VS extension I founded, has created a LINQ Debugging experience which is described in this post. You can find an equivalent of Microsot's 101 LINQ Sample demonstrated using OzCode's visualization here.

cc @tmat

It seems to me that LINQ debugging works quite well now. Here's a quick recording showing that using some example of LINQ on VS 2019 version 16.7:

Was this page helpful?
0 / 5 - 0 ratings