dotnet/roslyn
View on GitHubDebuggerDisplay fails when access properties in records
Open
#48,469 opened on Oct 9, 2020
Area-InteractiveBugFeature - Recordshelp wanted
Description
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.