Skip to content

Commit 0adc454

Browse files
committed
Fix NH-2482
SVN: trunk@5423
1 parent ce13e10 commit 0adc454

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using Iesi.Collections.Generic;
3+
using NHibernate.Intercept;
4+
using NUnit.Framework;
5+
using SharpTestsEx;
6+
7+
namespace NHibernate.ByteCode.Castle.Tests
8+
{
9+
public class LazyFieldInterceptorSerializable
10+
{
11+
[Serializable]
12+
public class MyClass
13+
{
14+
public virtual int Id { get; set; }
15+
}
16+
17+
[Test]
18+
public void LazyFieldInterceptorMarkedAsSerializable()
19+
{
20+
typeof(LazyFieldInterceptor).Should().Have.Attribute<SerializableAttribute>();
21+
}
22+
23+
[Test]
24+
public void LazyFieldInterceptorIsBinarySerializable()
25+
{
26+
var pf = new ProxyFactory();
27+
var propertyInfo = typeof(MyClass).GetProperty("Id");
28+
pf.PostInstantiate("MyClass", typeof(MyClass), new HashedSet<System.Type>(), propertyInfo.GetGetMethod(), propertyInfo.GetSetMethod(), null);
29+
var fieldInterceptionProxy = (IFieldInterceptorAccessor)pf.GetFieldInterceptionProxy();
30+
fieldInterceptionProxy.FieldInterceptor = new DefaultFieldInterceptor(null, null, null, "MyClass", typeof(MyClass));
31+
32+
fieldInterceptionProxy.Should().Be.BinarySerializable();
33+
}
34+
}
35+
}

src/NHibernate.ByteCode.Castle.Tests/NHibernate.ByteCode.Castle.Tests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
<SpecificVersion>False</SpecificVersion>
7171
<HintPath>..\..\lib\net\3.5\nunit.framework.dll</HintPath>
7272
</Reference>
73+
<Reference Include="SharpTestsEx.NUnit">
74+
<HintPath>..\..\lib\net\3.5\SharpTestsEx.NUnit.dll</HintPath>
75+
</Reference>
7376
<Reference Include="System" />
7477
<Reference Include="System.Core">
7578
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -80,6 +83,7 @@
8083
<ItemGroup>
8184
<Compile Include="DebugConnectionProvider.cs" />
8285
<Compile Include="AssemblyInfo.cs" />
86+
<Compile Include="LazyFieldInterceptorSerializable.cs" />
8387
<Compile Include="ProxyInterface\CastleProxy.cs" />
8488
<Compile Include="ProxyInterface\CastleProxyFixture.cs" />
8589
<Compile Include="ProxyInterface\CastleProxyImpl.cs" />

src/NHibernate.ByteCode.Castle/LazyFieldInterceptor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
using System;
12
using Castle.DynamicProxy;
23
using NHibernate.Intercept;
34
using NHibernate.Util;
45

56
namespace NHibernate.ByteCode.Castle
67
{
8+
[Serializable]
79
public class LazyFieldInterceptor : IFieldInterceptorAccessor, global::Castle.DynamicProxy.IInterceptor
810
{
911
public IFieldInterceptor FieldInterceptor

src/NHibernate/Intercept/DefaultFieldInterceptor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
using Iesi.Collections.Generic;
1+
using System;
2+
using Iesi.Collections.Generic;
23
using NHibernate.Engine;
34

45
namespace NHibernate.Intercept
56
{
7+
[Serializable]
68
public class DefaultFieldInterceptor : AbstractFieldInterceptor
79
{
810
public DefaultFieldInterceptor(ISessionImplementor session, ISet<string> uninitializedFields, ISet<string> unwrapProxyFieldNames, string entityName, System.Type mappedClass)

0 commit comments

Comments
 (0)