laazyj / GeorgeCloney

DeepClone, Serialize, DeSerialize extensions useful for testing
Other
17 stars 3 forks source link

Doesn't properly work with "object" properties #1

Closed bruno-brant closed 10 years ago

bruno-brant commented 11 years ago

If your class has a property that is declared as an 'System.Object', but a instance of a proper class is there, GeorgeCloney creates a new plain object. The desired effect would be to have the actual instance of the type cloned.

class Foo
{
    public object SomeObject { get; set; }
}

class Bar
{
    public int SomeValue { get; set; }
}

var foo = new Foo { SomeObject = new Bar { SomeValue = 10 } };
var clone = foo.DeepClone();
Console.WriteLine(clone.Bar is Bar); // prints False 
laazyj commented 10 years ago

This has been fixed and published on NuGet in version 1.1.1.17 http://www.nuget.org/packages/GeorgeCloney/