dotnet / dotnet/roslyn

Record synthesized implementation of PrintMembers calls object overload for string

Open
#78,339 7 comments 0 reactions 1 assignee Assigned to @RikkiGibson View on GitHub
Area-Compilers Feature - Records
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

See https://godbolt.org/z/c7cGhGoK1. I can't tell if this is a spec bug or a product bug. The spec seems to imply that the record implementation of PrintMembers should call

```C#
protected virtual bool PrintMembers(StringBuilder builder)
{
builder.Append(nameof(P1));
builder.Append(" = ");
builder.Append(this.P1);

return true;
}
```

In the case that `P1` is a string, overload resolution would pick the `string` overload. Instead it calls the object overload.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.