@@ -206,13 +206,12 @@ public static MessagePackSerializer<T> Get<T>( SerializationContext context, obj
206206
207207 internal static MessagePackSerializer < T > CreateInternal < T > ( SerializationContext context )
208208 {
209+ #if ! XAMIOS && ! XAMDROID && ! UNITY
210+ Contract . Ensures ( Contract . Result < MessagePackSerializer < T > > ( ) != null ) ;
211+ #endif // !XAMIOS && !XAMDROID && !UNITY
209212#if XAMIOS || XAMDROID || UNITY
210- return context . GetSerializer < T > ( ) ;
213+ return CreateReflectionInternal < T > ( context ) ;
211214#else
212-
213- Contract . Ensures ( Contract . Result < MessagePackSerializer < T > > ( ) != null ) ;
214-
215- //Func<SerializationContext, SerializerBuilder<T>> builderProvider;
216215 ISerializerBuilder < T > builder ;
217216#if NETFX_CORE || WINDOWS_PHONE
218217 builder = new ExpressionTreeSerializerBuilder < T > ( ) ;
@@ -331,7 +330,7 @@ public static IMessagePackSingleObjectSerializer Create( Type targetType, Serial
331330#endif // !UNITY
332331
333332#if XAMIOS || XAMDROID || UNITY
334- return context . GetSerializer ( targetType ) ;
333+ return CreateReflectionInternal ( context , targetType ) ;
335334#else
336335 // MPS.Create should always return new instance, and creator delegate should be cached for performance.
337336#if NETFX_CORE
@@ -553,6 +552,15 @@ internal static IMessagePackSingleObjectSerializer CreateReflectionInternal( Ser
553552
554553 internal static MessagePackSerializer < T > CreateReflectionInternal < T > ( SerializationContext context )
555554 {
555+ var serializer = context . Serializers . Get < T > ( context ) ;
556+
557+ if ( serializer != null )
558+ {
559+ // For MessagePack.Create compatibility.
560+ // Required for built-in types.
561+ return serializer ;
562+ }
563+
556564 var traits = typeof ( T ) . GetCollectionTraits ( ) ;
557565 switch ( traits . CollectionType )
558566 {
0 commit comments