Skip to content

Commit 4086a74

Browse files
committed
Merge branch 'main' into dev/grendel/native-tracing
* main: [trimming] fix custom applications for `TrimMode=full` (#8936)
2 parents 23fde10 + 98c1063 commit 4086a74

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/Microsoft.Android.Sdk.ILLink/PreserveApplications.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ void PreserveTypeProperty (CustomAttribute attribute, string property)
6666
if (!attribute.HasProperties)
6767
return;
6868

69-
var type_ref = (TypeReference) attribute.Properties.First (p => p.Name == property).Argument.Value;
69+
// NOTE: CustomAttributeNamedArgument is a struct
70+
var named_arg = attribute.Properties.FirstOrDefault (p => p.Name == property);
71+
if (named_arg.Name == null)
72+
return;
73+
74+
var type_ref = named_arg.Argument.Value as TypeReference;
7075
if (type_ref == null)
7176
return;
7277

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,9 +1083,11 @@ public void BuildAfterMultiDexIsNotRequired ()
10831083
}
10841084

10851085
[Test]
1086-
public void CustomApplicationClassAndMultiDex ()
1086+
public void CustomApplicationClassAndMultiDex ([Values (true, false)] bool isRelease)
10871087
{
10881088
var proj = CreateMultiDexRequiredApplication ();
1089+
proj.IsRelease = isRelease;
1090+
proj.TrimModeRelease = TrimMode.Full;
10891091
proj.SetProperty ("AndroidEnableMultiDex", "True");
10901092
proj.Sources.Add (new BuildItem ("Compile", "CustomApp.cs") { TextContent = () => @"
10911093
using System;
@@ -1108,7 +1110,7 @@ public override void OnCreate()
11081110
}
11091111
}
11101112
}" });
1111-
using (var b = CreateApkBuilder ("temp/CustomApplicationClassAndMultiDex")) {
1113+
using (var b = CreateApkBuilder ()) {
11121114
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
11131115
Assert.IsFalse (b.LastBuildOutput.ContainsText ("Duplicate zip entry"), "Should not get warning about [META-INF/MANIFEST.MF]");
11141116
var customAppContent = File.ReadAllText (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "src", "com", "foxsports", "test", "CustomApp.java"));

src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocumentElement.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ public static string ToString (TypeDefinition typeDef, TypeDefinitionCache cache
2929

3030
public static TypeDefinition ResolveType (string type, ICustomAttributeProvider provider, IAssemblyResolver resolver)
3131
{
32+
if (type == null)
33+
throw new ArgumentException ("Type resolution support requires a non-null Type.", nameof (type));
3234
if (provider == null)
33-
throw new ArgumentException ("Type resolution support requires an AssemblyDefinition or TypeDefinition.", "provider");
35+
throw new ArgumentException ("Type resolution support requires an AssemblyDefinition or TypeDefinition.", nameof (provider));
3436
if (resolver == null)
35-
throw new ArgumentException ("Type resolution support requires a IAssemblyResolver.", "resolver");
37+
throw new ArgumentException ("Type resolution support requires a IAssemblyResolver.", nameof (resolver));
3638

3739
// `type` is either a "bare" type "Foo.Bar", or an
3840
// assembly-qualified type "Foo.Bar, AssemblyName [Version=...]?".

0 commit comments

Comments
 (0)