title: Make two classes that are dependent on each other equatable
body: <p>I have class A:</p>
  
  <pre><code>public class A : IEquatable&lt;A&gt;
  {
      public B Owner { get; set; }
  
      public override bool Equals(object obj)
      {
          return Equals(obj as A);
      }
  
      public bool Equals([AllowNull] A other)
      {
          return other is A a &amp;&amp;
                 EqualityComparer&lt;B&gt;.Default.Equals(Owner, a.Owner);
      }
  }
  </code></pre>
  
  <p>And I have a class B:</p>
  
  <pre><code>public class B : IEquatable&lt;B&gt;
  {
      public List&lt;A&gt; Children { get; set; } = new List&lt;A&gt;();
  
      public override bool Equals(object obj)
      {
          return Equals(obj as B);
      }
  
      public bool Equals([AllowNull] B other)
      {
          return other is B b &amp;&amp;
                 EqualityComparer&lt;List&lt;A&gt;&gt;.Default.Equals(Children, b.Children);
      }
  }
  </code></pre>
  
  <p>The problem I am having is making <code>Equals()</code> methods of the above classes work. The <code>Equals()</code> methods in the example are generated by VS Code, but always return false in case of class B. </p>
  
  <p>I also tried using LINQ expressions (such as SequenceEqual method), but it always results in Stack Overflow (because of circular dependency?).</p>
  
  <p>As a side note, I used .NET Core 3.0 to run this.</p>