I want to calculate unique hashcode for Jobject. So based on so post
i am using JTokenEqualityComparer.GetHashCode(JToken token)
method to calculate the hashcode
[Fact]
public void GetHashcode()
{
JTokenEqualityComparer comp = new JTokenEqualityComparer();
// arrange
var obj1 = new JObject();
obj1.Add("FirstName", "foo");
obj1.Add("LastName", "bar");
var hashCode = comp.GetHashCode(obj1);
}
However, every-time i run this unit test it creates different hashcode. So it looks like in addition to property name and property value it use something else to calculate the hash-code.
I am using this code in ASP.NET core application. It creates unique hashcode for the JObjects with the same properties and values, however as soon as app pool gets recycled it creates new hashcode for the same JObject.
How do i create unique Hashcode for a JObject that has same properties and values?
So if there are 3 instances of JObjects that have same properties and values their hashcode should be same, regardless of machine, time and class that calcualtes the hashcode.