Skip to content

Commit 3d65987

Browse files
author
Lewis Mohr
committed
fix unknown fields in a map causing subsequent fields to fail to read
1 parent b104538 commit 3d65987

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/MsgPack/Serialization/ReflectionSerializers/ReflectionObjectMessagePackSerializer`1.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,18 @@ protected internal override T UnpackFromCore( Unpacker unpacker )
157157
continue;
158158
}
159159

160-
result = this.UnpackMemberValue( result, unpacker, itemsCount, ref unpacked, this._memberIndexes[ name ], i );
160+
int index;
161+
if ( !this._memberIndexes.TryGetValue(name, out index) )
162+
{
163+
// key does not exist in the object, skip the associated value
164+
if ( unpacker.Skip() == null )
165+
{
166+
throw SerializationExceptions.NewMissingItem( i );
167+
}
168+
continue;
169+
}
170+
171+
result = this.UnpackMemberValue(result, unpacker, itemsCount, ref unpacked, index, i);
161172
}
162173
}
163174

0 commit comments

Comments
 (0)