Avoid regenerating all formatters when only one object/union/enum changes#1884
Conversation
…AvoidRegenerateAllFormatters
AArnott
left a comment
There was a problem hiding this comment.
Thank you very much for identifying this shortcoming and proposing a fix. I think we can take it, after a few issues are worked out.
There was a problem hiding this comment.
Why is this necessary?
Same question for the other additions like this.
There was a problem hiding this comment.
Sorry for the late reply. I thought GetHashCode in base class is sufficent to hash the instances and tried to avoid use every fields to hash, so I made child classes to use GetHashCode in base class.
There was a problem hiding this comment.
This is insufficient, for the same reason we need to implement our own Equals method: some fields are arrays, which don't implement by-value equality (or GetHashCode), so the default GetHashCode implementation would produce a different return value even though the content may be equal by-value. An invariant that we must hold is that GetHashCode return the same value from two objects whose Equals method returns true for each other.
AArnott
left a comment
There was a problem hiding this comment.
I added the fixes that seemed prudent. I'm ready to merge this. Thank you for your contribution.

Currently, if one object with
MessagePackObjectAttributechanges, all formatters would be regenerated because the source (FullModel) ofcontext.RegisterSourceOutputchanges. Since one generated file contains only one formatter for one object, these files can be generated separately.This PR also fixes an issue in #1874 where
SequenceEqualwas used to compareImmutableHashSet.SetEqualshould be used instead.