unitycontainer / interception

Unity.Interception package
Apache License 2.0
22 stars 17 forks source link

The "PerResolve" lifetime is not properly respected when the resolving interception behaviors for an object #44

Open MikeCook9994 opened 1 year ago

MikeCook9994 commented 1 year ago

I've noticed some recent activity on these repos so I'm going to shoot my shot.

I am upgrading some code (that's an understatement) from Unity 3 to Unity 5 and have encountered what is either a bug or a significant behavioral difference regarding interception between the versions.

In Unity 5.11 (and likely earlier versions, I haven't explored deep enough to find where the issue starts), Unity will re-resolve objects registered with the "PerResolveLifetimeManager" when resolving objects needed for any defined interception behavior. I have verified that the same object will be used across the object graph for any reference that is not part of interception behavior.

Here is a test case that should demonstrate the issue. I tried another lifetime ("PerThread") to demonstrate that it does seem to specifically be an issue with "PerResolve".

UnityPerResolveInterceptionBrokenPoc.zip

I've pulled the interception repo and have been trying to uncover the issue, but I'm quite a bit out of my depth. Depending on the scope of the fix (I would have to evaluate fixing this vs other options for my team to consider), I'd be willing to submit a PR if I can get pointed in the right direction.