From 5ff483a09f25eeceda7047d69000a50d33150fe2 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 24 Sep 2024 12:11:29 -0500 Subject: [PATCH] [trimming] `TrimMode=full` in debug mode, should enable analyzers For AOT scenarios, projects would set: true For both `Debug` and `Release`, this allows you to get the same set of analyzers in both configurations. You'd want to see the same warnings for both. For Android, the project template is currently doing: Full But this would result in a *different* set of warnings between `Debug` and `Release` mode! Instead, we can do: Full And then add a new default, such as: true `TrimMode=Full` does *not* enable the trimmer, so other defaults in `Debug` should remain unchanged. So, the new behavior is: * `Configuration=Debug` * `PublishTrimmed=false` (default, no trimmer) * `TrimMode=Full` (project template) * `EnableTrimAnalyzer=true` (new default) * You get the same warnings in `Debug` and `Release` mode. I also reworded the commend in the project template slightly, to mention it enables analyzers. --- .../android-wear/AndroidApp1.csproj | 10 ++++------ .../android/AndroidApp1.csproj | 10 ++++------ .../Microsoft.Android.Sdk.DefaultProperties.targets | 1 + .../Tests/Xamarin.Android.Build.Tests/BuildTest2.cs | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.Android.Templates/android-wear/AndroidApp1.csproj b/src/Microsoft.Android.Templates/android-wear/AndroidApp1.csproj index e257d04c90b..8a3e5067f79 100644 --- a/src/Microsoft.Android.Templates/android-wear/AndroidApp1.csproj +++ b/src/Microsoft.Android.Templates/android-wear/AndroidApp1.csproj @@ -10,12 +10,10 @@ 1 1.0 $(MSBuildWarningsAsMessages);XA4218 - - - + full diff --git a/src/Microsoft.Android.Templates/android/AndroidApp1.csproj b/src/Microsoft.Android.Templates/android/AndroidApp1.csproj index c539a1f4c45..514d24bf1c9 100644 --- a/src/Microsoft.Android.Templates/android/AndroidApp1.csproj +++ b/src/Microsoft.Android.Templates/android/AndroidApp1.csproj @@ -9,12 +9,10 @@ com.companyname.AndroidApp1 1 1.0 - - - + full \ No newline at end of file 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 6cfdd2141b5..b73a74d5288 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 @@ -123,6 +123,7 @@ false true true + true false 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 b3da2309428..c70f8423a00 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,7 +269,7 @@ public void BuildHasNoWarnings (bool isRelease, bool xamarinForms, bool multidex [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" }, false, 1)] [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)]