Skip to content

Commit 051cad7

Browse files
authored
[One .NET] Do not preserve IO stream adapter/invoker (#5449)
Context: #5167 Context: #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)
1 parent 9a66530 commit 051cad7

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

Diff for: src/Microsoft.Android.Sdk.ILLink/PreserveLists/Mono.Android.xml

-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
<type fullname="Android.Runtime.GeneratedDummyHost" />
66
<type fullname="Android.Runtime.GeneratedEnumAttribute" />
77
<type fullname="Android.Runtime.IJavaObject" />
8-
<type fullname="Android.Runtime.InputStreamAdapter" />
9-
<type fullname="Android.Runtime.InputStreamInvoker" />
108
<type fullname="Android.Runtime.JNIEnv">
119
<method name="Exit" />
1210
<method name="Initialize" />
@@ -34,8 +32,6 @@
3432
<type fullname="Android.Runtime.LogLevel" />
3533
<type fullname="Android.Runtime.LogCategories" />
3634
<type fullname="Android.Runtime.NamespaceMappingAttribute" />
37-
<type fullname="Android.Runtime.OutputStreamAdapter" />
38-
<type fullname="Android.Runtime.OutputStreamInvoker" />
3935
<type fullname="Android.Runtime.PreserveAttribute" />
4036
<type fullname="Android.Runtime.RaiseThrowableEventArgs" />
4137
<type fullname="Android.Runtime.RegisterAttribute" />

0 commit comments

Comments
 (0)