{"action":"created","issue":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/913","labels_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/913/labels{/name}","comments_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/913/comments","events_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/913/events","html_url":"https://github.com/AutoMapper/AutoMapper/issues/913","id":109675714,"number":913,"title":"Constructor mapping bug in 4.0.4 after merging branch 'ConstrutorParamMapping' into develop","user":{"login":"adoris","id":2564728,"avatar_url":"https://avatars.githubusercontent.com/u/2564728?v=3","gravatar_id":"","url":"https://api.github.com/users/adoris","html_url":"https://github.com/adoris","followers_url":"https://api.github.com/users/adoris/followers","following_url":"https://api.github.com/users/adoris/following{/other_user}","gists_url":"https://api.github.com/users/adoris/gists{/gist_id}","starred_url":"https://api.github.com/users/adoris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adoris/subscriptions","organizations_url":"https://api.github.com/users/adoris/orgs","repos_url":"https://api.github.com/users/adoris/repos","events_url":"https://api.github.com/users/adoris/events{/privacy}","received_events_url":"https://api.github.com/users/adoris/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/labels/Bug","name":"Bug","color":"e11d21"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-10-04T11:30:27Z","updated_at":"2016-01-18T15:42:04Z","closed_at":"2016-01-18T15:42:04Z","body":"if not all constructor parameter can be mapped - constructor will be used to construct destination.\r\nBug is in TypeMapFactory. As workaround i use following:\r\n\r\n\r\n```\r\n private bool MapDestinationCtorToSource(TypeMap typeMap, ConstructorInfo destCtor, TypeInfo sourceTypeInfo,\r\n            IMappingOptions options)\r\n        {\r\n            var parameters = new List<ConstructorParameterMap>();\r\n            var ctorParameters = destCtor.GetParameters();\r\n\r\n            if (ctorParameters.Length == 0 || !options.ConstructorMappingEnabled)\r\n                return false;\r\n\r\n            foreach (var parameter in ctorParameters)\r\n            {\r\n                var members = new LinkedList<MemberInfo>();\r\n\r\n                var canResolve = MapDestinationPropertyToSource(members, sourceTypeInfo, parameter.Name, options);\r\n\r\n                var resolvers = members.Select(mi => mi.ToMemberGetter());\r\n\r\n                var param = new ConstructorParameterMap(parameter, resolvers.ToArray(), canResolve);\r\n\r\n                parameters.Add(param);\r\n            }\r\n\r\n<bold>\r\n            if (!parameters.All(p => p.CanResolve))\r\n            {\r\n                return false;\r\n            }\r\n</bold>\r\n            typeMap.AddConstructorMap(destCtor, parameters);\r\n\r\n            return true;\r\n        }\r\n```"},"comment":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/comments/172564804","html_url":"https://github.com/AutoMapper/AutoMapper/issues/913#issuecomment-172564804","issue_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/913","id":172564804,"user":{"login":"jbogard","id":104498,"avatar_url":"https://avatars.githubusercontent.com/u/104498?v=3","gravatar_id":"","url":"https://api.github.com/users/jbogard","html_url":"https://github.com/jbogard","followers_url":"https://api.github.com/users/jbogard/followers","following_url":"https://api.github.com/users/jbogard/following{/other_user}","gists_url":"https://api.github.com/users/jbogard/gists{/gist_id}","starred_url":"https://api.github.com/users/jbogard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbogard/subscriptions","organizations_url":"https://api.github.com/users/jbogard/orgs","repos_url":"https://api.github.com/users/jbogard/repos","events_url":"https://api.github.com/users/jbogard/events{/privacy}","received_events_url":"https://api.github.com/users/jbogard/received_events","type":"User","site_admin":false},"created_at":"2016-01-18T15:42:04Z","updated_at":"2016-01-18T15:42:04Z","body":"Closing until a repro comes up."}}