Is this a bug in visual studio 2019? I'm getting a error CS0570 for a program while debugging

196 Views Asked by At

Consider the following interface and a dummy class that implements it.

interface I<out T>
{
    System.Collections.Generic.IEnumerable<T> M()
    {
        var x = default(T);
        yield return x;
    }
}

public class C : I<string>
{
    public static void Main() => System.Linq.Enumerable.Any(((I<string>)new C()).M());
}

now put a breakpoint on line 6 (yield return x). Execute the program and you'll notice something odd if you try to watch x, It tells you the following:

error CS0570: '<>x.<>m0(I.d__0)' is not supported by the language

Obviously, the program works so it is supported by the language, but the debugger has no idea what to do with it. This also happens for async (Task{T},ValueTask{T}, or IAsyncEnumerable<T>) returning methods.

Before the usual stream of comments, this is NOT my actualcode. I have an actual valid use case for using a default interface member (interface versioning), my actual method is more complicated and calls other members of the interface, but the dim is a generator method in the and debugging a poorly compliant implementer is a nightmare, and I've essentially had to resort to log messages.

0

There are 0 best solutions below