@@ -78,26 +78,37 @@ void Generate (NativeCodeGenStateCollection? nativeCodeGenStates, string abi)
78
78
_ => throw new NotSupportedException ( $ "Internal error: unsupported runtime type '{ androidRuntime } '")
79
79
} ;
80
80
81
+ bool fileFullyWritten ;
81
82
if ( EnableNativeRuntimeLinking ) {
82
83
var pinvokePreserveGen = new PreservePinvokesNativeAssemblyGenerator ( Log , EnsureCodeGenState ( nativeCodeGenStates , targetArch ) , MonoComponents ) ;
83
84
LLVMIR . LlvmIrModule pinvokePreserveModule = pinvokePreserveGen . Construct ( ) ;
84
85
using var pinvokePreserveWriter = MemoryStreamPool . Shared . CreateStreamWriter ( ) ;
86
+ fileFullyWritten = false ;
85
87
try {
86
88
pinvokePreserveGen . Generate ( pinvokePreserveModule , targetArch , pinvokePreserveWriter , pinvokePreserveLlFilePath ! ) ;
87
- } finally {
88
89
pinvokePreserveWriter . Flush ( ) ;
89
90
Files . CopyIfStreamChanged ( pinvokePreserveWriter . BaseStream , pinvokePreserveLlFilePath ! ) ;
91
+ fileFullyWritten = true ;
92
+ } finally {
93
+ if ( ! fileFullyWritten ) {
94
+ MonoAndroidHelper . LogTextStreamContents ( Log , $ "Partial contents of file '{ pinvokePreserveLlFilePath } '", pinvokePreserveWriter . BaseStream ) ;
95
+ }
90
96
}
91
97
}
92
98
93
99
var marshalMethodsModule = marshalMethodsAsmGen . Construct ( ) ;
94
100
using var marshalMethodsWriter = MemoryStreamPool . Shared . CreateStreamWriter ( ) ;
95
101
102
+ fileFullyWritten = false ;
96
103
try {
97
104
marshalMethodsAsmGen . Generate ( marshalMethodsModule , targetArch , marshalMethodsWriter , marshalMethodsLlFilePath ) ;
98
- } finally {
99
105
marshalMethodsWriter . Flush ( ) ;
100
106
Files . CopyIfStreamChanged ( marshalMethodsWriter . BaseStream , marshalMethodsLlFilePath ) ;
107
+ fileFullyWritten = true ;
108
+ } finally {
109
+ if ( ! fileFullyWritten ) {
110
+ MonoAndroidHelper . LogTextStreamContents ( Log , $ "Partial contents of file '{ marshalMethodsLlFilePath } '", marshalMethodsWriter . BaseStream ) ;
111
+ }
101
112
}
102
113
103
114
MarshalMethodsNativeAssemblyGenerator MakeMonoGenerator ( )
0 commit comments