sts.sl
✅ Tracking changes on a complex object provided by a third party library
Hi!
I have a third party .Net Framework dll that allows me to load a file. This file is potentially several hundreds of megabytes in size, I get a single object to manage it. It's not just a plan object, it has it's own processing threads and does complicated logic and has it's own editor. Once I'm done working with this object, I can serialize it again.
The clients request was to add change tracking to this. As it does processing with real time data, I have a bunch of rules for what is considered a change. My current solution is loading the object twice and using https://github.com/GregFinzer/Compare-Net-Objects with lots of custom rules for comparison.
I have two issues with the current approach:
1.: Memory usage. I potentially have up to 8 of these loaded, implementing change tracking on them like this might make me run out of memory.
2.: Resource usage. The object potentially needs access to physical resources. Loading it twice might cause errors where these resources can't be shared.
Ideally I'd be able to track changes to specific properties and fields instead of having two copies to compare. How would you guys approach this problem? I have plenty of change events available that are potentially enough for me to track everything, however this is a deeply nested object with potentially hundreds of types, some of them might not be known to me at compile time so ideally I'd prefer a blacklist-based approach.
10 replies