From d3bb3a232c3b9edf2856e5f6da6b2a53757919f0 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Fri, 15 Jul 2016 16:09:30 +0100 Subject: [PATCH] [Xamarin.Android.Build.Tasks] Fix a regression in the Path seperator unit tests No idea why this started happening. Its probably a change in behaviour under Mono 4.4/.x version of xbuild. since it only effects items using the "LigicalName" meta data. But the result is we get things like this in the Resource.Designer.cs static int drawable/foo = 123456789; which is obviously a compilation problem for c#. So to fix we add some processing of the logical Name to replace any "invalid" path seperators with valid ones. --- src/Xamarin.Android.Build.Tasks/Tasks/AndroidUpdateResDir.cs | 4 ++-- .../Tasks/GenerateResourceDesigner.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/AndroidUpdateResDir.cs b/src/Xamarin.Android.Build.Tasks/Tasks/AndroidUpdateResDir.cs index 1621ff79dee..724ca63422a 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/AndroidUpdateResDir.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/AndroidUpdateResDir.cs @@ -80,13 +80,13 @@ public override bool Execute () //compute the target path string rel; - var logicalName = item.GetMetadata ("LogicalName"); + var logicalName = item.GetMetadata ("LogicalName").Replace ('\\', Path.DirectorySeparatorChar); if (item.GetMetadata ("IsWearApplicationResource") == "True") { rel = item.ItemSpec.Substring (IntermediateDir.Length); } else if (!string.IsNullOrEmpty (logicalName)) { rel = logicalName; } else { - rel = item.GetMetadata ("Link"); + rel = item.GetMetadata ("Link").Replace ('\\', Path.DirectorySeparatorChar); if (string.IsNullOrEmpty (rel)) { rel = item.GetMetadata ("Identity"); if (!string.IsNullOrEmpty (ProjectDir)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesigner.cs b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesigner.cs index 247b70f9711..ec1c1640e75 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesigner.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesigner.cs @@ -72,7 +72,7 @@ public override bool Execute () continue; var name = item.ItemSpec.Substring (ResourceDirectory.Length); - var logical_name = item.GetMetadata ("LogicalName"); + var logical_name = item.GetMetadata ("LogicalName").Replace ('\\', '/'); AddRename (name.Replace ('/', Path.DirectorySeparatorChar), logical_name.Replace ('/', Path.DirectorySeparatorChar)); }