Description
Hi Daniel,
First of all, thanks a lot for the awesome library! We've been using it in open-source Spinnaker for over a year now with great results.
I think I may have run into a corner case. We are configuring a differ in Kotlin like so:
val differ: ObjectDiffer = ObjectDifferBuilder
.startBuilding()
.apply {
comparison().ofType(Instant::class.java).toUseEqualsMethod()
inclusion().resolveUsing(object : InclusionResolver {
override fun getInclusion(node: DiffNode): Inclusion =
if (node.getPropertyAnnotation<ExcludedFromDiff>() != null) EXCLUDED else INCLUDED
override fun enablesStrictIncludeMode() = false
})
}
.build()
This allows us to use a @ExcludedFromDiff
annotation to exclude unwanted properties from the diff. This normally works just fine, but I came across a case where, if the objects with excluded fields are part of a collection, and I compare the collection itself, the differ reports a state of CHANGED
instead of the expected UNTOUCHED
.
For example, this comparison reports UNTOUCHED
:
data class MyObject(
@get:ExcludedFromDiff
val prop: String
)
val base = MyObject("test")
differ.compare(base, base.copy(prop = "whatever"))
But this comparison reports CHANGED
:
differ.compare(setOf(base), setOf(base.copy(prop = "whatever")))
I've tried my best to debug the issue, but failed. If you have any insights and could at least confirm whether you think this might be a bug and whether there's any workaround in version 0.95, that would be greatly appreciated!