Skip to content

Can't clone dictionary #34

@kakkamstrup

Description

@kakkamstrup

Here is a piece of code to recreate the bug, I hope.

using System.Collections.Generic;
using System.Linq;
using Force.DeepCloner;

namespace DeepClonerBug
{
internal class Program
{
static void Main(string[] args)
{
var org = new Dictionary<Location, Location[]>
{
{ new Location { Name = "A" }, new[] { new Location { Name = "1" } } }
};

        org[org.Keys.First()].ToString();

        var clone = org.DeepClone();

        // throws System.Collections.Generic.KeyNotFoundException: 'The given key was not present in the dictionary.'
        clone[clone.Keys.First()].ToString();
    }
}

public class Location
{
    public string Name { get; set; }
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions