Record types sythetic PrintMembers delegates to synthetic overridable PrintMember #6690
Unanswered
drdamour
asked this question in
Language Ideas
Replies: 1 comment 2 replies
-
Yup. And we explicitly decided that was the way we felt was great for them ecosystem here. Sorry! |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Been loving record types really great for client/server interactions and command/event. The ToString is awesome for quick log/dumping. But i find overriding PrtingMembers to consistently be a pain because i have to take over everything pretty much. Often i just want to make sure a single IEnumerable property dumps the way i want.
If there was one more layer of indirection in the synthetic generation it would make this way easier. If PrintMembers delegated to a PrintMember(StringBuilder, string memberName) or maybe even a PrintMember(StringBuilder, string memberName, object? value) i could easily switch expression the construction for my special members. Could even see there being a static method somewhere in runtime to do the default output.
i think this would be compatible because anyone who has overridden ToString or PrintMembers wouldnt be affected. If they already added a PrintMember method with same signature that could be an issue as they would already replace the synthetic print.
Im guessing i can leverage source generators to create my own PrintMembers at compile time as a different way of solving my goal but this indirection seems simpler.
Beta Was this translation helpful? Give feedback.
All reactions