From 051cad7972033b1b9c8b9fbea3be1b90c1c23fa9 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Mon, 4 Jan 2021 18:29:48 +0100 Subject: [PATCH] [One .NET] Do not preserve IO stream adapter/invoker (#5449) Context: https://github.com/xamarin/xamarin-android/issues/5167 Context: https://github.com/xamarin/xamarin-android/issues/5206 The following types are accessed through the `CallbackCode` type in `src/Mono.Android.Export` via System.Reflection: * `Android.Runtime.InputStreamAdapter` * `Android.Runtime.InputStreamInvoker` * `Android.Runtime.OutputStreamAdapter` * `Android.Runtime.OutputStreamInvoker` Historically the use of these types via Reflection required that they always be preserved, just in case `Mono.Android.Export.dll` was used. .NET 6 ILLink is able to detect such reflection use. These types no longer need to be explicitly preserved in all circumstances. Stop explicitly preserving these types, and rely on ILLink to preserve them when `Mono.Android.Export.dll` is used. This change reduces the `.apk` size in a common situation, when `Mono.Android.Export.dll` is not used. apk size comparison, BuildReleaseArm64False test: > apkdiff -f -e dll$ before.apk after.apk Size difference in bytes ([*1] apk1 only, [*2] apk2 only): - 80 assemblies/System.Console.dll - 129 assemblies/Java.Interop.dll - 1,237 assemblies/System.Private.CoreLib.dll - 6,093 assemblies/Mono.Android.dll Summary: - 7,539 Assemblies -1.01% (of 749,078) --- .../PreserveLists/Mono.Android.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Microsoft.Android.Sdk.ILLink/PreserveLists/Mono.Android.xml b/src/Microsoft.Android.Sdk.ILLink/PreserveLists/Mono.Android.xml index 3958d28e331..24c014afc59 100644 --- a/src/Microsoft.Android.Sdk.ILLink/PreserveLists/Mono.Android.xml +++ b/src/Microsoft.Android.Sdk.ILLink/PreserveLists/Mono.Android.xml @@ -5,8 +5,6 @@ - - @@ -34,8 +32,6 @@ - -