Skip to content

Instantly share code, notes, and snippets.

@ycherkes
Last active February 16, 2024 07:10
Show Gist options
  • Save ycherkes/0f92a01a636407e297443c8db7a802dc to your computer and use it in GitHub Desktop.
Save ycherkes/0f92a01a636407e297443c8db7a802dc to your computer and use it in GitHub Desktop.
Circular reference detection. Why GetHashCode is not valid in this case.
var og = new ObjectIDGenerator();
var a = new { Name = "A" };
var b= new {Name = "A"};
var c = a;
var aid = og.GetId(a, out var firstTime);
var bid = og.GetId(b, out firstTime);
var cid = og.GetId(c, out firstTime);
var aHashCode = a.GetHashCode();
var bHashCode = b.GetHashCode();
var cHashCode = c.GetHashCode();
Console.WriteLine("Hello, World!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment