Skip to content

Commit f4050bb

Browse files
committed
Add UnpackMessagePackObject(byte[])
1 parent aa509a2 commit f4050bb

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ Release 1.0.0-beta1 T.B.D.
712712

713713
NEW FEATURES
714714
* .NET Standard 2.0 which supports serializer source code generation on .NET Core. Note that serializer assembly generation is not supported.
715+
* MessagePackSerializer.UnpackMessagePackObject(byte[]) utility method.
715716

716717
BUG FIXES
717718
* Fix ByteArrayPacker throws IndexOutOfBoundException when the buffer remaining bytes is equal to packed scalar size. #252

src/MsgPack/Serialization/MessagePackSerializer.Factories.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#region -- License Terms --
1+
#region -- License Terms --
22
//
33
// MessagePack for CLI
44
//
@@ -666,6 +666,25 @@ public static MessagePackObject UnpackMessagePackObject( Stream stream )
666666
return _singleTonMpoDeserializer.Unpack( stream );
667667
}
668668

669+
/// <summary>
670+
/// Directly deserialize specified MessagePack byte array as <see cref="MessagePackObject"/> tree.
671+
/// </summary>
672+
/// <param name="buffer">The stream which contains deserializing data.</param>
673+
/// <returns>A <see cref="MessagePackObject"/> which is root of the deserialized MessagePack object tree.</returns>
674+
/// <exception cref="ArgumentNullException">
675+
/// <paramref name="buffer"/> is <c>null</c>.
676+
/// </exception>
677+
/// <remarks>
678+
/// This method is convinient wrapper for <see cref="MessagePackSerializer.Get{T}(SerializationContext)"/> for <see cref="MessagePackObject"/>.
679+
/// <note>
680+
/// You cannot override this method behavior because this method uses private <see cref="SerializationContext"/> instead of default context which is able to be accessed via <see cref="SerializationContext.Default"/>.
681+
/// </note>
682+
/// </remarks>
683+
public static MessagePackObject UnpackMessagePackObject( byte[] buffer )
684+
{
685+
return _singleTonMpoDeserializer.UnpackSingleObject( buffer );
686+
}
687+
669688
/// <summary>
670689
/// Try to prepare specified type for some AOT(Ahead-Of-Time) compilation environment.
671690
/// If the type will be used in collection or dictionary, use <see cref="PrepareCollectionType{TElement}"/> and/or <see cref="PrepareDictionaryType{TKey,TValue}"/> instead.

0 commit comments

Comments
 (0)