Dispose after removal, with .DisposeMany() #732
Closed
JakenVeina
started this conversation in
Ideas
Replies: 1 comment 11 replies
-
You have the problem and the solution .... Now all you need is a unit test or two and you'll have yourself a PR! |
Beta Was this translation helpful? Give feedback.
11 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
During debugging of a disposal issue that turned out to be related to something else, I noticed that
.DisposeMany()
does not behave the way I thought it would: items being removed from collections get disposed by the operator before they are removed from downstream collections, instead of after, making it potentially possible for already-disposed items to be invoked in some way. This is due to the use of.Do()
within.DisposeMany()
.DynamicData/src/DynamicData/Cache/Internal/DisposeMany.cs
Line 34 in b3180bc
.Do()
effectively amounts to...Instead, for
.DisposeMany()
it could be...This would ensure that disposal doesn't occur until after all downstream collections have processed the removals (at least assuming there are no downstream scheduler changes, which would potentially break
.DisposeMany()
no matter what).Beta Was this translation helpful? Give feedback.
All reactions