SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

Implement IEquatable<Self> for all [SpacetimeDB.Type]s

Open kazimuth opened this issue 10 months ago • 2 comments

Description of Changes

Fixes issue identified in https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk/pull/264 by implementing IEquatable<Self> for all [SpacetimeDB.Type]s in C#. Also overrides GetHashCode() and ToString() for these types, which should be helpful if users want to use them as hash map keys or print them.

Ready for review.

API and ABI breaking changes

Technically API breaking, since it is possible users manually implemented IEquatable somewhere. It's an easy fix though.

This also uses #nullable enable and #nullable restore in the generated code. This requires a version of Unity supporting C# 8. But I believe we already required this.

Expected complexity level and risk

2: this is a slightly-tricky algorithm to implement due to some pitfalls in C#'s type system.

Testing

  • [x] Get all C# module stuff compiling
  • [x] Add equality proptests for a wide variety of types
  • [x] Test that that SDK bug is fixed
  • [ ] Test quickstart-chat
  • [ ] Test blackholio

kazimuth avatar Mar 07 '25 21:03 kazimuth

I don't know the C# sdk well enough to be able to review this change sufficiently. I've reviewed the repro, and so I'm satisfied as long as it fixes the repro test, but I think @rekhoff will be able to give this a much better review.

joshua-spacetime avatar Mar 11 '25 21:03 joshua-spacetime

There is a decent amount going on here, I don't see any clear issues, and what I see makes sense. It looks like the quickstart-chat and blackholio haven't been manually tested with these changes, which would be good to do. I'm going to hold off on my approval until after I get these tested.

rekhoff avatar Mar 11 '25 22:03 rekhoff