-
Notifications
You must be signed in to change notification settings - Fork 564
Open
Labels
Area: App+Library BuildIssues when building Library projects or Application projects.Issues when building Library projects or Application projects.bugComponent does not function as intended.Component does not function as intended.
Milestone
Description
This is a follow-up to #2310. Once that issue is fixed for fragment elements, the same logic should be applied to class attributes on transition elements and app:layout_behavior attributes on custom layout behaviors. That way all of these similar XML attributes will support the same kinds of replacements for fully assembly-qualified managed type names.
Steps to Reproduce
Add the following tests to ConvertResourcesCasesTests and run them:
[Test]
public void CustomTransitionClassAttributes ()
{
var path = Path.Combine (Root, "temp", "CustomTransitionClassAttributes");
Directory.CreateDirectory (path);
var resPath = Path.Combine (path, "res");
Directory.CreateDirectory (Path.Combine (resPath, "transition"));
File.WriteAllText (Path.Combine (resPath, "transition", "custom_transition.xml"), @"<?xml version='1.0' ?>
<transitionSet xmlns:android='http://schemas.android.com/apk/res/android'>
<transition class='ClassLibrary1.CustomTransition' />
<transition class='ClassLibrary1.CustomTransition, ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' />
</transitionSet>");
var errors = new List<BuildErrorEventArgs> ();
IBuildEngine engine = new MockBuildEngine (TestContext.Out, errors);
var task = new ConvertResourcesCases {
BuildEngine = engine
};
task.ResourceDirectories = new ITaskItem [] {
new TaskItem (resPath),
};
task.AcwMapFile = Path.Combine (path, "acwmap.txt");
task.CustomViewMapFile = Path.Combine (path, "classmap.txt");
File.WriteAllLines (task.AcwMapFile, new string [] {
"ClassLibrary1.CustomTransition, ClassLibrary1;md5d6f7135293df7527c983d45d07471c5e.CustomTransition",
"ClassLibrary1.CustomTransition;md5d6f7135293df7527c983d45d07471c5e.CustomTransition",
"classLibrary1.CustomTransition;md5d6f7135293df7527c983d45d07471c5e.CustomTransition"
});
Assert.IsTrue (task.Execute (), "Task should have executed successfully");
var custom = new ConvertCustomView () {
BuildEngine = engine,
CustomViewMapFile = task.CustomViewMapFile,
AcwMapFile = task.AcwMapFile,
ResourceDirectories = new ITaskItem [] {
new TaskItem (resPath),
},
};
Assert.IsTrue (custom.Execute (), "Task should have executed successfully");
var output = File.ReadAllText (Path.Combine (resPath, "transition", "custom_transition.xml"));
StringAssert.Contains ("md5d6f7135293df7527c983d45d07471c5e.CustomTransition", output, "md5d6f7135293df7527c983d45d07471c5e.CustomTransition should exist in the main.xml");
StringAssert.DoesNotContain ("ClassLibrary1.CustomTransition", output, "ClassLibrary1.CustomTransition should have been replaced in all cases.");
Directory.Delete (path, recursive: true);
}
[Test]
public void CustomLayoutBehaviorAttributes ()
{
var path = Path.Combine (Root, "temp", "CustomLayoutBehaviorAttributes");
Directory.CreateDirectory (path);
var resPath = Path.Combine (path, "res");
Directory.CreateDirectory (Path.Combine (resPath, "layout"));
File.WriteAllText (Path.Combine (resPath, "layout", "main.xml"), @"<?xml version='1.0' ?>
<android.support.design.widget.CoordinatorLayout xmlns:android='http://schemas.android.com/apk/res/android' xmlns:app='http://schemas.android.com/apk/res-auto'>
<Button app:layout_behavior='ClassLibrary1.CustomBehavior' />
<Button app:layout_behavior='ClassLibrary1.CustomBehavior, ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' />
</android.support.design.widget.CoordinatorLayout>");
var errors = new List<BuildErrorEventArgs> ();
IBuildEngine engine = new MockBuildEngine (TestContext.Out, errors);
var task = new ConvertResourcesCases {
BuildEngine = engine
};
task.ResourceDirectories = new ITaskItem [] {
new TaskItem (resPath),
};
task.AcwMapFile = Path.Combine (path, "acwmap.txt");
task.CustomViewMapFile = Path.Combine (path, "classmap.txt");
File.WriteAllLines (task.AcwMapFile, new string [] {
"ClassLibrary1.CustomBehavior, ClassLibrary1;md5d6f7135293df7527c983d45d07471c5e.CustomBehavior",
"ClassLibrary1.CustomBehavior;md5d6f7135293df7527c983d45d07471c5e.CustomBehavior",
"classLibrary1.CustomBehavior;md5d6f7135293df7527c983d45d07471c5e.CustomBehavior"
});
Assert.IsTrue (task.Execute (), "Task should have executed successfully");
var custom = new ConvertCustomView () {
BuildEngine = engine,
CustomViewMapFile = task.CustomViewMapFile,
AcwMapFile = task.AcwMapFile,
ResourceDirectories = new ITaskItem [] {
new TaskItem (resPath),
},
};
Assert.IsTrue (custom.Execute (), "Task should have executed successfully");
var output = File.ReadAllText (Path.Combine (resPath, "layout", "main.xml"));
StringAssert.Contains ("md5d6f7135293df7527c983d45d07471c5e.CustomBehavior", output, "md5d6f7135293df7527c983d45d07471c5e.CustomBehavior should exist in the main.xml");
StringAssert.DoesNotContain ("ClassLibrary1.CustomBehavior", output, "ClassLibrary1.CustomBehavior should have been replaced in all cases.");
Directory.Delete (path, recursive: true);
}Expected Behavior
The tests pass. All of the appearances of the managed type names are replaced by the corresponding Java type names from the acwmap.txt files.
Actual Behavior
The tests fail. The attributes that use fully assembly-qualified names are not replaced.
1) Failed : Xamarin.Android.Build.Tests.ConvertResourcesCasesTests.CustomLayoutBehaviorAttributes
ClassLibrary1.CustomBehavior should have been replaced in all cases.
Expected: not String containing "ClassLibrary1.CustomBehavior"
But was: "<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"><Button app:layout_behavior="md5d6f7135293df7527c983d45d07471c5e.CustomBehavior" /><Button app:layout_behavior="ClassLibrary1.CustomBehavior, ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /></android.support.design.widget.CoordinatorLayout>"
at Xamarin.Android.Build.Tests.ConvertResourcesCasesTests.CustomLayoutBehaviorAttributes()
2) Failed : Xamarin.Android.Build.Tests.ConvertResourcesCasesTests.CustomTransitionClassAttributes
ClassLibrary1.CustomTransition should have been replaced in all cases.
Expected: not String containing "ClassLibrary1.CustomTransition"
But was: "<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"><transition class="md5d6f7135293df7527c983d45d07471c5e.CustomTransition" /><transition class="ClassLibrary1.CustomTransition, ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /></transitionSet>"
at Xamarin.Android.Build.Tests.ConvertResourcesCasesTests.CustomTransitionClassAttributes()
Metadata
Metadata
Assignees
Labels
Area: App+Library BuildIssues when building Library projects or Application projects.Issues when building Library projects or Application projects.bugComponent does not function as intended.Component does not function as intended.