diff --git a/releasenotes.txt b/releasenotes.txt index 584bc5714e0..2ba1d97fddd 100644 --- a/releasenotes.txt +++ b/releasenotes.txt @@ -1,3 +1,11 @@ +Tentative for 4.1: + + Possible breaking change: Proxies for classes that used lazy fields (not collections) + would have any exceptions from the entity wrapped in TargetInvocationException. This + wrapping exception have now been removed. Where relevant, you should instead catch + the original exception type you throw. + + Build 4.0.4.GA ============================= diff --git a/src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorSerializable.cs b/src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorTests.cs similarity index 60% rename from src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorSerializable.cs rename to src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorTests.cs index c21eba615f4..70d020796af 100644 --- a/src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorSerializable.cs +++ b/src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorTests.cs @@ -6,12 +6,18 @@ namespace NHibernate.Test.DynamicProxyTests { - public class LazyFieldInterceptorSerializable + public class LazyFieldInterceptorTests { [Serializable] public class MyClass { public virtual int Id { get; set; } + + public virtual void ThrowError() + { + // Use some specific exception type to avoid using the base class. + throw new FormatException("test"); + } } [Test] @@ -31,5 +37,16 @@ public void LazyFieldInterceptorIsBinarySerializable() Assert.That(fieldInterceptionProxy, Is.BinarySerializable); } + + + [Test] + public void DefaultDynamicLazyFieldInterceptorUnWrapsTIEExceptions() + { + var pf = new DefaultProxyFactory(); + var propertyInfo = typeof(MyClass).GetProperty("Id"); + pf.PostInstantiate("MyClass", typeof(MyClass), new HashSet(), propertyInfo.GetGetMethod(), propertyInfo.GetSetMethod(), null); + var myClassProxied = (MyClass)pf.GetFieldInterceptionProxy(new MyClass()); + Assert.Throws(() => myClassProxied.ThrowError(), "test"); + } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/NHibernate.Test.csproj b/src/NHibernate.Test/NHibernate.Test.csproj index 8371f405311..255dd1596af 100644 --- a/src/NHibernate.Test/NHibernate.Test.csproj +++ b/src/NHibernate.Test/NHibernate.Test.csproj @@ -258,7 +258,7 @@ - + @@ -3754,7 +3754,6 @@ -