@@ -523,12 +523,22 @@ static IEnumerable<object[]> Get_BuildHasTrimmerWarningsData ()
523523
524524 foreach ( AndroidRuntime runtime in Enum . GetValues ( typeof ( AndroidRuntime ) ) ) {
525525 AddTestData ( runtime , "" , new string [ 0 ] , false ) ;
526- AddTestData ( runtime , "" , new string [ 0 ] , true ) ;
526+
527+ if ( runtime == AndroidRuntime . NativeAOT ) {
528+ AddTestData ( runtime , "" , new [ ] { "IL2055" , "IL3050" } , true , 2 ) ;
529+ } else {
530+ AddTestData ( runtime , "" , new string [ 0 ] , true ) ;
531+ }
527532 AddTestData ( runtime , "SuppressTrimAnalysisWarnings=false" , new string [ ] { "IL2055" } , true , 2 ) ;
528533 AddTestData ( runtime , "TrimMode=full" , new string [ ] { "IL2055" } , false , 1 ) ;
529534 AddTestData ( runtime , "TrimMode=full" , new string [ ] { "IL2055" } , true , 2 ) ;
530535 AddTestData ( runtime , "IsAotCompatible=true" , new string [ ] { "IL2055" , "IL3050" } , false ) ;
531- AddTestData ( runtime , "IsAotCompatible=true" , new string [ ] { "IL2055" , "IL3050" } , true , 3 ) ;
536+
537+ if ( runtime == AndroidRuntime . NativeAOT ) {
538+ AddTestData ( runtime , "IsAotCompatible=true" , new string [ ] { "IL2055" , "IL3050" } , true , 2 ) ;
539+ } else {
540+ AddTestData ( runtime , "IsAotCompatible=true" , new string [ ] { "IL2055" , "IL3050" } , true , 3 ) ;
541+ }
532542 }
533543
534544 return ret ;
@@ -557,6 +567,15 @@ public void BuildHasTrimmerWarnings (AndroidRuntime runtime, string properties,
557567 IsRelease = isRelease ,
558568 } ;
559569 proj . SetRuntime ( runtime ) ;
570+
571+ if ( runtime == AndroidRuntime . NativeAOT ) {
572+ // We're not interested in ILC warnings here, just the trimmer warnings before ILC runs
573+ var ignoreIlcWarnings = new List < BuildItem > {
574+ new ( "IlcArg" , "--notrimwarn" ) ,
575+ new ( "IlcArg" , "--noaotwarn" ) ,
576+ } ;
577+ proj . ItemGroupList . Add ( ignoreIlcWarnings ) ;
578+ }
560579 proj . SetRuntimeIdentifier ( "arm64-v8a" ) ;
561580 proj . MainActivity = proj . DefaultMainActivity
562581 . Replace ( "//${FIELDS}" , "Type type = typeof (List<>);" )
@@ -576,23 +595,7 @@ public void BuildHasTrimmerWarnings (AndroidRuntime runtime, string properties,
576595 Assert . IsTrue ( b . Build ( proj ) , "Build should have succeeded." ) ;
577596
578597 if ( codes . Length == 0 ) {
579- if ( runtime == AndroidRuntime . NativeAOT ) {
580- const string expectedWarningIL3050 = "ILC : AOT analysis warning IL3050:" ;
581- const int numberOfExpectedWarnings = 7 ;
582-
583- Assert . IsTrue (
584- StringAssertEx . ContainsText (
585- b . LastBuildOutput ,
586- $ " { numberOfExpectedWarnings } Warning(s)"
587- ) ,
588- $ "{ b . BuildLogFile } should have exactly { numberOfExpectedWarnings } MSBuild warnings for NativeAOT."
589- ) ;
590-
591- var warnings = b . LastBuildOutput . SkipWhile ( x => ! x . StartsWith ( "Build succeeded." , StringComparison . Ordinal ) ) . Where ( x => x . Contains ( expectedWarningIL3050 , StringComparison . Ordinal ) ) ;
592- Assert . IsTrue ( warnings . Count ( ) == numberOfExpectedWarnings , $ "Expected { numberOfExpectedWarnings } 'IL3050' warnings, found { warnings . Count ( ) } ") ;
593- } else {
594- b . AssertHasNoWarnings ( ) ;
595- }
598+ b . AssertHasNoWarnings ( ) ;
596599 } else {
597600 totalWarnings ??= codes . Length ;
598601 Assert . True ( StringAssertEx . ContainsText ( b . LastBuildOutput , $ "{ totalWarnings } Warning(s)") , $ "Should receive { totalWarnings } warnings") ;
0 commit comments