Hi there,
The user Krzysztof Ko?mic (xtoff) has changed the issue DYNPROXY-ISSUE-85
"False positive exception for serializable type with no serialization
constructor".
Here is what the user changed:
Description
from: The following tests fails with exception message saying
that type is not serializable while in fact, it is.
[Test]
public void SerializatingObjectsWithoutDefaultConstructor1()
{
var c = new ClassWithNoSerializationCtor { Property = "foo" };
var c1 = SerializeAndDeserialize( c );
Assert.AreEqual( "foo", c1.Property );
var proxy =
this.generator.CreateClassProxy<ClassWithNoSerializationCtor>();
var proxy2 = SerializeAndDeserialize(proxy);
Assert.AreEqual( "foo", proxy2.Property );
}
[Serializable]
public class ClassWithNoSerializationCtor : ISerializable
{
public string Property{ get; set;}
public void GetObjectData(SerializationInfo info, StreamingContext
context)
{
info.SetType(typeof(SerializableClassTestCase.ClassWithNoSerializationCtorReference));
info.AddValue("Property", Property);
}
}
[Serializable]
public class ClassWithNoSerializationCtorReference : IObjectReference,
ISerializable
{
private ClassWithNoSerializationCtor _item;
public ClassWithNoSerializationCtorReference(SerializationInfo
info, StreamingContext context)
{
_item = new ClassWithNoSerializationCtor();
_item.Property = info.GetString("Property");
}
public object GetRealObject(StreamingContext context)
{
return _item;
}
public void GetObjectData(SerializationInfo info, StreamingContext
context)
{
}
}
to: The following tests fails with exception message saying
that type is not serializable while in fact, it is.
[Test]
public void SerializatingObjectsWithoutDefaultConstructor1()
{
var c = new ClassWithNoSerializationCtor( "foo" );
var c1 = SerializeAndDeserialize( c );
Assert.AreEqual( "foo", c1.Property );
var proxy = this.generator.CreateClassProxy( typeof(
ClassWithNoSerializationCtor ), new[] { new StandardInterceptor() }, "foo" );
var proxy2 = SerializeAndDeserialize(proxy) as
ClassWithNoSerializationCtor;
Assert.AreEqual( "foo", proxy2.Property );
var proxyTargetAccessor = proxy2 as IProxyTargetAccessor;
Assert.IsNotNull( proxyTargetAccessor );
var interceptors = proxyTargetAccessor.GetInterceptors();
Assert.IsNotEmpty( interceptors );
Assert.IsInstanceOfType( typeof( StandardInterceptor ),
interceptors[ 0 ] );
}
[Serializable]
public class ClassWithNoSerializationCtorReference : IObjectReference,
ISerializable
{
private ClassWithNoSerializationCtor _item;
public ClassWithNoSerializationCtorReference(SerializationInfo
info, StreamingContext context)
{
var property = info.GetString("Property");
_item = new ClassWithNoSerializationCtor( property );
}
public object GetRealObject(StreamingContext context)
{
return _item;
}
public void GetObjectData(SerializationInfo info, StreamingContext
context)
{
}
}
[Serializable]
public class ClassWithNoSerializationCtor : ISerializable
{
public ClassWithNoSerializationCtor( string property )
{
this.Property = property;
}
public string Property{ get; set;}
public virtual void GetObjectData(SerializationInfo info,
StreamingContext context)
{
info.SetType(typeof(SerializableClassTestCase.ClassWithNoSerializationCtorReference));
info.AddValue("Property", Property);
}
}
For more, see
http://support.castleproject.org/projects/DYNPROXY/issues/view/DYNPROXY-ISSUE-85
--
donjon
by Castle Stronghold
http://www.castle-donjon.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Development List" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---