dotnet/roslyn

DebuggerDisplay fails when access properties in records

オープン

#48,469 opened on 2020/10/09

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

Repository metrics

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

説明

Version Used:

  • 5.0.100-rc.1.20452.10

Steps to Reproduce:

public class Program
{
    public static void Main()
    {
        var me = new Person("Phil", "Scott");
        var meWithAccessors = new PersonWithAccessors("Phil", "Scott");
        var meWithMethod = new PersonWithMethod("Phil", "Scott");

        Console.WriteLine("Hello World!");
    }

    [DebuggerDisplay("{FirstName} {LastName}")]
    record Person(string FirstName, string LastName);

    [DebuggerDisplay("{get_FirstName()} {get_LastName()}")]
    record PersonWithAccessors(string FirstName, string LastName);

    [DebuggerDisplay("{GetName(), nq}")]
    record PersonWithMethod(string FirstName, string LastName)
    {
        public string GetName() => $"{FirstName} {LastName}";
    }
}

Expected Behavior:

"Phil Scott" to be display for all three. Well, maybe not the one where I'm going directly to get accessors.

Actual Behavior:

Accesssing via the accessors and a method works fine, but receive the error Property, indexer, or event 'Program.Person.FirstName' is not supported by the language; try directly calling accessor methods 'Program.Person.get_FirstName()' or 'Program.Person.set_FirstName(?)' Property, indexer, or event 'Program.Person.LastName' is not supported by the language; try directly calling accessor methods 'Program.Person.get_LastName()' or 'Program.Person.set_LastName(?)' when going directly to the properties.

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