diff --git a/src/Microsoft.Android.Sdk.ILLink/PreserveApplications.cs b/src/Microsoft.Android.Sdk.ILLink/PreserveApplications.cs index 99ca8df9384..5e3e1b0c44d 100644 --- a/src/Microsoft.Android.Sdk.ILLink/PreserveApplications.cs +++ b/src/Microsoft.Android.Sdk.ILLink/PreserveApplications.cs @@ -66,7 +66,12 @@ void PreserveTypeProperty (CustomAttribute attribute, string property) if (!attribute.HasProperties) return; - var type_ref = (TypeReference) attribute.Properties.First (p => p.Name == property).Argument.Value; + // NOTE: CustomAttributeNamedArgument is a struct + var named_arg = attribute.Properties.FirstOrDefault (p => p.Name == property); + if (named_arg.Name == null) + return; + + var type_ref = named_arg.Argument.Value as TypeReference; if (type_ref == null) return; diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs index 2394f7804d9..6cf5a5a88a0 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs @@ -1083,9 +1083,11 @@ public void BuildAfterMultiDexIsNotRequired () } [Test] - public void CustomApplicationClassAndMultiDex () + public void CustomApplicationClassAndMultiDex ([Values (true, false)] bool isRelease) { var proj = CreateMultiDexRequiredApplication (); + proj.IsRelease = isRelease; + proj.TrimModeRelease = TrimMode.Full; proj.SetProperty ("AndroidEnableMultiDex", "True"); proj.Sources.Add (new BuildItem ("Compile", "CustomApp.cs") { TextContent = () => @" using System; @@ -1108,7 +1110,7 @@ public override void OnCreate() } } }" }); - using (var b = CreateApkBuilder ("temp/CustomApplicationClassAndMultiDex")) { + using (var b = CreateApkBuilder ()) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); Assert.IsFalse (b.LastBuildOutput.ContainsText ("Duplicate zip entry"), "Should not get warning about [META-INF/MANIFEST.MF]"); var customAppContent = File.ReadAllText (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "src", "com", "foxsports", "test", "CustomApp.java")); diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocumentElement.cs b/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocumentElement.cs index 3139f366fb8..ef3a475a3e4 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocumentElement.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocumentElement.cs @@ -29,10 +29,12 @@ public static string ToString (TypeDefinition typeDef, TypeDefinitionCache cache public static TypeDefinition ResolveType (string type, ICustomAttributeProvider provider, IAssemblyResolver resolver) { + if (type == null) + throw new ArgumentException ("Type resolution support requires a non-null Type.", nameof (type)); if (provider == null) - throw new ArgumentException ("Type resolution support requires an AssemblyDefinition or TypeDefinition.", "provider"); + throw new ArgumentException ("Type resolution support requires an AssemblyDefinition or TypeDefinition.", nameof (provider)); if (resolver == null) - throw new ArgumentException ("Type resolution support requires a IAssemblyResolver.", "resolver"); + throw new ArgumentException ("Type resolution support requires a IAssemblyResolver.", nameof (resolver)); // `type` is either a "bare" type "Foo.Bar", or an // assembly-qualified type "Foo.Bar, AssemblyName [Version=...]?".