Skip to content

Commit d2b573e

Browse files
committed
fixed an issue with cloning primitive types, casted as an object
1 parent 3a8dcc2 commit d2b573e

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

DeepCloner.Tests/SimpleObjectSpec.cs

+2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ public void Privitive_Should_Be_Cloned()
144144
Assert.That(((object)null).DeepClone(), Is.Null);
145145
var obj = new object();
146146
Assert.That(obj.DeepClone(), Is.Not.Null);
147+
Assert.That(true.DeepClone(), Is.True);
148+
Assert.That(((object)true).DeepClone(), Is.True);
147149
Assert.That(obj.DeepClone().GetType(), Is.EqualTo(typeof(object)));
148150
Assert.That(obj.DeepClone(), Is.Not.EqualTo(obj));
149151
}

DeepCloner.nuspec

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<metadata>
44
<id>DeepCloner</id>
55
<title>DeepCloner</title>
6-
<version>0.9.1</version>
6+
<version>0.9.2</version>
77
<authors>force</authors>
88
<owners>force</owners>
99
<licenseUrl>https://github.com/force-net/DeepCloner/blob/develop/LICENSE</licenseUrl>
@@ -15,6 +15,7 @@
1515
Seriously improved cloning of simple object (constructor analyzing + reference counting)
1616
Fixed small issue with possible multiple copying of same fields in object
1717
Safe variant now correctly clones readonly fields
18+
Fixed small issue with cloning primitive types casted as an object
1819
</releaseNotes>
1920
<copyright>Copyright by Force 2016</copyright>
2021
<tags>.NET shallow deep clone DeepClone fast</tags>

DeepCloner/DeepCloner.csproj

-5
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
<ItemGroup>
4343
<Reference Include="System" />
4444
<Reference Include="System.Core" />
45-
<Reference Include="System.Xml.Linq" />
46-
<Reference Include="System.Data.DataSetExtensions" />
47-
<Reference Include="Microsoft.CSharp" />
48-
<Reference Include="System.Data" />
49-
<Reference Include="System.Xml" />
5045
</ItemGroup>
5146
<ItemGroup>
5247
<Compile Include="DeepClonerExtensions.cs" />

DeepCloner/Helpers/DeepClonerGenerator.cs

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ private static object CloneClassRoot(object obj)
2424
// 350ms
2525
var cloner = (Func<object, DeepCloneState, object>)DeepClonerCache.GetOrAddClass(type, t => GenerateCloner(t, true));
2626

27+
if (cloner == null) return obj;
28+
2729
// 200ms
2830
return cloner(obj, new DeepCloneState());
2931
}

DeepCloner/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
// by using the '*' as shown below:
3333

3434
[assembly: AssemblyVersion("0.8.0.0")] // change this value only when api is changing
35-
[assembly: AssemblyFileVersion("0.9.1.0")]
36-
[assembly: AssemblyInformationalVersion("0.9.1.0")]
35+
[assembly: AssemblyFileVersion("0.9.2.0")]
36+
[assembly: AssemblyInformationalVersion("0.9.2.0")]
3737

3838
#if !DEBUG
3939
[assembly: AssemblyKeyFileAttribute("..\\public.snk")]

0 commit comments

Comments
 (0)