{"action":"created","issue":{"url":"https://api.github.com/repos/SlapperAutoMapper/Slapper.AutoMapper/issues/57","repository_url":"https://api.github.com/repos/SlapperAutoMapper/Slapper.AutoMapper","labels_url":"https://api.github.com/repos/SlapperAutoMapper/Slapper.AutoMapper/issues/57/labels{/name}","comments_url":"https://api.github.com/repos/SlapperAutoMapper/Slapper.AutoMapper/issues/57/comments","events_url":"https://api.github.com/repos/SlapperAutoMapper/Slapper.AutoMapper/issues/57/events","html_url":"https://github.com/SlapperAutoMapper/Slapper.AutoMapper/issues/57","id":240577029,"number":57,"title":"MapDynamic with array property always results in a single-member array","user":{"login":"FilipFilipov","id":10566947,"avatar_url":"https://avatars3.githubusercontent.com/u/10566947?v=4","gravatar_id":"","url":"https://api.github.com/users/FilipFilipov","html_url":"https://github.com/FilipFilipov","followers_url":"https://api.github.com/users/FilipFilipov/followers","following_url":"https://api.github.com/users/FilipFilipov/following{/other_user}","gists_url":"https://api.github.com/users/FilipFilipov/gists{/gist_id}","starred_url":"https://api.github.com/users/FilipFilipov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FilipFilipov/subscriptions","organizations_url":"https://api.github.com/users/FilipFilipov/orgs","repos_url":"https://api.github.com/users/FilipFilipov/repos","events_url":"https://api.github.com/users/FilipFilipov/events{/privacy}","received_events_url":"https://api.github.com/users/FilipFilipov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-07-05T08:35:41Z","updated_at":"2017-11-12T23:24:38Z","closed_at":null,"author_association":"NONE","body":"You can reproduce this easily in your `MapDynamicTests` if you change the Customer's Order type from `ICollection<Order>` to `Order[]` and then try to map a customer with more than one Order. The resulting array will always contain only the final Order.\r\n\r\nLooking through the code I think this is caused by the `MapCollection` method, which for arrays does\r\n\r\n```\r\nvar arrayList = new ArrayList { instanceToAddToCollectionInstance };\r\n```\r\n\r\nor in the case where `isNewlyCreatedInstance` is false\r\n```\r\nvar arrayList = new ArrayList((ICollection)instance);\r\n```\r\n\r\nIn both cases shouldn't that instead be\r\n```\r\nvar arrayList = new ArrayList((ICollection)instance) { instanceToAddToCollectionInstance };\r\n```"},"comment":{"url":"https://api.github.com/repos/SlapperAutoMapper/Slapper.AutoMapper/issues/comments/343777502","html_url":"https://github.com/SlapperAutoMapper/Slapper.AutoMapper/issues/57#issuecomment-343777502","issue_url":"https://api.github.com/repos/SlapperAutoMapper/Slapper.AutoMapper/issues/57","id":343777502,"user":{"login":"odelvalle","id":2826969,"avatar_url":"https://avatars0.githubusercontent.com/u/2826969?v=4","gravatar_id":"","url":"https://api.github.com/users/odelvalle","html_url":"https://github.com/odelvalle","followers_url":"https://api.github.com/users/odelvalle/followers","following_url":"https://api.github.com/users/odelvalle/following{/other_user}","gists_url":"https://api.github.com/users/odelvalle/gists{/gist_id}","starred_url":"https://api.github.com/users/odelvalle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odelvalle/subscriptions","organizations_url":"https://api.github.com/users/odelvalle/orgs","repos_url":"https://api.github.com/users/odelvalle/repos","events_url":"https://api.github.com/users/odelvalle/events{/privacy}","received_events_url":"https://api.github.com/users/odelvalle/received_events","type":"User","site_admin":false},"created_at":"2017-11-12T23:24:38Z","updated_at":"2017-11-12T23:24:38Z","author_association":"MEMBER","body":"Hi @FilipFilipov I changed ICollection to array in Order, and this test pass without change anything in MapCollection:\r\n\r\n```c#\r\n[Test]\r\npublic void Can_Handle_Mapping_A_Single_Dynamic_Object_With_Multiple_Childs()\r\n{\r\n\t// Arrange\r\n\tdynamic dynamicCustomer = new ExpandoObject();\r\n\tdynamicCustomer.Id = 1;\r\n\tdynamicCustomer.FirstName = \"Bob\";\r\n\tdynamicCustomer.LastName = \"Smith\";\r\n\tdynamicCustomer.Orders = new[]\r\n\t{\r\n\t\tnew Order {Id = 1, OrderTotal = 50.50m},\r\n\t\tnew Order {Id = 2, OrderTotal = 60.50m},\r\n\t};\r\n\r\n\t// Act\r\n\tvar customer = Slapper.AutoMapper.MapDynamic<Customer>(dynamicCustomer) as Customer;\r\n\r\n\t// Assert\r\n\tAssert.NotNull(customer);\r\n\tAssert.That(customer.Orders.Count() == 2);\r\n}\r\n```\r\nCan you send me any test that fail?\r\nThanks"}}
{"actor":{"display_login":"odelvalle"}}