Closed MovGP0 closed 2 years ago
Given we have an id like:
[StronglyTypedId(backingType: StronglyTypedIdBackingType.Guid)] public partial struct CustomerId { }
Then the hashes of the id and the underlying type should match:
var guid = new Guid("d5d21f3b-2d6d-45ee-a1b7-bb9cc65e55c6") var id = new CustomerId(guid); Assert.Equal(guid.GetHash(), id.GetHash());
This is important when migrating existing code/tests to strongly typed ids.
Remarks: Currently the hash code changes when a different set of StronglyTypedIdConverter is defined.
StronglyTypedIdConverter
This is already how it works I think? 🤔 the ID calls GetHashCode() on the backing value?
GetHashCode()
https://github.com/andrewlock/StronglyTypedId/blob/master/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns%3DSome.Namespace_converter%3D10_backingType%3DInt.verified.txt#L31
Given we have an id like:
Then the hashes of the id and the underlying type should match:
This is important when migrating existing code/tests to strongly typed ids.
Remarks: Currently the hash code changes when a different set of
StronglyTypedIdConverter
is defined.