In short:
Is there any way to provide my own Equals( object? )
method for a record struct
instead of being stuck with the one automagically generated by the compiler?
Note:
This question has nothing to do with replacing the automatically generated MyRecord.Equals( MyRecord )
method, which is trivially doable; This question is specifically about replacing the MyRecord.Equals( Object? )
method inherited from Object
, which is a whole different story.
Background:
If I want to override Equals( object? )
in plain old class
and struct
, I am free to do so; however, I cannot do it with record
; the IDE says "Member with the same signature is already declared", while the compiler gives "error CS0111: Type 'Color' already defines a member called 'Equals' with the same parameter types".
A quick look at official Microsoft documentation here and here says that this is by design.
The Question:
Does anyone know any workaround to this?
(Besides just never using record
and forfeiting all of its convenience.)