{"action":"opened","issue":{"url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json/issues/1234","repository_url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json","labels_url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json/issues/1234/labels{/name}","comments_url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json/issues/1234/comments","events_url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json/issues/1234/events","html_url":"https://github.com/JamesNK/Newtonsoft.Json/issues/1234","id":211816276,"number":1234,"title":"InvalidCastException when populating an object that implements IEnumerable<T>","user":{"login":"MaxKot","id":430815,"avatar_url":"https://avatars1.githubusercontent.com/u/430815?v=3","gravatar_id":"","url":"https://api.github.com/users/MaxKot","html_url":"https://github.com/MaxKot","followers_url":"https://api.github.com/users/MaxKot/followers","following_url":"https://api.github.com/users/MaxKot/following{/other_user}","gists_url":"https://api.github.com/users/MaxKot/gists{/gist_id}","starred_url":"https://api.github.com/users/MaxKot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaxKot/subscriptions","organizations_url":"https://api.github.com/users/MaxKot/orgs","repos_url":"https://api.github.com/users/MaxKot/repos","events_url":"https://api.github.com/users/MaxKot/events{/privacy}","received_events_url":"https://api.github.com/users/MaxKot/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-03T22:13:26Z","updated_at":"2017-03-03T22:13:26Z","closed_at":null,"body":"An InvalidCastException is throw when deserializing an object with a specific conditions.\r\n\r\nThere is a class EnumerableLike that:\r\n1. implements IEnumerable<T>\r\n2. is deserialized with a custom JsonConverter.\r\n\r\nThere is a class Container that:\r\n1. has a read-only property EnumerableLikeProp of type EnumerableLike\r\n2. has a constructor marked with JsonContructorAttribute\r\n3. the constructor accepts JsonProperties other than EnumerableLikeProp\r\n4. the constructor does not accept a JsonProperty for EnumerableLikeProp.\r\n\r\nIf these conditions are met then an InvalidCastException is throw when deserializing an instance of type Container.\r\n\r\nWhile this is easily fixed by applying JsonObjectAttribute to the EnumerableLike class, the exception does not provide a clear description of its reasons.\r\n\r\nStack trace:\r\n```\r\nResult StackTrace:\t\r\nat Void .ctor(System.Collections.Generic.ICollection`1[System.Int32])(Object[] )\r\nat Newtonsoft.Json.Serialization.JsonArrayContract.CreateWrapper(Object list) in D:\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\Serialization\\JsonArrayContract.cs:line 292\r\nat Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters(JsonReader reader, JsonObjectContract contract, JsonProperty containerProperty, ObjectConstructor`1 creator, String id) in D:\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\Serialization\\JsonSerializerInternalReader.cs:line 2038\r\nat Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject(JsonReader reader, JsonObjectContract objectContract, JsonProperty containerMember, JsonProperty containerProperty, String id, Boolean& createdFromNonDefaultCreator) in D:\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\Serialization\\JsonSerializerInternalReader.cs:line 2277\r\nat Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) in D:\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\Serialization\\JsonSerializerInternalReader.cs:line 479\r\nat Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) in D:\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\Serialization\\JsonSerializerInternalReader.cs:line 294\r\nat Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) in D:\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\Serialization\\JsonSerializerInternalReader.cs:line 196\r\nat Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) in D:\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\JsonSerializer.cs:line 874\r\nat Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) in D:\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\JsonSerializer.cs:line 853\r\nat Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) in D:\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\JsonConvert.cs:line 812\r\nat Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) in D:\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\JsonConvert.cs:line 769\r\nat Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value) in D:\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\JsonConvert.cs:line 706\r\nat Newtonsoft.Json.Tests.JsonConvertTest.ShouldNotPopulateReadOnlyEnumerableObjectWithNonDefaultConstructor() in D:\\Newtonsoft.Json\\Src\\Newtonsoft.Json.Tests\\JsonConvertTest.cs:line 1638\r\nResult Message:\tSystem.InvalidCastException : Unable to cast object of type 'EnumerableWithConverter' to type 'System.Collections.Generic.ICollection`1[System.Int32]'.\r\n```"}}
{"actor":{"display_login":"MaxKot"}}