dotnet/roslyn

C# EE: The type of hoisted dynamic variables displayed as object

Offen

#32.492 geöffnet am 15.01.2019

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (4.257 Forks)batch import
Area-InteractiveInteractive-Debugginghelp wanted

Repository-Metriken

Stars
 (20.414 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)

Beschreibung

Step thru Main and M methods. In Main the type of e is displayed as dynamic in Locals window. In M the type of d is object. It should be dynamic as well.

using System;
using System.Linq;
using System.Collections.Generic;

class C
{
    static IEnumerable<int> M()
    {
        dynamic d = 1;
        yield return d;
        Console.WriteLine(d);
    }

    public static void Main()
    {
        dynamic e = 1;
        M().ToArray();
    }
}

We should put DynamicAttribute on the lifted fields, or add and use dynamic variable CDI to the iterator method.

Contributor Guide