BinaryFormatter.Serialize output changes between Rhino minor versions

As I’m calculating a hash for a given geometry I’ve noticed that the hash changes with new Rhino updates.

The input to my hash function is based on the bytes generated by BinaryFormatter.Serialize as such:

public string GetHashForGeometry(GeometryBase src){
  byte[] rc = null;
  var formatter = new BinaryFormatter();
  using (var stream = new MemoryStream())
  {
      formatter.Serialize(stream, src);
      rc = stream.ToArray();
  }
  
  return CalclulateHash(rc);
}

Can I somehow disregard the Rhino version info that seems to be a part of the GeometryBase object?

Hi @ia1,

No, there is not.

If you are looking for a quick an easy way to determine if two objects are not identical, then you might try using the new GeometryBase.DataCRC method that will appear in the Rhino 7 SR20 release candidate, which should be released this week.

https://mcneel.myjetbrains.com/youtrack/issue/RH-68961

– Dale