title: How to properly customize c# record equality with inheritance
body: <p>Given the following,</p>
  <pre class="lang-cs prettyprint-override"><code>public record Foo(int Id)
  {
      public virtual bool Equals(Foo? foo)
      {
        Console.WriteLine($&quot;foo {(foo is null ? &quot;IS&quot; : &quot;is NOT&quot;)} null&quot;);
        return foo is not null &amp;&amp; Id == foo.Id;
      } 
      public override int GetHashCode() =&gt; Id.GetHashCode();
  }
  
  public record FooSummary(int Id, string Summary) : Foo(Id);
  
  public record FooDetail(int Id,  string Detail) : Foo(Id);
  
  var summary = new FooSummary(1, &quot;Summary&quot;);      
  var detail = new FooDetail(1, &quot;Detail&quot;);
  
  Console.WriteLine(detail == summary); 
  
  // Output:
  // foo IS null
  // false
  </code></pre>
  <p>Is it possible to customize record equality is such a way that <code>detail == summary</code> is <code>true</code>?</p>
  <p>In a class I could override <code>Equals(object obj)</code>, but in a record that results in a compilation error (CS0111)</p>
  <p><strong>Edit</strong><br />
  I've accepted @StriplingWarrior's answer as it technically answers my question, but as he and others have explained: this is a bad idea.  This was definitely a case of the XY problem and trying to be a little <em>too</em> clever for my own good.</p>