1- #region -- License Terms --
1+ #region -- License Terms --
22//
33// MessagePack for CLI
44//
2020
2121using System ;
2222using System . Linq ;
23+ #if FEATURE_TAP
24+ using System . Threading . Tasks ;
25+ #endif // FEATURE_TAP
2326
2427namespace MsgPack . Serialization . AbstractSerializers
2528{
@@ -77,7 +80,11 @@ private void BuildNullableUnpackFrom( TContext context, Type underlyingType, boo
7780#if FEATURE_TAP
7881 isAsync ? MethodName . UnpackFromAsyncCore :
7982#endif // FEATURE_TAP
80- MethodName . UnpackFromCore ;
83+ MethodName . UnpackFromCore ;
84+ #if FEATURE_TAP
85+ var asyncMethodReturnType = typeof ( Task < > ) . MakeGenericType ( underlyingType ) ;
86+ #endif // FEATURE_TAP
87+
8188 context . BeginMethodOverride ( methodName ) ;
8289
8390 var result = this . DeclareLocal ( context , this . TargetType , "result" ) ;
@@ -87,12 +94,15 @@ private void BuildNullableUnpackFrom( TContext context, Type underlyingType, boo
8794 context ,
8895 this . EmitGetSerializerExpression ( context , underlyingType , null , null ) ,
8996#if FEATURE_TAP
90- isAsync ? typeof ( MessagePackSerializer < > ) . MakeGenericType ( underlyingType ) . GetMethod ( "UnpackFromAsync" , SerializerBuilderHelper . UnpackFromAsyncParameterTypes ) :
97+ isAsync
98+ ? typeof ( MessagePackSerializer < > ) . MakeGenericType ( underlyingType ) . GetMethods ( )
99+ . Single ( m => m . IsPublic && m . Name == "UnpackFromAsync" && m . ReturnType == asyncMethodReturnType && m . GetParameterTypes ( ) . SequenceEqual ( SerializerBuilderHelper . UnpackFromAsyncParameterTypes ) ) :
91100#endif // FEATURE_TAP
92101 typeof ( MessagePackSerializer < > ) . MakeGenericType ( underlyingType ) . GetMethod ( "UnpackFrom" ) ,
93102 context . Unpacker
94103 ) ;
95104
105+
96106 context . EndMethodOverride (
97107 methodName ,
98108 this . EmitRetrunStatement (
0 commit comments