DefaultProxyFactory does not call parameterless constructor of the parent type when instantiating proxies

Description

The DefineConstructor method in ProxyFactory.cs generates IL to call "baseConstructor", however this is always the default constructor of System.Object and no the parentType. Some POCOs may have basic initialization in the constructor that is now broken with this change. Our existing system, coming from NH 2.1 is unable to function with this new behavior.

Unit test will be forthcoming to demonstrate issue.

Environment

None

Attachments

1

is related to

Activity

Show:

Patrick Earl 
September 20, 2011 at 3:51 PM

Closed as requested by reporter.

As a random note for the future, why would the proxy object need to be initialized anyways? It's just going to pass calls to the properly initialized instance.

Stuart Carnie 
September 8, 2011 at 4:49 AM

A pull request has been submitted for this fix: https://github.com/nhibernate/nhibernate-core/pull/7

Stuart Carnie 
September 6, 2011 at 5:22 PM

Not without a lot of work and introspection. It is no different to the existing proxy factories of pre NHibernate 3.2. The default constructor should not cause any side effects.

cremor 
September 5, 2011 at 7:56 AM

What happens if the constructor calls virtual methods or properties? E.g. assigning empty collections to automatic C# properties needs to assign the public virtual property. Will there be any code that assures that the proxy is NOT loaded in that case?

Stuart Carnie 
September 2, 2011 at 10:23 PM

test case

Won't Fix

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created September 2, 2011 at 12:31 AM
Updated September 20, 2011 at 3:51 PM
Resolved September 20, 2011 at 3:51 PM
Who's Looking?