@@ -48,24 +48,20 @@ public override bool RunTask ()
4848 var steps = new List < IAssemblyModifierPipelineStep > ( ) ;
4949 steps . Add ( new StripEmbeddedLibrariesStep ( Log ) ) ;
5050
51- // FixAbstractMethods — memoize Mono.Android resolution so the attempt (and any error
52- // logging) happens at most once, regardless of how many assemblies need fixing .
51+ // FixAbstractMethods — resolve Mono.Android once up front. If resolution fails, log
52+ // the error and skip running the fix step entirely to avoid later unhandled exceptions .
5353 AssemblyDefinition ? monoAndroidAssembly = null ;
54- bool monoAndroidResolutionAttempted = false ;
55- steps . Add ( new PostTrimmingFixAbstractMethodsStep ( cache ,
56- ( ) => {
57- if ( ! monoAndroidResolutionAttempted ) {
58- monoAndroidResolutionAttempted = true ;
59- try {
60- monoAndroidAssembly = resolver . Resolve ( AssemblyNameReference . Parse ( "Mono.Android" ) ) ;
61- } catch ( AssemblyResolutionException ex ) {
62- Log . LogErrorFromException ( ex , showStackTrace : false ) ;
63- }
64- }
65- return monoAndroidAssembly ;
66- } ,
67- ( msg ) => Log . LogDebugMessage ( msg ) ,
68- ( msg ) => Log . LogCodedWarning ( "XA2000" , msg ) ) ) ;
54+ try {
55+ monoAndroidAssembly = resolver . Resolve ( AssemblyNameReference . Parse ( "Mono.Android" ) ) ;
56+ } catch ( AssemblyResolutionException ex ) {
57+ Log . LogErrorFromException ( ex , showStackTrace : false ) ;
58+ }
59+ if ( monoAndroidAssembly != null ) {
60+ steps . Add ( new PostTrimmingFixAbstractMethodsStep ( cache ,
61+ ( ) => monoAndroidAssembly ,
62+ ( msg ) => Log . LogDebugMessage ( msg ) ,
63+ ( msg ) => Log . LogCodedWarning ( "XA2000" , msg ) ) ) ;
64+ }
6965
7066 if ( AddKeepAlives ) {
7167 // Memoize the corlib resolution so the attempt (and any error logging) happens at most once,
0 commit comments