@@ -2176,9 +2176,11 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
21762176 MarshalManagedExceptionMode mode ;
21772177 GCHandle exception_gchandle = INVALID_GCHANDLE ;
21782178
2179- GCHandle handle = xamarin_gchandle_new (exception , false);
2180- mode = xamarin_on_marshal_managed_exception (handle , & exception_gchandle );
2181- xamarin_gchandle_free (handle );
2179+ {
2180+ GCHandle handle = xamarin_gchandle_new (exception , false);
2181+ mode = xamarin_on_marshal_managed_exception (handle , & exception_gchandle );
2182+ xamarin_gchandle_free (handle );
2183+ }
21822184
21832185 if (exception_gchandle != INVALID_GCHANDLE ) {
21842186 PRINT (PRODUCT ": Got an exception while executing the MarshalManagedException event (this exception will be ignored):" );
@@ -2197,7 +2199,7 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
21972199 switch (mode ) {
21982200#if !defined (CORECLR_RUNTIME ) // CoreCLR won't unwind through native frames, so we'll have to abort (in the default case statement)
21992201 case MarshalManagedExceptionModeDisable :
2200- case MarshalManagedExceptionModeUnwindNativeCode :
2202+ case MarshalManagedExceptionModeUnwindNativeCode : {
22012203 //
22022204 // We want to maintain the original stack trace of the exception, but unfortunately
22032205 // calling mono_raise_exception directly with the original exception will overwrite
@@ -2210,7 +2212,7 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
22102212 // to throw an exception that contains the original stack trace.
22112213 //
22122214
2213- handle = xamarin_gchandle_new (exception , false);
2215+ GCHandle handle = xamarin_gchandle_new (exception , false);
22142216 xamarin_rethrow_managed_exception (handle , & exception_gchandle );
22152217 xamarin_gchandle_free (handle );
22162218
@@ -2231,8 +2233,9 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
22312233 xamarin_handling_unhandled_exceptions = 0 ;
22322234
22332235 mono_raise_exception ((MonoException * ) exception );
2234- #endif
22352236 break ;
2237+ }
2238+ #endif
22362239 case MarshalManagedExceptionModeThrowObjectiveCException : {
22372240 GCHandle handle = xamarin_gchandle_new (exception , false);
22382241 NSException * ns_exc = xamarin_unwrap_ns_exception (handle , & exception_gchandle );
@@ -2295,13 +2298,14 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
22952298 case MarshalManagedExceptionModeUnwindNativeCode :
22962299#endif
22972300 case MarshalManagedExceptionModeAbort :
2298- default :
2299- handle = xamarin_gchandle_new (exception , false);
2301+ default : {
2302+ GCHandle handle = xamarin_gchandle_new (exception , false);
23002303 const char * msg = [xamarin_print_all_exceptions (handle ) UTF8String ];
23012304 xamarin_gchandle_free (handle );
23022305 xamarin_assertion_message ("Aborting due to trying to marshal managed exception:\n%s\n" , msg );
23032306 break ;
23042307 }
2308+ }
23052309}
23062310
23072311void
0 commit comments