Reflection optimizer not used for components

Description

The class NHibernate.Tuple.Component.AbstractComponentTuplizer calls the abstract method BuildInstantiator in its constructor.
The derived class NHibernate.Tuple.Component.PocoComponentTuplizer overrides this method and has the following body:

if (optimizer == null)
return new PocoInstantiator(component, null);
return new PocoInstantiator(component, optimizer.InstantiationOptimizer);

optimizer is a field of this class and will be set in the constructor of PocoComponentTuplizer. But at the time this method is called, the constructor didn't yet run.

So, call order is like this:

AbstractComponentTuplizer..ctor -> PocoComponentTuplizer.BuildInstantiator (accesses optimizer) -> PocoComponentTuplizer..ctor (assigns value to optimizer). (That's actually the reason why Visual Studio warns about virtual method calls in constructors)

The result of this is that the reflection optimizer is not used at all to create POCO components.

Environment

None

Activity

Show:

Daniel Hilgarth March 21, 2013 at 6:31 AM

Indeed. Sorry for not searching properly before posting my report. Is there any ETA when the pull request will be merged?

cremor March 5, 2013 at 6:34 AM

This seems like a duplicate of NH-3119. A pull request is available there.

Duplicate

Details

Assignee

Reporter

Priority

Who's Looking?

Open Who's Looking?
Created March 1, 2013 at 2:01 PM
Updated May 7, 2014 at 11:07 AM
Resolved March 21, 2013 at 11:26 AM
Who's Looking?