You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(I'm not sure whether this is the correct repo for this issue)
Given two records Parent and Child, where Parent overrides the ToString method. When I call ToString on an instance of Child, ToString of Parent is not called. Instead, the one of object seems to be used.
If the C# language were changed so that the compiler does not generate a ToString() override in record Child when its base class is record Parent, then the generated Parent.ToString() method would also have to be changed not to hardcode the "Parent" name in the output. I didn't find any discussion about that in dotnet/csharplang#39 nor in the language design meetings linked from there. At this point, it would be a breaking change.
Describe the bug
(I'm not sure whether this is the correct repo for this issue)
Given two records
Parent
andChild
, whereParent
overrides theToString
method. When I callToString
on an instance ofChild
,ToString
ofParent
is not called. Instead, the one ofobject
seems to be used.To Reproduce
Given the following code:
I would expect the following test to succeed:
But it fails for the following reason:
When debugging this, I noticed that
ToString
ofParent
is never called.This can be "fixed" by overriding the
ToString
method inChild
as well:But I refuse to believe that's how it's supposed to work.
Further technical details
The text was updated successfully, but these errors were encountered: