File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/Generator/Generators/CSharp Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -777,10 +777,18 @@ private void MarshalRefClass(Class @class)
777
777
Context . Parameter . Name } "", ""Cannot be null because it is passed by value."");" ) ;
778
778
779
779
var nativeClass = typePrinter . PrintNative ( @class ) ;
780
+
780
781
var cctorName = CSharpSources . GetFunctionNativeIdentifier ( Context . Context , cctor ) ;
782
+
783
+ var defaultValue = "" ;
784
+ var TypePrinter = new CSharpTypePrinter ( Context . Context ) ;
785
+ var ExpressionPrinter = new CSharpExpressionPrinter ( TypePrinter ) ;
786
+ if ( cctor . Parameters . Count > 1 )
787
+ defaultValue = $ ", { ExpressionPrinter . VisitParameter ( cctor . Parameters . Last ( ) ) } ";
788
+
781
789
Context . Before . WriteLine ( $ "byte* __{ Context . Parameter . Name } Memory = stackalloc byte[sizeof({ nativeClass } )];") ;
782
790
Context . Before . WriteLine ( $ "__IntPtr __{ Context . Parameter . Name } Ptr = (__IntPtr)__{ Context . Parameter . Name } Memory;") ;
783
- Context . Before . WriteLine ( $ "{ nativeClass } .{ cctorName } (__{ Context . Parameter . Name } Ptr, { Context . Parameter . Name } .__Instance);") ;
791
+ Context . Before . WriteLine ( $ "{ nativeClass } .{ cctorName } (__{ Context . Parameter . Name } Ptr, { Context . Parameter . Name } .__Instance{ defaultValue } );") ;
784
792
Context . Return . Write ( $ "__{ Context . Parameter . Name } Ptr") ;
785
793
786
794
if ( Context . Context . ParserOptions . IsItaniumLikeAbi && @class . HasNonTrivialDestructor )
You can’t perform that action at this time.
0 commit comments