title: Duplicates in HashSet after deserialzation C#
body: <p>I have a <code>HashSet</code> as seen below:</p>
  
  <pre><code>public name {get; set; }
  
  [JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace, TypeNameHandling = TypeNameHandling.Auto)]
  public ICollection&lt;T&gt; data { get; set; }
  
  public MyClass(string name)
  {
      name = name;
      data = new HashSet&lt;T&gt;(new CustomComparer());
  }
  </code></pre>
  
  <p>The comparer looks like:</p>
  
  <pre><code>public class CustomComparer: EqualityComparer&lt;T&gt;
  {
      public override bool Equals(T x, T y)
      {
          return string.Equals(x.val, y.val, StringComparison.OrdinalIgnoreCase);
      }
  
      public override int GetHashCode(T obj)
      {
          return $"{obj?.val?.ToLowerInvariant()}-{obj?.val?.ToLowerInvariant()}".GetHashCode();
      }
  }
  </code></pre>
  
  <p>Now, I have a unit test where I first create an instance of MyClass as:</p>
  
  <pre><code>var obj1 = new MyClass("test");
  obj1.data.Add(CustomObject1);
  obj1.data.Add(CustomObject2);
  </code></pre>
  
  <p>The next step I do is serialize and deserialize the object.</p>
  
  <pre><code>var jsonSerializerSettings = new JsonSerializerSettings();         
  var serializedObject = JsonConvert.SerializeObject(obj1, jsonSerializerSettings);
  var deserializedUserObject = JsonConvert.DeserializeObject&lt;MyClass&gt;(serializedObject, jsonSerializerSettings);
  </code></pre>
  
  <p>Now, when I try to add <code>CustomObject1</code> back to the deserialized object (which is already present), it still adds to the set.</p>
  
  <p>Not sure why this is happening.
  Any leads would be helpful.</p>