diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets
index 62bb7370194..7fcd3d31fe7 100644
--- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets
+++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets
@@ -85,7 +85,7 @@
full
partial
- false
+ false
true
android-arm;android-arm64;android-x86;android-x64
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs
index b517429a188..30b93598aa9 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs
@@ -269,6 +269,48 @@ public void BuildHasNoWarnings (bool isRelease, bool xamarinForms, bool multidex
}
}
+ [Test]
+ [TestCase ("", new string [0], false)]
+ [TestCase ("", new string [0], true)]
+ [TestCase ("SuppressTrimAnalysisWarnings=false", new string [] { "IL2055" }, true, 2)]
+ [TestCase ("TrimMode=full", new string [0], false)]
+ [TestCase ("TrimMode=full", new string [] { "IL2055" }, true, 2)]
+ [TestCase ("IsAotCompatible=true", new string [] { "IL2055", "IL3050" }, false)]
+ [TestCase ("IsAotCompatible=true", new string [] { "IL2055", "IL3050" }, true, 3)]
+ public void BuildHasTrimmerWarnings (string properties, string [] codes, bool isRelease, int? totalWarnings = null)
+ {
+ var proj = new XamarinAndroidApplicationProject {
+ IsRelease = isRelease,
+ };
+ proj.SetRuntimeIdentifier ("arm64-v8a");
+ proj.MainActivity = proj.DefaultMainActivity
+ .Replace ("//${FIELDS}", "Type type = typeof (List<>);")
+ .Replace ("//${AFTER_ONCREATE}", "Console.WriteLine (type.MakeGenericType (typeof (object)));");
+ proj.SetProperty ("TrimmerSingleWarn", "false");
+
+ if (!string.IsNullOrEmpty (properties)) {
+ foreach (var property in properties.Split (';')) {
+ int index = property.IndexOf ('=');
+ if (index != -1) {
+ proj.SetProperty (property [..index], property [(index + 1)..]);
+ }
+ }
+ }
+
+ using var b = CreateApkBuilder (Path.Combine ("temp", TestName));
+ Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
+
+ if (codes.Length == 0) {
+ b.AssertHasNoWarnings ();
+ } else {
+ totalWarnings ??= codes.Length;
+ Assert.True (StringAssertEx.ContainsText (b.LastBuildOutput, $"{totalWarnings} Warning(s)"), $"Should receive {totalWarnings} warnings");
+ foreach (var code in codes) {
+ Assert.True (StringAssertEx.ContainsText (b.LastBuildOutput, code), $"Should receive {code} warning");
+ }
+ }
+ }
+
[Test]
[TestCase ("AndroidFastDeploymentType", "Assemblies", true, false)]
[TestCase ("AndroidFastDeploymentType", "Assemblies", false, false)]
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/MainActivity.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/MainActivity.cs
index 8e1a16169e6..98a18bc4b55 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/MainActivity.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/MainActivity.cs
@@ -13,6 +13,7 @@ namespace ${ROOT_NAMESPACE}
[Register ("${JAVA_PACKAGENAME}.MainActivity"), Activity (Label = "${PROJECT_NAME}", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
+ //${FIELDS}
int count = 1;
protected override void OnCreate (Bundle bundle)
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/DotNet/MainActivity.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/DotNet/MainActivity.cs
index 7b6e41efcd7..4fe99b77517 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/DotNet/MainActivity.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/DotNet/MainActivity.cs
@@ -4,6 +4,7 @@ namespace ${ROOT_NAMESPACE}
[Android.Runtime.Register ("${JAVA_PACKAGENAME}.MainActivity"), Activity (Label = "${PROJECT_NAME}", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
+ //${FIELDS}
int count = 1;
protected override void OnCreate (Bundle? bundle)