I think that you are making too many suppositions instead try it.
1) LinFu is not the embedded DynProxy. It was the start point, but as some
committer known ;), was not a matter of just copy&paste
2) LinFu and the embedded DynProxy... well... code
protected virtual System.Type GetUnproxyType()
{
return GetType();
}
public virtual System.Type GetMyType()
{
return GetUnproxyType();
}
Console.WriteLine(proxy.GetMyType()); <= returns the correct type
Other
private System.Type GetUnproxyType()
{
return GetType();
}
public virtual System.Type GetMyType()
{
return GetUnproxyType();
}
Returns the correct type
Other
private System.Type GetUnproxyType()
{
return GetType();
}
public override bool Equals(object obj)
{
return GetUnproxyType() == obj.GetType();
}
var factory = new ProxyFactory();
var c =
(ClassWithVarietyOfMembers)factory.CreateProxy(typeof(ClassWithVarietyOfMembers),
new PassThroughInterceptor(new ClassWithVarietyOfMembers()), null);
c.Equals(new ClassWithVarietyOfMembers()).Should().Be.True();
Pass the test
On Wed, Apr 20, 2011 at 10:18 AM, cremor <[email protected]> wrote:
> Seems like I mixed up some things here, sorry about that.
> The NHibernate 3.0 Cookbook uses a private method. I have never tried
> that, maybe it worked with Castle. If yes it's a possible breaking
> change.
> The Sharp-Architecture code uses a protected virtual method. That
> worked with Castle (and maybe Spring) but didn't work with LinFu
> (because LinFu didn't proxy protected methods). I assume most people
> don't even know that LinFu didn't proxy protected methods, so no need
> to mention this as breaking change.
>
> But I still think that the new default ProxyFactory should be more
> visible in the release notes than a short line between all those other
> improvements ;-)
>
> On Apr 20, 2:33 pm, Fabio Maulo <[email protected]> wrote:
> > This method works
> > public virtual System.Type GetUnproxyType()
> > {
> > return GetType();
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > }
> > On Wed, Apr 20, 2011 at 9:25 AM, cremor <[email protected]> wrote:
> > > Compile time: There is no NHibernate.ByteCode.*.dll any more so the
> > > reference to it and the NHibernate configuration for it is invalid.
> > > Run time: Possible breaking change if you switch from Castle to new
> > > internal ProxyFactory and use the GetUnproxiedType() trick I explained
> > > above.
> >
> > > On Apr 20, 2:16 pm, Fabio Maulo <[email protected]> wrote:
> > > > but, which is the breaking change ?
> >
> > > > On Wed, Apr 20, 2011 at 9:06 AM, cremor <[email protected]> wrote:
> > > > > Yeah, I saw that. But I meant that it's not listed under breaking
> > > > > changes at the top of the file.
> >
> > > > > On Apr 20, 1:53 pm, Fabio Maulo <[email protected]> wrote:
> > > > > > In release notes
> > > > > > ** Improvement
> > > > > > * [NH-2586] - Default ProxyFactory
> >
> > > > > > On Wed, Apr 20, 2011 at 7:34 AM, cremor <[email protected]> wrote:
> > > > > > > Wouldn't it be a good idea if the breaking change to the
> > > ProxyFactory
> > > > > > > would be mentioned in the release notes? It's quite a big
> change
> > > that
> > > > > > > you don't need (and have) that seperate assemblies any more by
> > > > > > > default.
> >
> > > > > > > And there is not only the compile time breaking change. If you
> have
> > > > > > > previously used Castle and your entities use the quite common
> > > > > > > GetUnproxiedType() trick (e.g. from Sharp-Architecture or the
> > > > > > > NHibernate 3.0 Cookbook), there will be a bug in your code if
> you
> > > > > > > switch to the new default ProxyFactory (because that
> > > > > > > GetUnproxiedType() trick doesn't work with it, like it didn't
> work
> > > > > > > with LinFu and Spring).
> >
> > > > > > --
> > > > > > Fabio Maulo
> >
> > > > --
> > > > Fabio Maulo
> >
> > --
> > Fabio Maulo
>
--
Fabio Maulo