Skip to content

NOT READY FOR PULL - You'll want to review the change set and integrate the way you see fit. #2

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

Closed
wants to merge 2 commits into from

Conversation

ranzlee
Copy link

@ranzlee ranzlee commented Aug 25, 2011

NH 3.2 has a bug in the default proxy factory (not sure if it's been reported). The generated proxy assembly does not pass peverify because the proxy type constructor calls object::ctor instead of the base type (entity) constructor. This means that lazy loads are limited to full-trust policy.

I fixed the proxy factory to emit call the "real" base type constructor, but this would have the side-effect of preventing constructor DI in entities. Then I added a new provider and contract (DefaultEntityInjector and IEntityInjector) so that DI is supported out-of-box by providing an implementation. The implementation simply needs to provide the constructor arguments for NH's call to Activator.CreateInstance.

I added a test project that demonstrates default constructor, interface based proxy, and non-default constructor cats. Also, peverify reports zero errors on the dynamic assembly. This has also been tested in a pseudo-medium trust environment. The required reflection permissions above default medium are emit & protected member access.

Please take a look when you have time (randy.w.lee@gmail.com or @ranzlee)

Thanks much!

P.S. I only modified the lightweight bytecode provider logic. Haven't even looked at code dom...

…call

to object constructor instead of base type constructor.  This was
causing verification exception with non-full trust policy.

Added IEntityInjector as a provider to support non-default constructor
entities for DI scenarios.  NH still makes the Activator.CreateInstance
call, but uses the constructor parms provided by the IEntityInjector
implementation.
@patearl
Copy link
Member

patearl commented Aug 25, 2011

Please submit an issue linking to this pull request.

@rippo
Copy link

rippo commented Aug 25, 2011

Hi Patrick, where is best place to submit an issue? https://nhibernate.jira.com ??

@julian-maughan
Copy link
Member

Yes, rippo, on the JIRA bug tracker please

@rippo
Copy link

rippo commented Aug 25, 2011

Added issue at https://nhibernate.jira.com/browse/NH-2857
Thanks

@patearl
Copy link
Member

patearl commented Sep 27, 2011

Since this request is not intended to be integrated, I'm going to close it. Would be good for discussion to continue in the JIRA issue.

@patearl patearl closed this Sep 27, 2011
hazzik added a commit that referenced this pull request Aug 5, 2016
hazzik referenced this pull request in ngbrown-forks/nhibernate-core Mar 17, 2017
# This is the 1st commit message:

NH-3807 - Took care of most of the GetTypeInfo() needs.
Added TypeReflectionExtensions for CoreClr use.

# The commit message #2 will be skipped:

# fixup! NH-3807 - Took care of most of the GetTypeInfo() needs. Added TypeReflectionExtensions for CoreClr use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants