{"action":"created","issue":{"url":"https://api.github.com/repos/SlapperAutoMapper/Slapper.AutoMapper/issues/12","labels_url":"https://api.github.com/repos/SlapperAutoMapper/Slapper.AutoMapper/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/SlapperAutoMapper/Slapper.AutoMapper/issues/12/comments","events_url":"https://api.github.com/repos/SlapperAutoMapper/Slapper.AutoMapper/issues/12/events","html_url":"https://github.com/SlapperAutoMapper/Slapper.AutoMapper/issues/12","id":75702188,"number":12,"title":"Slapper.Automapper crashes in certain a rare corner case; fix attached","user":{"login":"sharpe5","id":1290916,"avatar_url":"https://avatars.githubusercontent.com/u/1290916?v=3","gravatar_id":"","url":"https://api.github.com/users/sharpe5","html_url":"https://github.com/sharpe5","followers_url":"https://api.github.com/users/sharpe5/followers","following_url":"https://api.github.com/users/sharpe5/following{/other_user}","gists_url":"https://api.github.com/users/sharpe5/gists{/gist_id}","starred_url":"https://api.github.com/users/sharpe5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharpe5/subscriptions","organizations_url":"https://api.github.com/users/sharpe5/orgs","repos_url":"https://api.github.com/users/sharpe5/repos","events_url":"https://api.github.com/users/sharpe5/events{/privacy}","received_events_url":"https://api.github.com/users/sharpe5/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-05-12T18:53:45Z","updated_at":"2016-01-21T10:11:26Z","closed_at":"2016-01-08T08:52:10Z","body":"Hi,\r\n\r\nFirstly, Slapper.Automapper is just awesome, thanks for the excellent work!!!\r\n\r\nI've had Slapper.Automapper crash with a null pointer exception.\r\n\r\nImagine that we have a large SQL query, and part of it comes back as null:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/1290916/7595468/29e2f38c-f8df-11e4-81e7-d5700f550b10.png)\r\n\r\nThis means that everything in the POCO is null, and nothing should be added to its parent POCO (which is class `PingOrder` which contains `List<PingTicket> Tickets;`):\r\n\r\n\t[DataContract]\r\n\tpublic class PingTicket\r\n\t{\r\n\t\t// Must have parameterless constructor.\r\n\t\tpublic PingTicket()\t{ }\r\n\r\n\t\t[DataMember]\r\n\t\tpublic long? TicketId { get; set; }\r\n\r\n\t\t[DataMember]\r\n\t\tpublic decimal? Quantity { get; set; }\r\n\t}\r\n\r\nThe code crashes in this line, as `identifierValue` is null:\r\n`identifierHash += identifierValue.GetHashCode() + type.GetHashCode();`\r\n\r\nthe code is in this function:\r\n`public static Tuple<bool, object, int> GetInstance(Type type, IDictionary<string, object> properties)`\r\n\r\nThe fix I applied was to replace this:\r\n\r\n`identifierHash += identifierValue.GetHashCode() + type.GetHashCode();`\r\n\r\nwith this:\r\n\r\n`if (identifierValue != null)`\r\n`{`\r\n  `identifierHash += identifierValue.GetHashCode() + type.GetHashCode();`\r\n`}`\r\n\r\nWhen this function was entered, the contents of the `properties` parameter was this:\r\n`properties[\"ticketid\"] = null`\r\n`properties[\"orderid\"] = null`\r\n\r\nThis meant that `identifierValue` was null, and `identifierValue.GetHashCode()` failed as you can't get a hash on a null value.\r\n\r\nI would submit a push request, but unfortunately I can't as I'm at work.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/SlapperAutoMapper/Slapper.AutoMapper/issues/comments/173524458","html_url":"https://github.com/SlapperAutoMapper/Slapper.AutoMapper/issues/12#issuecomment-173524458","issue_url":"https://api.github.com/repos/SlapperAutoMapper/Slapper.AutoMapper/issues/12","id":173524458,"user":{"login":"odelvalle","id":2826969,"avatar_url":"https://avatars.githubusercontent.com/u/2826969?v=3","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":"2016-01-21T10:11:26Z","updated_at":"2016-01-21T10:11:26Z","body":"Thanks @sharpe5 .. Exactly, has been fixed in version 1.0.0.7 and published to Nuget."}}