{"action":"created","issue":{"url":"https://api.github.com/repos/michaeledgar/protobuf-net/issues/422","labels_url":"https://api.github.com/repos/michaeledgar/protobuf-net/issues/422/labels{/name}","comments_url":"https://api.github.com/repos/michaeledgar/protobuf-net/issues/422/comments","events_url":"https://api.github.com/repos/michaeledgar/protobuf-net/issues/422/events","html_url":"https://github.com/michaeledgar/protobuf-net/issues/422","id":58234414,"number":422,"title":"Invalid behaviour while deserializing unknown enum value","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/michaeledgar/protobuf-net/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/michaeledgar/protobuf-net/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"},{"url":"https://api.github.com/repos/michaeledgar/protobuf-net/labels/Type-Defect","name":"Type-Defect","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-19T16:46:53Z","updated_at":"2015-02-19T16:46:54Z","closed_at":null,"body":"```\nThis test describes expected behaviour. The equivalent test works in c++, java.\nThis test worked well with protobuf-net v1, but it was broken when we got \nprotobuf-net v2: we got an exception ProtoBuf.ProtoException : No \nTests.Enum_Test+E1 enum is mapped to the wire-value 3\n\n[TestFixture]\npublic class Enum_Test\n{\n\t[ProtoContract]\n\tpublic enum E1\n\t{\n\t\t[ProtoEnum(Value = 0)] Default = 0,\n\t\t[ProtoEnum(Value = 1)] One = 1,\n\t\t[ProtoEnum(Value = 2)] Two = 2\n\t}\n\t[ProtoContract]\n\tpublic class Dummy1 : IExtensible\n\t{\n\t\t[ProtoMember(1, IsRequired = false)]\n\t\t[DefaultValue(E1.Default)]\n\t\tpublic E1 EnumProp { get; set; }\n\n\t\tprivate IExtension extensionObject;\n\t\tIExtension IExtensible.GetExtensionObject(bool createIfMissing)\n\t\t{\n\t\t\treturn Extensible.GetExtensionObject(ref extensionObject, createIfMissing);\n\t\t}\n\t}\n\t[ProtoContract]\n\tpublic enum E2\n\t{\n\t\t[ProtoEnum(Value = 0)] Default = 0,\n\t\t[ProtoEnum(Value = 1)] One = 1,\n\t\t[ProtoEnum(Value = 2)] Two = 2,\n\t\t[ProtoEnum(Value = 3)] Three = 3\n\t}\n\t[ProtoContract]\n\tpublic class Dummy2\n\t{\n\t\t[ProtoMember(1, IsRequired = false)]\n\t\t[DefaultValue(E2.Default)]\n\t\tpublic E2 EnumProp { get; set; }\n\t}\n\t[Test]\n\tpublic void MissingEnumValueDeserializationSuccess()\n\t{\n\t\tvar dummy2 = new Dummy2 { EnumProp = E2.Three };\n\t\tvar bytes = dummy2.ToProtoBytes();\n\t\tvar dummy1 = bytes.FromProtoBytes<Dummy1>();\n\t\tAssert.AreEqual(E1.Default, dummy1.EnumProp);\n\t}\n}\n\ngood version: protobuf-net r282 (windows 7 x64)\nbuggy version: protobuf-net r668 (windows 7 x64)\n```\n\n-----\nOriginal issue reported on code.google.com by `space...@yandex.ru` on 19 Dec 2013 at 9:51"},"comment":{"url":"https://api.github.com/repos/michaeledgar/protobuf-net/issues/comments/75088391","html_url":"https://github.com/michaeledgar/protobuf-net/issues/422#issuecomment-75088391","issue_url":"https://api.github.com/repos/michaeledgar/protobuf-net/issues/422","id":75088391,"user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"created_at":"2015-02-19T16:46:54Z","updated_at":"2015-02-19T16:46:54Z","body":"```\nThanks for proposed code, i can confirm it works! This is also how Java and C++ \nprotobuffer handles undefined enums, that it will fallback to default value, \ninstead of throwing exception.\n```\n\n-----\nOriginal comment by `noxx...@googlemail.com` on 30 May 2014 at 2:23"}}