Fix item expression parsing, indexes were wrong to parse after "->" .
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 31 Jan 2014 12:11:17 +0000 (21:11 +0900)
committerAtsushi Eno <atsushieno@gmail.com>
Thu, 20 Feb 2014 09:23:02 +0000 (18:23 +0900)
mcs/class/Microsoft.Build/Microsoft.Build.Internal/ExpressionParserManual.cs
mcs/class/Microsoft.Build/Test/Microsoft.Build.Internal/ExpressionParserTest.cs

index f177505587dd7da9caf7a627ecab120f90b867fb..ded0233a5d7d7a65c20b6a04e15daf26aa85d3d8 100644 (file)
@@ -244,7 +244,7 @@ namespace Microsoft.Build.Internal.Expressions
                                return new ItemAccessExpression () {
                                        Application = new ItemApplication () {
                                                Name = new NameToken () { Name = name },
-                                               Expressions = Parse (idx, end - idx)
+                                               Expressions = Parse (idx + 2, end)
                                                }
                                        };
                        } else {
index 7654538a1a4c64ab8c2e19fb6e9dc5e6a9e09a13..89feec3399f94382e257b946d57636f3360a07cd 100644 (file)
@@ -35,6 +35,8 @@ using NUnit.Framework;
 using Microsoft.Build.Execution;
 using Microsoft.Build.Exceptions;
 using System.Collections.Generic;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Logging;
 
 namespace MonoTests.Microsoft.Build.Internal
 {
@@ -282,6 +284,31 @@ namespace MonoTests.Microsoft.Build.Internal
                        var root = ProjectRootElement.Create (reader);
                        new Project (root);
                }
+               
+               [Test]
+               public void MetadataExpansion ()
+               {
+                       string project_xml = @"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+  <PropertyGroup>
+    <X>a/b/c.txt</X>
+  </PropertyGroup>
+  <Target Name='Foo'>
+    <CreateItem Include='$(X)'>
+      <Output TaskParameter='Include' ItemName='I' />
+    </CreateItem>
+    <CreateProperty Value=""@(I->'%(Filename)%(Extension)')"">
+      <Output TaskParameter='Value' PropertyName='P' />
+    </CreateProperty>
+    <Error Text=""Expected 'c.txt' but got '$(P)'"" Condition=""'$(P)'!='c.txt'"" />
+  </Target>
+</Project>";
+                       var xml = XmlReader.Create (new StringReader (project_xml));
+                       var root = ProjectRootElement.Create (xml);
+                       var p = new ProjectInstance (root);
+                       var sw = new StringWriter ();
+                       var result = p.Build (new ILogger [] { new ConsoleLogger (LoggerVerbosity.Minimal, sw.WriteLine, null, null)});
+                       Assert.IsTrue (result, "#1: " + sw);
+               }
        }
 }