Skip to content

Commit 781320c

Browse files
committed
Fix DataMemberAttribute on WP-SL/SL-5 causes exception when it does not have Order.
1 parent 6c385b0 commit 781320c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/MsgPack/Serialization/SerializationTarget.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,15 @@ internal static IEnumerable<SerializingMember> GetTargetMembers( Type type )
167167
.FirstOrDefault();
168168
var id = item.data.GetNamedArguments()
169169
.Where( arg => arg.GetMemberName() == "Order" )
170-
.Select( arg => ( int? )arg.GetTypedValue().Value )
170+
.Select( arg => ( int? ) arg.GetTypedValue().Value )
171171
.FirstOrDefault();
172+
#if SILVERLIGHT
173+
if ( id == -1 )
174+
{
175+
// Shim for Silverlight returns -1 because GetNamedArguments() extension method cannot recognize whether the argument was actually specified or not.
176+
id = null;
177+
}
178+
#endif // SILVERLIGHT
172179

173180
return
174181
new SerializingMember(

0 commit comments

Comments
 (0)