-
Notifications
You must be signed in to change notification settings - Fork 934
Generate a correct proxy for interfaces #1728
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
Generate a correct proxy for interfaces #1728
Conversation
Static proxies generated for interfaces were incorrectly attempting to call the base "interface implementation". And they were all sharing the same type name.
What was the error? Is it even possible to get null |
Ok, found the answer to my second question here:
|
When I attempted re-implementing the lazy property proxy as a delegating proxy, I had to debug that trouble. Some tests where triggering it. I have not checked if removing that from the entity proxy would also cause some tests to start failing for the same reason. But since lazy entity proxies are used in many more tests than lazy property proxies, I am confident it would. |
The error fixed by this PR is invalid IL (failing PeVerify) generated for proxies on interface. These proxies were still usable, because the invalid code path was never executed (since in the interface case, there is no base constructor able of calling virtual members re-implemented by the proxy). But better generate correct proxies. |
Previously it was failing PEVerify similarly to nhibernate#1728 but for abstract classes (this is possible in case of a polymorphic entities). Unlike interfaces the abstract base class can go into a situation when lazy initializer is not yet available, eg. code in a constructor.
Previously it was failing PEVerify similarly to nhibernate#1728 but for abstract classes (this is possible in case of a polymorphic entities). Unlike interfaces the abstract base class can go into a situation when lazy initializer is not yet available, eg. code in a constructor.
Previously it was failing PEVerify similarly to nhibernate#1728 but for abstract classes (this is possible in case of a polymorphic entities). Unlike interfaces the abstract base class can go into a situation when lazy initializer is not yet available, eg. code in a constructor.
#1884) Previously it was failing PEVerify similarly to #1728 but for abstract classes (this is possible in case of a polymorphic entities). Unlike interfaces the abstract base class can go into a situation when lazy initializer is not yet available, eg. code in a constructor. Also test the explicit interface case, check access into constructor, and check proxy on type with interfaces. And correctly call explicit interface methods of base type
Static proxies generated for interfaces were incorrectly attempting to call the base "interface implementation", causing a PeVerify failure (but no runtime failure, the invalid code being on a never executed path). And they were all sharing the same type name.
(This flaw is also present in the dynamic proxy, but probably since its debut. Being now obsoleted, I do not intend to fix it.)