force-net / DeepCloner

Fast object cloner for .NET
MIT License
530 stars 73 forks source link

program crashed when deepclone multidimensional zero-length array #25

Closed DemoJameson closed 3 years ago

DemoJameson commented 3 years ago
Array.CreateInstance(typeof(int), new[] {0, 0}).DeepClone(); // IndexOutOfRangeException
Array.CreateInstance(typeof(int), new[] {1, 0}).DeepClone(); // IndexOutOfRangeException
Array.CreateInstance(typeof(int), new[] {0, 1}).DeepClone(); // IndexOutOfRangeException
Array.CreateInstance(typeof(int), new[] {1, 1}).DeepClone(); // Works
Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Array.InternalGetReference(Void* elemRef, Int32 rank, Int32* pIndices)
   at System.Array.GetValue(Int32[] indices)
   at Force.DeepCloner.Helpers.DeepClonerGenerator.CloneAbstractArrayInternal(Array obj, DeepCloneState state)
   at Force.DeepCloner.Helpers.DeepClonerGenerator.CloneClassRoot(Object obj)
   at Force.DeepCloner.Helpers.DeepClonerGenerator.CloneObject[T](T obj)
   at Force.DeepCloner.DeepClonerExtensions.DeepClone[T](T obj)
   at ConsoleApp1.Program.Main(String[] args) in C:\Users\DemoJameon\RiderProjects\ConsoleApp1\ConsoleApp1\Program.cs:line 10
force-net commented 3 years ago

I'll try to release a new version in some days.