dotnet/roslyn

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

オープン

#32,492 opened on 2019/01/15

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)C# (4,257 件のフォーク)batch import
Area-InteractiveInteractive-Debugginghelp wanted

Repository metrics

Stars
 (20,414 個のスター)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

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.

コントリビューターガイド