dotnet/roslyn

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

開放

#32,492 建立於 2019年1月15日

 (0 則留言) (0 個反應) (0 位負責人)C# (4,257 個分叉)batch import
Area-InteractiveInteractive-Debugginghelp wanted

倉庫指標

星標
 (20,414 顆星)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 256 個 PR)

描述

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.

貢獻者指南