Add refactorings to explicitly generate implicit record members
#81126 opened on Nov 10, 2025
Description
Summary
Add refactorings that will explicitly create implicitly declared record members, like ToString, PrintMembers etc.
Background and Motivation
Records declare implicitly some members that we can override with our own logic, which are Equals(T), GetHashCode, ToString and PrintMembers.
However, when the logic needs to be overridden, one has to write these methods from scratch, even if just changing equality logic for a single property or changing the way one member is printed in PrintMembers.
Proposed Feature
Add refactorings for each of the overridable record's implicitly declared methods that would generate them explicitly. Generated methods should do the same as the implicit ones do. It will make it easier to override logic as we'd have the original method that we'd be able to augment instead of writing from scratch.
Alternative Designs
This can still be done manually. For some cases of overriding Equals you could go with making a wrapper type for the value involved which defines it's own equality.
Also, a source generator could be created that helps managing these methods, but this is something that wouldn't be done in roslyn.