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
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class ResolveLibraryProjectImports : AndroidTask
[Required]
public bool DesignTimeBuild { get; set; }

public bool AndroidApplication { get; set; }

[Output]
public ITaskItem [] Jars { get; set; }

Expand Down Expand Up @@ -442,7 +444,7 @@ void Extract (
resolvedAssetDirectories.Add (new TaskItem (Path.GetFullPath (assetsDir), new Dictionary<string, string> {
{ OriginalFile, aarFullPath },
}));
if (File.Exists (proguardFile)) {
if (AndroidApplication && File.Exists (proguardFile)) {
proguardConfigFiles.Add (new TaskItem (Path.GetFullPath (proguardFile), new Dictionary<string, string> {
{ OriginalFile, aarFullPath },
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ public static void AssertTargetIsPartiallyBuilt (this BuildOutput output, string
Assert.IsTrue (output.IsTargetPartiallyBuilt (target), $"The target {target} should have been partially built.");
}

[DebuggerHidden]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would a unit test method need [DebuggerHidden]?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

though i see some of the other Assert* methods have [DebuggerHidden]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The on assertion-style methods in this file, it allows the debugger to break on the line in your test instead of inside here.

It's really optional, and maybe only useful inside IDEs?

public static void AssertEntryEquals (this ZipArchive zip, string zipPath, string archivePath, string expected)
{
zip.AssertContainsEntry (zipPath, archivePath);

var entry = zip.ReadEntry (archivePath);
using var stream = new MemoryStream ();
entry.Extract (stream);
stream.Position = 0;
using var reader = new StreamReader (stream);
Assert.AreEqual (expected, reader.ReadToEnd ().Trim ());
}

[DebuggerHidden]
public static void AssertContainsEntry (this ZipArchive zip, string zipPath, string archivePath)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void DotNetBuildLibrary (bool isRelease, bool duplicateAar, bool useDesig
BinaryContent = () => XamarinAndroidApplicationProject.icon_binary_mdpi,
},
new AndroidItem.ProguardConfiguration ("proguard.txt") {
TextContent = () => @"-ignorewarnings",
TextContent = () => "# LibraryC",
},
}
};
Expand All @@ -97,7 +97,7 @@ public void DotNetBuildLibrary (bool isRelease, bool duplicateAar, bool useDesig
FileAssert.Exists (aarPath);
using (var aar = ZipHelper.OpenZip (aarPath)) {
aar.AssertContainsEntry (aarPath, "assets/bar/bar.txt");
aar.AssertContainsEntry (aarPath, "proguard.txt");
aar.AssertEntryEquals (aarPath, "proguard.txt", "# LibraryC");
}

var libB = new XASdkProject (outputType: "Library") {
Expand Down Expand Up @@ -139,7 +139,7 @@ public Foo ()
TextContent = () => ResourceData.JavaSourceTestExtension,
},
new AndroidItem.ProguardConfiguration ("proguard.txt") {
TextContent = () => @"-ignorewarnings",
TextContent = () => "# LibraryB",
},
}
};
Expand Down Expand Up @@ -185,6 +185,8 @@ public Foo ()
aar.AssertContainsEntry (aarPath, $"libs/{projectJarHash}.jar");
aar.AssertContainsEntry (aarPath, "jni/arm64-v8a/libfoo.so");
aar.AssertContainsEntry (aarPath, "jni/x86/libfoo.so");
// proguard.txt from Library C should not flow to Library B and "double"
aar.AssertEntryEquals (aarPath, "proguard.txt", "# LibraryB");
Comment on lines +188 to +189
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok with the updated test, this was previously failing with:

Expected string length 10 but was 22. Strings differ at index 10.
  Expected: "# LibraryB"
  But was:  "# LibraryB\r\n# LibraryC"

So this is better than using an .aar from maven.

}

// Check EmbeddedResource files do not exist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ This file is used by all project types, including binding projects.
Outputs="$(_AndroidStampDirectory)_ResolveLibraryProjectImports.stamp">
<ResolveLibraryProjectImports
ContinueOnError="$(DesignTimeBuild)"
AndroidApplication="$(AndroidApplication)"
CacheFile="$(_AndroidLibraryProjectImportsCache)"
DesignTimeBuild="$(DesignTimeBuild)"
Assemblies="@(_MonoAndroidReferencePath);@(_MonoAndroidReferenceDependencyPaths)"
Expand Down