Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Microsoft.Android.Sdk.ILLink/PreserveApplications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=...]?".
Expand Down