Skip to content

Commit 15269f6

Browse files
authored
[One .NET] Do not preserve entire collection types (#5445)
Context: #5167 Context: #5206 Instead of preserving the `Android.Runtime.Java*` collection types unconditionally, use the new dynamic dependency attributes from 7083eba. `.apk` size impact on BuildReleaseArm64False test: > lapkdiff -f -e dll$ before.apk after.apk Size difference in bytes ([*1] apk1 only, [*2] apk2 only): - 477 assemblies/Java.Interop.dll - 603 assemblies/System.Collections.Concurrent.dll - 1,388 assemblies/System.Private.CoreLib.dll - 30,291 assemblies/Mono.Android.dll Summary: - 32,759 Assemblies -4.19% (of 781,837) - 32,768 Package size difference -0.43% (of 7,645,409)
1 parent 1b7d73b commit 15269f6

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/Microsoft.Android.Sdk.ILLink/PreserveLists/Mono.Android.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@
1616
<type fullname="Android.Runtime.JObjectRefType" />
1717
<type fullname="Android.Runtime.JValue" />
1818
<!-- it seems that generics identifier `n is not taken into consideration though ... -->
19-
<type fullname="Android.Runtime.JavaArray`1" />
20-
<type fullname="Android.Runtime.JavaCollection" />
21-
<type fullname="Android.Runtime.JavaCollection`1" />
22-
<type fullname="Android.Runtime.JavaDictionary" />
23-
<type fullname="Android.Runtime.JavaDictionary`2" />
24-
<type fullname="Android.Runtime.JavaList" />
25-
<type fullname="Android.Runtime.JavaList`1" />
26-
<type fullname="Android.Runtime.JavaSet" />
27-
<type fullname="Android.Runtime.JavaSet`1" />
2819
<type fullname="Android.Runtime.JavaTypeConverter`1" />
2920
<type fullname="Android.Runtime.JniHandleOwnership" />
3021
<type fullname="Android.Runtime.Logger" />

src/Mono.Android.Export/CallbackCode.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using System.Diagnostics.CodeAnalysis;
45
using System.IO;
56
using System.Linq;
67
using System.Reflection;
@@ -406,6 +407,15 @@ public CodeExpression FromNative (CodeExpression arg)
406407
}
407408

408409
// Ignore ToNative() overload that takes generic instancing mapping. The reflected method should have nothing to do with it.
410+
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaArray", "Mono.Android")]
411+
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaCollection", "Mono.Android")]
412+
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaCollection`1", "Mono.Android")]
413+
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaDictionary", "Mono.Android")]
414+
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaDictionary`2", "Mono.Android")]
415+
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaList", "Mono.Android")]
416+
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaList`1", "Mono.Android")]
417+
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaSet", "Mono.Android")]
418+
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaSet`1", "Mono.Android")]
409419
public CodeExpression ToNative (CodeExpression arg)
410420
{
411421
switch (GetKind (type)) {

src/Mono.Android/Properties/AssemblyInfo.cs.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ using System.Runtime.CompilerServices;
2727
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Drawing.Size))]
2828
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Drawing.SizeF))]
2929
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Drawing.SystemColors))]
30+
[assembly: InternalsVisibleTo("Mono.Android.Export, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
3031
[assembly: InternalsVisibleTo("Mono.Android-Tests, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
3132
[assembly: InternalsVisibleTo("Java.Interop-Tests, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
3233
[assembly: InternalsVisibleTo("Mono.Android-TestsMultiDex, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]

0 commit comments

Comments
 (0)