-
Notifications
You must be signed in to change notification settings - Fork 934
Possible interface proxy unnecessary initialization #2271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
When building an interface proxy, NHibernate has currently no knowledge of the concrete class which will implement it under the hood (as a delegated state). So it cannot analyze it to determine which interface members should be implicitly implemented or not. Implementing them all implicitly could lead again to duplicated methods in the proxy, and could be invalid depending on whether the concrete class explicitly implement them or not. With an interface proxy, only the declared proxy interface id property can be considered as being the id currently. Changing this would require to transmit that concrete class to the proxy builder, which is not currently done. It may be not easy to do. And then the proxy implementation should be adjusted to generate virtual counterparts to implicitly implemented methods, instead of overrides (excepted for object instance methods like GetHashCode and Equals which would have to stay as overrides). |
I'm not sure I understand what it means. Are you saying if actual mapped entity implements both interfaces implicitly - it should work? Maybe my test is simply wrong (it's with subclasses and base class doesn't implement both interfaces) - I will double check tomorrow. But with simple example which is illustrated in this issue - should it work properly theoretically? |
Should, maybe, would, no. The technical current state of proxy generation does not allow this to work in a reliable way.
I was meaning only what matches the mapping Due to xml mapping semantic, it seems now clear to me this should be supported. But detecting it and supporting it from |
I simplified test to make it as simple as described in this issue - and issue still occurs. So I confirm it's valid issue.
It seems to me that interface proxy members can be implemented implicitly (and simply skip duplicate members). This logic should be applied strictly when proxy is interface.
I don't get this point. Isn't it already the case for interface proxy: |
Yes, but a proxy implementing interfaces implicitly will then use the same method to implement both. And by the way, how do we decide through which interface the common implicit implementation should call the corresponding method on its internal state? There will be a few hard troubles to tackle for this issue. |
Uh oh!
There was an error while loading. Please reload this page.
If proxy interface
IProxy
implements multiple interfaces with identifier property:Currently generated proxy initializes proxy
IProxy
onIReadOnlyId.Id
access:It should not trigger proxy initialization.
Possible solution: implement class for interface proxy members implicitly.
The text was updated successfully, but these errors were encountered: