Hello,
Depending on the return value of LazyInitializer's Invoke(), and subsequent logic in Intercept(), the method may be invoked on the implementation object instead of the proxy. However, because of the special-casing of calls to "Dispose" within Invoke, the return value of Invoke will be null, and Dispose will not be called on the implementation. This bypasses some custom logic that we have on our objects (which perform various cleanup operations when Dispose is called on them).
So, my question is whether there is a significant risk to invoking Dispose on the implementation of a proxy? We are currently overriding LazyInitializer's Intercept, such that it passes Dispose calls on to the implementation regardless of the return value of Invoke. So far, it doesn't seem to cause any unexpected behavior, but I figured there must be some good reason for Invoke's treatment of Dispose. We're effectively ignoring Invoke's handling of Dispose, and doing the exact opposite of what it's trying to prevent.
Does anyone happen to know the reason why LazyInitializer's Invoke is coded to prevent Dispose calls from reaching the implementation?
Thanks,
-Dan
|