Skip to content

Commit

Permalink
[illink] Do not preserve whole collection types
Browse files Browse the repository at this point in the history
Context: dotnet#5167
Context: dotnet#5206

Instead of preserving these types unconditionally, use the new dynamic
dependency attributes

apksize 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)
  • Loading branch information
radekdoulik committed Dec 22, 2020
1 parent 09baa52 commit 56f7474
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@
<type fullname="Android.Runtime.JObjectRefType" />
<type fullname="Android.Runtime.JValue" />
<!-- it seems that generics identifier `n is not taken into consideration though ... -->
<type fullname="Android.Runtime.JavaArray`1" />
<type fullname="Android.Runtime.JavaCollection" />
<type fullname="Android.Runtime.JavaCollection`1" />
<type fullname="Android.Runtime.JavaDictionary" />
<type fullname="Android.Runtime.JavaDictionary`2" />
<type fullname="Android.Runtime.JavaList" />
<type fullname="Android.Runtime.JavaList`1" />
<type fullname="Android.Runtime.JavaSet" />
<type fullname="Android.Runtime.JavaSet`1" />
<type fullname="Android.Runtime.JavaTypeConverter`1" />
<type fullname="Android.Runtime.JniHandleOwnership" />
<type fullname="Android.Runtime.Logger" />
Expand Down
10 changes: 10 additions & 0 deletions src/Mono.Android.Export/CallbackCode.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -406,6 +407,15 @@ public CodeExpression FromNative (CodeExpression arg)
}

// Ignore ToNative() overload that takes generic instancing mapping. The reflected method should have nothing to do with it.
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaArray", "Mono.Android")]
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaCollection", "Mono.Android")]
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaCollection`1", "Mono.Android")]
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaDictionary", "Mono.Android")]
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaDictionary`2", "Mono.Android")]
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaList", "Mono.Android")]
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaList`1", "Mono.Android")]
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaSet", "Mono.Android")]
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaSet`1", "Mono.Android")]
public CodeExpression ToNative (CodeExpression arg)
{
switch (GetKind (type)) {
Expand Down
1 change: 1 addition & 0 deletions src/Mono.Android/Properties/AssemblyInfo.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ using System.Runtime.CompilerServices;
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Drawing.Size))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Drawing.SizeF))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Drawing.SystemColors))]
[assembly: InternalsVisibleTo("Mono.Android.Export, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
[assembly: InternalsVisibleTo("Mono.Android-Tests, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
[assembly: InternalsVisibleTo("Java.Interop-Tests, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
[assembly: InternalsVisibleTo("Mono.Android-TestsMultiDex, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
Expand Down

0 comments on commit 56f7474

Please sign in to comment.