In class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine:
authorAnkit Jain <radical@corewars.org>
Wed, 26 Aug 2009 01:56:11 +0000 (01:56 -0000)
committerAnkit Jain <radical@corewars.org>
Wed, 26 Aug 2009 01:56:11 +0000 (01:56 -0000)
* Expression.cs: Correctly handle a item reference with transform
when allowItems is false. If item ref is ignored, then the transform
will get incorrectly matched as a metadata ref.
* ItemReference.cs (.ctor): Add a @original_string param.

In class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks:
* CreateItemTest.cs (TestVariableExpansion): Update test to
use a transform with a item reference in a property.

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

mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Expression.cs
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ItemReference.cs
mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/ChangeLog
mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateItemTest.cs

index e9838f26be582f90495e11d868aafad476f68c4e..b9e59b3b5da946612ad9c2c0e6fd6fa0569265e2 100644 (file)
@@ -1,3 +1,10 @@
+2009-08-26  Ankit Jain  <jankit@novell.com>
+
+       * Expression.cs: Correctly handle a item reference with transform
+       when allowItems is false. If item ref is ignored, then the transform
+       will get incorrectly matched as a metadata ref.
+       * ItemReference.cs (.ctor): Add a @original_string param.
+
 2009-08-26  Ankit Jain  <jankit@novell.com>
 
        * Utilities.cs (UnescapeFromXml): New. From md.
index 69d3f21d236c95af09cd0289143603e84ae2c426..6ac39d30f0ff5630738d74d04f23537ddbe91e97 100644 (file)
@@ -97,7 +97,7 @@ namespace Microsoft.Build.BuildEngine {
                                }
                        }
 
-                       CopyToExpressionCollection (p3);
+                       CopyToExpressionCollection (p3, allowItems);
                }
 
                void Prepare (List <ArrayList> l, int length)
@@ -106,12 +106,14 @@ namespace Microsoft.Build.BuildEngine {
                                l.Add (null);
                }
                
-               void CopyToExpressionCollection (List <ArrayList> lists)
+               void CopyToExpressionCollection (List <ArrayList> lists, bool allowItems)
                {
                        for (int i = 0; i < lists.Count; i++) {
                                foreach (object o in lists [i]) {
                                        if (o is string)
                                                expressionCollection.Add (Utilities.Unescape ((string) o));
+                                       else if (!allowItems && o is ItemReference)
+                                               expressionCollection.Add (((ItemReference) o).OriginalString);
                                        else if (o is IReference)
                                                expressionCollection.Add ((IReference) o);
                                }
@@ -122,13 +124,6 @@ namespace Microsoft.Build.BuildEngine {
 
                ArrayList SplitItems (string text, bool allowItems)
                {
-                       if (!allowItems) {
-                               // FIXME: it's probably larger than 1
-                               ArrayList l = new ArrayList ();
-                               l.Add (text);
-                               return l;
-                       }
-
                        ArrayList phase1 = new ArrayList ();
                        Match m;
                        m = ItemRegex.Match (text);
@@ -145,7 +140,8 @@ namespace Microsoft.Build.BuildEngine {
                                if (m.Groups [ItemRegex.GroupNumberFromName ("has_separator")].Success)
                                        separator = m.Groups [ItemRegex.GroupNumberFromName ("separator")].Value;
 
-                               ir = new ItemReference (name, transform, separator, m.Groups [0].Index, m.Groups [0].Length);
+                               ir = new ItemReference (text.Substring (m.Groups [0].Index, m.Groups [0].Length),
+                                               name, transform, separator, m.Groups [0].Index, m.Groups [0].Length);
                                phase1.Add (ir);
                                m = m.NextMatch ();
                        }
index d89d3a79a602c5be4374c42fb53fb332d71fb097..ee827a4132b780c50c5c3b4944f1523eca995d62 100644 (file)
@@ -39,12 +39,14 @@ namespace Microsoft.Build.BuildEngine {
                Expression      separator;
                int             start;
                int             length;
+               string          original_string;
                
-               public ItemReference (string itemName, string transform, string separator, int start, int length)
+               public ItemReference (string original_string, string itemName, string transform, string separator, int start, int length)
                {
                        this.itemName = itemName;
                        this.start = start;
                        this.length = length;
+                       this.original_string = original_string;
 
                        if (transform != null) {
                                this.transform = new Expression ();
@@ -88,6 +90,10 @@ namespace Microsoft.Build.BuildEngine {
                        get { return separator; }
                }
 
+               public string OriginalString {
+                       get { return original_string; }
+               }
+
                public int Start {
                        get { return start; }
                }
@@ -98,8 +104,7 @@ namespace Microsoft.Build.BuildEngine {
 
                public override string ToString ()
                {
-                       //FIXME: transform
-                       return "@" + itemName;
+                       return original_string;
                }
        }
 }
index 72eafd9e8287cb9c2dc0a3f3ccaaeb9602c7254b..6d94cc9f4d7750dc938e0f8ec7dd9bc830a7204d 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-26  Ankit Jain  <jankit@novell.com>
+
+       * CreateItemTest.cs (TestVariableExpansion): Update test to
+       use a transform with a item reference in a property.
+
 2009-08-26  Ankit Jain  <jankit@novell.com>
 
        * CreateItemTest.cs (TestVariableExpansion): New.
index d4829616fed7d221b1d7e0991b6d00f9319df7be..3113c6d80e50a2351dd0cab54f6569718cabe442 100644 (file)
@@ -199,7 +199,7 @@ namespace MonoTests.Microsoft.Build.Tasks {
                                        <P1>FooP1</P1>
                                        <P2>FooP2</P2>
                                        <C>@(IG)</C>
-                                       <P3>@(Nine)</P3>
+                                       <P3>@(Nine->'%(Identity)')</P3>
                                </PropertyGroup>
                                <ItemGroup>
                                        <Nine Include=""Nine""/>
@@ -247,7 +247,7 @@ namespace MonoTests.Microsoft.Build.Tasks {
                        Assert.AreEqual ("Eight", include[3].FinalItemSpec, "A#6");
                        Assert.AreEqual ("Nine", include[4].FinalItemSpec, "A#7");
 
-                       testLogger.CheckLoggedMessageHead ("C: Abc;FooP1;FooP2;Eight;Nine", "A#10");
+                       testLogger.CheckLoggedMessageHead ("C: Abc;FooP1;FooP2;Eight;Nine", "A#9");
                        testLogger.CheckLoggedMessageHead ("items: Abc;FooP1;FooP2;Eight;Nine", "A#10");
 
                }