Use FormatterServices.GetUninitializedObject as instantiation mechanism for objects without default ctor.
Description
Environment
Activity

Nikita Govorov February 19, 2012 at 1:33 AM

Julian Maughan February 18, 2012 at 3:19 PM
I did some testing and it is true that the default constructor (if provided) is called. However, I confirmed that field initialization is not performed. Also, if I enable lazy loading in your test I get an exception thrown from the SessionFactory. This could be resolved, but unfortunately I think the need for full-trust ultimately prevents your changes from being usable.

Nikita Govorov February 14, 2012 at 10:13 AM
@Julian,
NHibernate will use default constructor if the last one exists, so current users's aplications won't be affected.

Julian Maughan February 13, 2012 at 2:34 PM
I like the idea, but surely this would represent a breaking change for many existing users? FormatterServices.GetUninitializedObject does not call the default constructor even if one exists, and it also bypasses field initialization. Combined with the need for full-trust, I don't see how we can use this pull request.

Nikita Govorov February 9, 2012 at 11:19 AM
Also as side effect, this improvement forces nhibernate to use reflection optimizer for components instead of Activator.
I guess exception you've got is related to that improvement https://nhibernate.jira.com/browse/NH-3029(which should be applied before). Of course fields initialization is not performed, because in this case we skip constructor call and expect nhibernate will set them. Just in case, I repeat, it does not require full-trust if you don't use it, in any case thanks for your time spent on this this issue.