File tree Expand file tree Collapse file tree
src/ServiceStack.GrpcClient Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -715,8 +715,29 @@ private static string GetTypeName(Type type)
715715 }
716716
717717 //also forces static initializer
718- public static MetaType GetMetaType ( ) => metaType
719- ??= typeof ( T ) . IsValueType ? null : GrpcConfig . TypeModel . Add ( typeof ( T ) , applyDefaultBehaviour : true ) ;
718+ public static MetaType GetMetaType ( ) => metaType
719+ ??= typeof ( T ) . IsValueType ? null : CreateMetaType ( ) ;
720+
721+ private static MetaType CreateMetaType ( )
722+ {
723+ // check to see if this is a request DTO; if it is, we'll do things manually;
724+ // do this by checking for the IReturn[Void|<T>] : IReturn API
725+ bool isRequest = typeof ( IReturn ) . IsAssignableFrom ( typeof ( T ) )
726+ && typeof ( T ) . GetInterfaces ( ) . Any (
727+ x => x == typeof ( IReturnVoid )
728+ || x . IsGenericType && x . GetGenericTypeDefinition ( ) == typeof ( IReturn < > ) ) ;
729+
730+ if ( ! isRequest )
731+ {
732+ // regular type; let the serializer worry about the details
733+ return GrpcConfig . TypeModel . Add ( typeof ( T ) , applyDefaultBehaviour : true ) ;
734+ }
735+ // query type; flatten
736+ var mt = GrpcConfig . TypeModel . Add ( typeof ( T ) , applyDefaultBehaviour : false ) ;
737+
738+ return mt ;
739+
740+ }
720741
721742 public GrpcMarshaller ( ) : base ( Serialize , Deserialize ) { }
722743
You can’t perform that action at this time.
0 commit comments