In class/Microsoft.Build.Tasks/Microsoft.Build.Tasks:
authorAnkit Jain <radical@corewars.org>
Fri, 5 Feb 2010 12:20:52 +0000 (12:20 -0000)
committerAnkit Jain <radical@corewars.org>
Fri, 5 Feb 2010 12:20:52 +0000 (12:20 -0000)
Fix bug #576579.
* CreateManifestResourceName.cs: Use TargetPath metadata, as the link
name.
* CreateCSharpManifestResourceName.cs:
* CreateVisualBasicManifestResourceName.cs: Prefer linkname over
filename, if available.

In class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks:

* CreateCSharpManifestResourceNameTest.cs:
* CreateVisualBasicManifestResourceNameTest.cs:
Add new tests for TargetPath metadata.

In class/Microsoft.Build.Tasks/Test/resources:

* junk.txt: New.

svn path=/trunk/mcs/; revision=150924

mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ChangeLog
mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/CreateCSharpManifestResourceName.cs
mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/CreateManifestResourceName.cs
mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/CreateVisualBasicManifestResourceName.cs
mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/ChangeLog
mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateCSharpManifestResourceNameTest.cs
mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateVisualBasicManifestResourceNameTest.cs [changed mode: 0644->0755]
mcs/class/Microsoft.Build.Tasks/Test/resources/ChangeLog
mcs/class/Microsoft.Build.Tasks/Test/resources/junk.txt [new file with mode: 0644]

index 8461250815908ce31f1ffcabce38786326b70a98..dc6330dc2b512c088f525c099ef27526d6479200 100644 (file)
@@ -1,3 +1,12 @@
+2010-02-05  Ankit Jain  <jankit@novell.com>
+
+       Fix bug #576579.
+       * CreateManifestResourceName.cs: Use TargetPath metadata, as the link
+       name.
+       * CreateCSharpManifestResourceName.cs:
+       * CreateVisualBasicManifestResourceName.cs: Prefer linkname over
+       filename, if available.
+
 2010-02-04  Ankit Jain  <jankit@novell.com>
 
        * WriteLinesToFile.cs: Delete the file if there is nothing to
index 7d9d5951d80ad1f0064b5e558e48ab867d7c427c..1a0f7f52ea0c132ecd832bf60dc3198e2b063257 100644 (file)
@@ -50,8 +50,9 @@ namespace Microsoft.Build.Tasks {
                                                              string dependentUponFileName,
                                                              Stream binaryStream)
                {
+                       string filename_to_use = String.IsNullOrEmpty (linkFileName) ? fileName : linkFileName;
                        if (String.IsNullOrEmpty (dependentUponFileName) || binaryStream == null)
-                               return GetResourceIdFromFileName (fileName, rootNamespace);
+                               return GetResourceIdFromFileName (filename_to_use, rootNamespace);
 
                        string ns = null;
                        string classname = null;
@@ -88,10 +89,10 @@ namespace Microsoft.Build.Tasks {
                                }
 
                                if (classname == null)
-                                       return GetResourceIdFromFileName (fileName, rootNamespace);
+                                       return GetResourceIdFromFileName (filename_to_use, rootNamespace);
 
                                string culture, extn, only_filename;
-                               if (AssignCulture.TrySplitResourceName (fileName, out only_filename, out culture, out extn))
+                               if (AssignCulture.TrySplitResourceName (filename_to_use, out only_filename, out culture, out extn))
                                        extn = "." + culture;
                                else
                                        extn = String.Empty;
index dd3eacab33a0c574976fc93b7c8ec8daf7b3f2c7..0388364f8b34576138e8aaf694c13731a045919c 100644 (file)
@@ -72,7 +72,7 @@ namespace Microsoft.Build.Tasks {
 
                                        manifestResourceNames [i] = new TaskItem (item);
                                        manifestResourceNames [i].ItemSpec = CreateManifestName (
-                                                               filename, null, rootNamespace,
+                                                               filename, item.GetMetadata ("TargetPath"), rootNamespace,
                                                                dependentUponFileName, binaryStream);
                                } finally {
                                        if (binaryStream != null)
index 6b7fb55534a573c3eedc5d32f01dafa1093acb81..ffa62a2bfa4c16552ce11045391f8204cecbb148 100644 (file)
@@ -45,9 +45,10 @@ namespace Microsoft.Build.Tasks {
                                                              string dependentUponFileName,
                                                              Stream binaryStream)
                {
+                       string filename_to_use = String.IsNullOrEmpty (linkFileName) ? fileName : linkFileName;
                        if (String.IsNullOrEmpty (dependentUponFileName) || binaryStream == null)
                                return GetResourceIdFromFileName
-                                       (Path.GetFileName (fileName), rootNamespace);
+                                       (Path.GetFileName (filename_to_use), rootNamespace);
 
                        string ns = null;
                        string classname = null;
@@ -77,10 +78,10 @@ namespace Microsoft.Build.Tasks {
                                }
 
                                if (classname == null)
-                                       return GetResourceIdFromFileName (fileName, rootNamespace);
+                                       return GetResourceIdFromFileName (filename_to_use, rootNamespace);
 
                                string culture, extn, only_filename;
-                               if (AssignCulture.TrySplitResourceName (fileName, out only_filename, out culture, out extn))
+                               if (AssignCulture.TrySplitResourceName (filename_to_use, out only_filename, out culture, out extn))
                                        extn = "." + culture;
                                else
                                        extn = String.Empty;
index a4b6caeb3afe8988941ed11c459855a5036be336..55033f7bd07286aba5e434485f79abc5afab9f77 100644 (file)
@@ -1,3 +1,9 @@
+2010-02-05  Ankit Jain  <jankit@novell.com>
+
+       * CreateCSharpManifestResourceNameTest.cs:
+       * CreateVisualBasicManifestResourceNameTest.cs:
+       Add new tests for TargetPath metadata.
+
 2010-02-04  Ankit Jain  <jankit@novell.com>
 
        * WriteLinesToFileTest.cs: New.
index 1a6bf8cd6edb95f665b0402034fb93218288e28b..150104c662a475553b3913f216f587cc6a33af77 100755 (executable)
@@ -18,36 +18,49 @@ namespace MonoTests.Microsoft.Build.Tasks
                public CreateCSharpManifestResourceNameTest ()
                {
                        string sample_cs_path = Path.Combine ("Test", Path.Combine ("resources", "Sample.cs"));
+                       string junk_file = Path.Combine ("Test", Path.Combine ("resources", "junk.txt"));
+                       string curdir = Path.GetDirectoryName (Environment.CurrentDirectory);
+
+                       /* {Include, LogicalName, DependentUpon, TargetPath} */
                        resx_no_culture_files = new string [,] {
                                // With dependent file
-                               { "foo with space.resx", null, sample_cs_path },
-                               { "foo with space.resx", "RandomName", sample_cs_path },
+                               { "foo with space.resx", null, sample_cs_path, null },
+                               { "foo with space.resx", "RandomName", sample_cs_path, null },
+                               { "foo with space.resx", "RandomName", sample_cs_path, "bar with space.resx" },
+
+                               // can't find a C# class in the .vb file
+                               { "foo with space.resx", "RandomName", junk_file, "bar with space.resx" },
 
-                               { "Test/resources/foo with space.resx", null, "Sample.cs" },
-                               { "Test/resources/foo with space.resx", "RandomName", "Sample.cs" },
+                               { "Test/resources/foo with space.resx", null, "Sample.cs", null },
+                               { "Test/resources/foo with space.resx", "RandomName", "Sample.cs", null },
+                               { "Test/resources/foo with space.resx", "RandomName", "Sample.cs", "bar with space.resx"},
 
                                // W/o dependent file
-                               { "foo with space.resx", null, null },
-                               { "foo with space.resx", "RandomName", null },
+                               { "foo with space.resx", null, null, null },
+                               { "foo with space.resx", "RandomName", null, null },
 
-                               { "Test/resources folder/foo with space.resx", null, null },
-                               { "Test/resources folder/foo with space.resx", "RandomName", null },
+                               { "Test/resources folder/foo with space.resx", null, null, null },
+                               { "Test/resources folder/foo with space.resx", "RandomName", null, null },
                        };
 
                        resx_with_culture_files = new string [,] {
                                // With dependent file
-                               { "foo with space.de.resx", null, sample_cs_path },
-                               { "foo with space.de.resx", "RandomName", sample_cs_path },
+                               { "foo with space.de.resx", null, sample_cs_path, null },
+                               { "foo with space.de.resx", "RandomName", sample_cs_path, null },
+                               { "foo with space.de.resx", "RandomName", sample_cs_path, "bar with space.fr.resx" },
+
+                               // can't find a C# class in the .vb file
+                               { "foo with space.de.resx", "RandomName", junk_file, "bar with space.fr.resx" },
 
-                               { "Test/resources/foo with space.de.resx", null, "Sample.cs" },
-                               { "Test/resources/foo with space.de.resx", "RandomName", "Sample.cs" },
+                               { "Test/resources/foo with space.de.resx", null, "Sample.cs", null },
+                               { "Test/resources/foo with space.de.resx", "RandomName", "Sample.cs", null},
 
                                // W/o dependent file
-                               { "foo with space.de.resx", null, null },
-                               { "foo with space.de.resx", "RandomName", null },
+                               { "foo with space.de.resx", null, null, null },
+                               { "foo with space.de.resx", "RandomName", null, null },
 
-                               { "Test/resources folder/foo with space.de.resx", null, null },
-                               { "Test/resources folder/foo with space.de.resx", "RandomName", null }
+                               { "Test/resources folder/foo with space.de.resx", null, null, null },
+                               { "Test/resources folder/foo with space.de.resx", "RandomName", null, null }
                        };
 
                        non_resx_no_culture_files = new string [,] {
@@ -74,11 +87,14 @@ namespace MonoTests.Microsoft.Build.Tasks
                        CheckResourceNames (resx_no_culture_files, new string [] {
                                // w/ dependent file
                                "Mono.Tests.Sample", "Mono.Tests.Sample",
+                               "Mono.Tests.Sample", "bar with space",
                                "Mono.Tests.Sample", "Mono.Tests.Sample",
 
                                // W/o dependent file
-                               "foo with space", "foo with space" ,
-                               "Test.resources_folder.foo with space", "Test.resources_folder.foo with space"}, null);
+                               "Mono.Tests.Sample", "foo with space" ,
+                               "foo with space", "Test.resources_folder.foo with space",
+                               "Test.resources_folder.foo with space",
+                       }, null);
                }
 
                [Test]
@@ -88,10 +104,13 @@ namespace MonoTests.Microsoft.Build.Tasks
                        CheckResourceNames (resx_no_culture_files, new string [] {
                                // With dependent file
                                "Mono.Tests.Sample", "Mono.Tests.Sample",
+                               "Mono.Tests.Sample", "RN1.RN2.bar with space",
                                "Mono.Tests.Sample", "Mono.Tests.Sample",
+
                                // W/o dependent file
-                               "RN1.RN2.foo with space", "RN1.RN2.foo with space",
-                               "RN1.RN2.Test.resources_folder.foo with space", "RN1.RN2.Test.resources_folder.foo with space"},
+                               "Mono.Tests.Sample", "RN1.RN2.foo with space",
+                               "RN1.RN2.foo with space", "RN1.RN2.Test.resources_folder.foo with space",
+                               "RN1.RN2.Test.resources_folder.foo with space"},
                                "RN1.RN2");
                }
 
@@ -101,7 +120,10 @@ namespace MonoTests.Microsoft.Build.Tasks
                        CheckResourceNames (resx_with_culture_files, new string [] {
                                // With dependent file
                                 "Mono.Tests.Sample.de", "Mono.Tests.Sample.de",
+                                "Mono.Tests.Sample.fr", "bar with space.fr",
+
                                 "Mono.Tests.Sample.de", "Mono.Tests.Sample.de",
+
                                // W/o dependent file
                                 "foo with space.de", "foo with space.de",
                                 "Test.resources_folder.foo with space.de", "Test.resources_folder.foo with space.de" }, null);
@@ -113,6 +135,7 @@ namespace MonoTests.Microsoft.Build.Tasks
                        CheckResourceNames (resx_with_culture_files, new string [] {
                                // With dependent file
                                 "Mono.Tests.Sample.de", "Mono.Tests.Sample.de",
+                                "Mono.Tests.Sample.fr", "RN1.RN2.bar with space.fr",
                                 "Mono.Tests.Sample.de", "Mono.Tests.Sample.de",
                                // W/o dependent file
                                 "RN1.RN2.foo with space.de", "RN1.RN2.foo with space.de",
@@ -126,6 +149,7 @@ namespace MonoTests.Microsoft.Build.Tasks
                        CheckResourceNames (non_resx_with_culture_files, new string [] {
                                Path.Combine ("de", "foo with space.txt"), Path.Combine ("de", "foo with space.txt"),
                                Path.Combine ("de", "Test.resources_folder.foo with space.txt"), Path.Combine ("de", "Test.resources_folder.foo with space.txt")}, null);
+
                }
 
                [Test]
@@ -155,6 +179,42 @@ namespace MonoTests.Microsoft.Build.Tasks
                                "RN1.RN2");
                }
 
+               [Test]
+               public void TestExternalResourcesNoRootNamespaceWithTargetPath ()
+               {
+                       CheckResourceNames (new string[,] {
+                                       {"../folder/foo.txt", null, null, "abc.txt"},
+                                       {"../folder/foo.de.txt", null, null, "xyz.txt"}},
+                                       new string[] { "abc.txt", "xyz.txt" }, null);
+               }
+
+               [Test]
+               public void TestExternalResourcesWithRootNamespaceWithTargetPath ()
+               {
+                       CheckResourceNames (new string[,] {
+                                       {"../folder/foo.txt", null, null, "abc.txt"},
+                                       {"../folder/foo.de.txt", null, null, "xyz.txt"}},
+                                       new string[] { "RN.abc.txt", "RN.xyz.txt" }, "RN");
+               }
+
+               [Test]
+               public void TestExternalResourcesNoRootNamespaceNoTargetPath ()
+               {
+                       CheckResourceNames (new string[,] {
+                                       {"../folder/foo.txt", null, null},
+                                       {"../folder/foo.de.txt", null, null}},
+                                       new string[] { "...folder.foo.txt", Path.Combine ("de", "...folder.foo.txt") }, null);
+               }
+
+               [Test]
+               public void TestExternalResourcesWithRootNamespaceNoTargetPath ()
+               {
+                       CheckResourceNames (new string[,] {
+                                       {"../folder/foo.txt", null, null},
+                                       {"../folder/foo.de.txt", null, null}},
+                                       new string[] { "RN....folder.foo.txt", Path.Combine ("de", "RN....folder.foo.txt") }, "RN");
+               }
+
                [Test]
                public void TestInvalidCulture ()
                {
@@ -182,6 +242,7 @@ namespace MonoTests.Microsoft.Build.Tasks
                                Assert.Fail ("Build failed");
                        }
 
+                       bool has_targetpaths = files.GetUpperBound (1) == 3;
                        BuildItemGroup group = project.GetEvaluatedItemsByName ("ResourceNames");
                        Assert.AreEqual (names.Length, group.Count, "A2");
                        for (int i = 0; i <= files.GetUpperBound (0); i++) {
@@ -192,6 +253,8 @@ namespace MonoTests.Microsoft.Build.Tasks
                                Assert.AreEqual (files [i, 2] != null, group [i].HasMetadata ("DependentUpon"), "A6 #" + (i + 1));
                                if (files [i, 2] != null)
                                        Assert.AreEqual (files [i, 2], group [i].GetMetadata ("DependentUpon"), "A7 #" + (i + 1));
+                               if (has_targetpaths && files [i, 3] != null)
+                                       Assert.AreEqual (files [i, 3], group [i].GetMetadata ("TargetPath"), "A8 #" + (i + 1));
                        }
                }
 
@@ -200,9 +263,12 @@ namespace MonoTests.Microsoft.Build.Tasks
                        StringBuilder sb = new StringBuilder ();
                        sb.Append ("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n");
 
+                       bool has_targetpaths = files.GetUpperBound (1) == 3;
                        sb.Append ("\t<ItemGroup>\n");
                        for (int i = 0; i <= files.GetUpperBound (0); i ++) {
                                sb.AppendFormat ("\t\t<ResourceFiles Include = \"{0}\">\n", files [i, 0]);
+                               if (has_targetpaths && files [i, 3] != null)
+                                       sb.AppendFormat ("\t\t\t<TargetPath>{0}</TargetPath>\n", files [i, 3]);
                                if (files [i, 1] != null)
                                        sb.AppendFormat ("\t\t\t<LogicalName>{0}</LogicalName>\n", files [i, 1]);
                                if (files [i, 2] != null)
old mode 100644 (file)
new mode 100755 (executable)
index 599ac94..bb94c5c
@@ -1,3 +1,4 @@
+
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -13,41 +14,53 @@ namespace MonoTests.Microsoft.Build.Tasks
        {
 
                string [,] resx_no_culture_files, resx_with_culture_files;
-               string [,] non_resx_no_culture_files, non_resx_with_culture_files;
-
+               string [,] non_resx_no_culture_files, non_resx_with_culture_files; 
                public CreateVisualBasicManifestResourceNameTest ()
                {
+                       string junk_file = Path.Combine ("Test", Path.Combine ("resources", "junk.txt"));
                        string sample_vb_path = Path.Combine ("Test", Path.Combine ("resources", "Sample.vb"));
+                       string curdir = Path.GetDirectoryName (Environment.CurrentDirectory);
+
+                       /* {Include, LogicalName, DependentUpon, TargetPath} */
                        resx_no_culture_files = new string [,] {
                                // With dependent file
-                               { "foo with space.resx", null, sample_vb_path },
-                               { "foo with space.resx", "RandomName", sample_vb_path },
+                               { "foo with space.resx", null, sample_vb_path, null },
+                               { "foo with space.resx", "RandomName", sample_vb_path, null },
+                               { "foo with space.resx", "RandomName", sample_vb_path, "bar with space.resx" },
+
+                               // can't find a C# class in the .vb file
+                               { "foo with space.resx", "RandomName", junk_file, "bar with space.resx" },
 
-                               { "Test/resources/foo with space.resx", null, "Sample.vb" },
-                               { "Test/resources/foo with space.resx", "RandomName", "Sample.vb" },
+                               { "Test/resources/foo with space.resx", null, "Sample.vb", null },
+                               { "Test/resources/foo with space.resx", "RandomName", "Sample.vb", null },
+                               { "Test/resources/foo with space.resx", "RandomName", "Sample.vb", "bar with space.resx"},
 
                                // W/o dependent file
-                               { "foo with space.resx", null, null },
-                               { "foo with space.resx", "RandomName", null },
+                               { "foo with space.resx", null, null, null },
+                               { "foo with space.resx", "RandomName", null, null },
 
-                               { "Test/resources/foo with space.resx", null, null },
-                               { "Test/resources/foo with space.resx", "RandomName", null },
+                               { "Test/resources folder/foo with space.resx", null, null, null },
+                               { "Test/resources folder/foo with space.resx", "RandomName", null, null },
                        };
 
                        resx_with_culture_files = new string [,] {
                                // With dependent file
-                               { "foo with space.de.resx", null, sample_vb_path },
-                               { "foo with space.de.resx", "RandomName", sample_vb_path },
+                               { "foo with space.de.resx", null, sample_vb_path, null },
+                               { "foo with space.de.resx", "RandomName", sample_vb_path, null },
+                               { "foo with space.de.resx", "RandomName", sample_vb_path, "bar with space.fr.resx" },
 
-                               { "Test/resources/foo with space.de.resx", null, "Sample.vb" },
-                               { "Test/resources/foo with space.de.resx", "RandomName", "Sample.vb" },
+                               // can't find a C# class in the .vb file
+                               { "foo with space.de.resx", "RandomName", junk_file, "bar with space.fr.resx" },
+
+                               { "Test/resources/foo with space.de.resx", null, "Sample.vb", null },
+                               { "Test/resources/foo with space.de.resx", "RandomName", "Sample.vb", null},
 
                                // W/o dependent file
-                               { "foo with space.de.resx", null, null },
-                               { "foo with space.de.resx", "RandomName", null },
+                               { "foo with space.de.resx", null, null, null },
+                               { "foo with space.de.resx", "RandomName", null, null },
 
-                               { "Test/resources folder/foo with space.de.resx", null, null },
-                               { "Test/resources folder/foo with space.de.resx", "RandomName", null }
+                               { "Test/resources folder/foo with space.de.resx", null, null, null },
+                               { "Test/resources folder/foo with space.de.resx", "RandomName", null, null }
                        };
 
                        non_resx_no_culture_files = new string [,] {
@@ -74,11 +87,14 @@ namespace MonoTests.Microsoft.Build.Tasks
                        CheckResourceNames (resx_no_culture_files, new string [] {
                                // w/ dependent file
                                "Mono.Tests.Sample", "Mono.Tests.Sample",
+                               "Mono.Tests.Sample", "bar with space",
                                "Mono.Tests.Sample", "Mono.Tests.Sample",
 
                                // W/o dependent file
-                               "foo with space", "foo with space" ,
-                               "foo with space", "foo with space"}, null);
+                               "Mono.Tests.Sample", "foo with space" ,
+                               "foo with space", "foo with space",
+                               "foo with space",
+                       }, null);
                }
 
                [Test]
@@ -88,10 +104,13 @@ namespace MonoTests.Microsoft.Build.Tasks
                        CheckResourceNames (resx_no_culture_files, new string [] {
                                // With dependent file
                                "RN1.RN2.Mono.Tests.Sample", "RN1.RN2.Mono.Tests.Sample",
+                               "RN1.RN2.Mono.Tests.Sample", "RN1.RN2.bar with space",
                                "RN1.RN2.Mono.Tests.Sample", "RN1.RN2.Mono.Tests.Sample",
+
                                // W/o dependent file
+                               "RN1.RN2.Mono.Tests.Sample", "RN1.RN2.foo with space",
                                "RN1.RN2.foo with space", "RN1.RN2.foo with space",
-                               "RN1.RN2.foo with space", "RN1.RN2.foo with space"},
+                               "RN1.RN2.foo with space"},
                                "RN1.RN2");
                }
 
@@ -101,7 +120,10 @@ namespace MonoTests.Microsoft.Build.Tasks
                        CheckResourceNames (resx_with_culture_files, new string [] {
                                // With dependent file
                                 "Mono.Tests.Sample.de", "Mono.Tests.Sample.de",
+                                "Mono.Tests.Sample.fr", "bar with space.fr",
+
                                 "Mono.Tests.Sample.de", "Mono.Tests.Sample.de",
+
                                // W/o dependent file
                                 "foo with space.de", "foo with space.de",
                                 "foo with space.de", "foo with space.de" }, null);
@@ -113,6 +135,7 @@ namespace MonoTests.Microsoft.Build.Tasks
                        CheckResourceNames (resx_with_culture_files, new string [] {
                                // With dependent file
                                 "RN1.RN2.Mono.Tests.Sample.de", "RN1.RN2.Mono.Tests.Sample.de",
+                                "RN1.RN2.Mono.Tests.Sample.fr", "RN1.RN2.bar with space.fr",
                                 "RN1.RN2.Mono.Tests.Sample.de", "RN1.RN2.Mono.Tests.Sample.de",
                                // W/o dependent file
                                 "RN1.RN2.foo with space.de", "RN1.RN2.foo with space.de",
@@ -126,6 +149,7 @@ namespace MonoTests.Microsoft.Build.Tasks
                        CheckResourceNames (non_resx_with_culture_files, new string [] {
                                Path.Combine ("de", "foo with space.txt"), Path.Combine ("de", "foo with space.txt"),
                                Path.Combine ("de", "foo with space.txt"), Path.Combine ("de", "foo with space.txt")}, null);
+
                }
 
                [Test]
@@ -155,6 +179,53 @@ namespace MonoTests.Microsoft.Build.Tasks
                                "RN1.RN2");
                }
 
+               [Test]
+               public void TestExternalResourcesNoRootNamespaceWithTargetPath ()
+               {
+                       CheckResourceNames (new string[,] {
+                                       {"../folder/foo.txt", null, null, "abc.txt"},
+                                       {"../folder/foo.de.txt", null, null, "xyz.txt"}},
+                                       new string[] { "abc.txt", "xyz.txt" }, null);
+               }
+
+               [Test]
+               public void TestExternalResourcesWithRootNamespaceWithTargetPath ()
+               {
+                       CheckResourceNames (new string[,] {
+                                       {"../folder/foo.txt", null, null, "abc.txt"},
+                                       {"../folder/foo.de.txt", null, null, "xyz.txt"}},
+                                       new string[] { "RN.abc.txt", "RN.xyz.txt" }, "RN");
+               }
+
+               [Test]
+               public void TestExternalResourcesNoRootNamespaceNoTargetPath ()
+               {
+                       CheckResourceNames (new string[,] {
+                                       {"../folder/foo.txt", null, null},
+                                       {"../folder/foo.de.txt", null, null}},
+                                       new string[] { "foo.txt", Path.Combine ("de", "foo.txt") }, null);
+               }
+
+               [Test]
+               public void TestExternalResourcesWithRootNamespaceNoTargetPath ()
+               {
+                       CheckResourceNames (new string[,] {
+                                       {"../folder/foo.txt", null, null},
+                                       {"../folder/foo.de.txt", null, null}},
+                                       new string[] { "RN.foo.txt", Path.Combine ("de", "RN.foo.txt") }, "RN");
+               }
+
+               [Test]
+               public void TestInvalidCulture ()
+               {
+                       string [,] files = new string [,] {
+                               { "Foo.invalid.txt", null, null },
+                               { "Foo.invalid.resx", null, null }
+                       };
+                       CheckResourceNames (files, new string [] {"RN1.RN2.Foo.invalid.txt", "RN1.RN2.Foo.invalid"},
+                               "RN1.RN2");
+               }
+
                void CheckResourceNames (string [,] files, string [] names, string rootNamespace)
                {
                        Assert.AreEqual (files.GetUpperBound (0) + 1, names.Length, "Number of files and names must match");
@@ -171,6 +242,7 @@ namespace MonoTests.Microsoft.Build.Tasks
                                Assert.Fail ("Build failed");
                        }
 
+                       bool has_targetpaths = files.GetUpperBound (1) == 3;
                        BuildItemGroup group = project.GetEvaluatedItemsByName ("ResourceNames");
                        Assert.AreEqual (names.Length, group.Count, "A2");
                        for (int i = 0; i <= files.GetUpperBound (0); i++) {
@@ -181,6 +253,8 @@ namespace MonoTests.Microsoft.Build.Tasks
                                Assert.AreEqual (files [i, 2] != null, group [i].HasMetadata ("DependentUpon"), "A6 #" + (i + 1));
                                if (files [i, 2] != null)
                                        Assert.AreEqual (files [i, 2], group [i].GetMetadata ("DependentUpon"), "A7 #" + (i + 1));
+                               if (has_targetpaths && files [i, 3] != null)
+                                       Assert.AreEqual (files [i, 3], group [i].GetMetadata ("TargetPath"), "A8 #" + (i + 1));
                        }
                }
 
@@ -189,9 +263,12 @@ namespace MonoTests.Microsoft.Build.Tasks
                        StringBuilder sb = new StringBuilder ();
                        sb.Append ("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n");
 
+                       bool has_targetpaths = files.GetUpperBound (1) == 3;
                        sb.Append ("\t<ItemGroup>\n");
                        for (int i = 0; i <= files.GetUpperBound (0); i ++) {
                                sb.AppendFormat ("\t\t<ResourceFiles Include = \"{0}\">\n", files [i, 0]);
+                               if (has_targetpaths && files [i, 3] != null)
+                                       sb.AppendFormat ("\t\t\t<TargetPath>{0}</TargetPath>\n", files [i, 3]);
                                if (files [i, 1] != null)
                                        sb.AppendFormat ("\t\t\t<LogicalName>{0}</LogicalName>\n", files [i, 1]);
                                if (files [i, 2] != null)
index 5f0da8e421373a102e51d8748211a57a820aeda8..5ac841b85d713fc85bc9a742b80e76c22516ebf9 100644 (file)
@@ -1,3 +1,7 @@
+2010-02-05  Ankit Jain  <jankit@novell.com>
+
+       * junk.txt: New.
+
 2009-04-27  Ankit Jain  <jankit@novell.com>
 
        * Sample.vb: New.
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/resources/junk.txt b/mcs/class/Microsoft.Build.Tasks/Test/resources/junk.txt
new file mode 100644 (file)
index 0000000..38cbbb3
--- /dev/null
@@ -0,0 +1 @@
+Non code file used by Create*ManifestResourceTest .