{"action":"created","issue":{"url":"https://api.github.com/repos/restsharp/RestSharp/issues/670","labels_url":"https://api.github.com/repos/restsharp/RestSharp/issues/670/labels{/name}","comments_url":"https://api.github.com/repos/restsharp/RestSharp/issues/670/comments","events_url":"https://api.github.com/repos/restsharp/RestSharp/issues/670/events","html_url":"https://github.com/restsharp/RestSharp/issues/670","id":67058403,"number":670,"title":"Deserialization error when trying to deserialize list of enums where an enum value returned in response does not exist","user":{"login":"JohnnyV1","id":5562759,"avatar_url":"https://avatars.githubusercontent.com/u/5562759?v=3","gravatar_id":"","url":"https://api.github.com/users/JohnnyV1","html_url":"https://github.com/JohnnyV1","followers_url":"https://api.github.com/users/JohnnyV1/followers","following_url":"https://api.github.com/users/JohnnyV1/following{/other_user}","gists_url":"https://api.github.com/users/JohnnyV1/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnnyV1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnnyV1/subscriptions","organizations_url":"https://api.github.com/users/JohnnyV1/orgs","repos_url":"https://api.github.com/users/JohnnyV1/repos","events_url":"https://api.github.com/users/JohnnyV1/events{/privacy}","received_events_url":"https://api.github.com/users/JohnnyV1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-08T06:14:43Z","updated_at":"2015-04-24T16:32:30Z","closed_at":null,"body":"I noticed that if I am deserializing an object that contains an enum property, that property will be the first enum value in the enumeration if the response contains a value that is not known to the REST client deserializer.  I think that is good behavior because I usually put Unknown as the first value in enum types that go over the wire.\r\n\r\nAs an example\r\n```c#\r\n    public enum Values\r\n    {\r\n        Unknown,\r\n        Value1,\r\n        Value2,\r\n        Value3\r\n    }\r\n```\r\nHowever, If I have an object with `IEnumerable<Values>` as a property and if a list came over the wire with Value4 in it, an error is thrown and deserialization fails for the entire object.  Basically I cannot add additional enum values on the server because I may break existing clients.  Can this be changed to return the first enum value when an item in an enum list cannot be deserialized just like having an enum property on the object itself?"},"comment":{"url":"https://api.github.com/repos/restsharp/RestSharp/issues/comments/95986240","html_url":"https://github.com/restsharp/RestSharp/issues/670#issuecomment-95986240","issue_url":"https://api.github.com/repos/restsharp/RestSharp/issues/670","id":95986240,"user":{"login":"kondaskondas","id":4131283,"avatar_url":"https://avatars.githubusercontent.com/u/4131283?v=3","gravatar_id":"","url":"https://api.github.com/users/kondaskondas","html_url":"https://github.com/kondaskondas","followers_url":"https://api.github.com/users/kondaskondas/followers","following_url":"https://api.github.com/users/kondaskondas/following{/other_user}","gists_url":"https://api.github.com/users/kondaskondas/gists{/gist_id}","starred_url":"https://api.github.com/users/kondaskondas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kondaskondas/subscriptions","organizations_url":"https://api.github.com/users/kondaskondas/orgs","repos_url":"https://api.github.com/users/kondaskondas/repos","events_url":"https://api.github.com/users/kondaskondas/events{/privacy}","received_events_url":"https://api.github.com/users/kondaskondas/received_events","type":"User","site_admin":false},"created_at":"2015-04-24T16:32:30Z","updated_at":"2015-04-24T16:32:30Z","body":"Give your enum values an integer value eg:\r\n` public enum Values\r\n{\r\nUnknown = 0,\r\nValue1 = 1,\r\nValue2 = 2,\r\nValue3 = 3\r\n}\r\n`\r\nThen when the deserializer tries to assign an unknown value would be 0, if it tries to parse a value by a string it will throw. Or you can send an IEnumerable<int> and convert them to Values on your client (Simple solution).\r\n\r\nYou can check and do tests if you clone/download the repository and run this test:\r\nProject: jsonenums\r\nFile: JsonTests.cs\r\nTest: Can_Deserialize_Various_Enum_Values\r\n\r\nModify the jsonenums.txt and include and unknown value, you can see it will fail to parse an unknown string word but if its an integer it will get you the default value.\r\nCan_Deserialize_Various_Enum_Values"}}