[xbuild]: Implement task batching for properties; fixes #16403.
authorMartin Baulig <martin.baulig@xamarin.com>
Mon, 2 Dec 2013 21:51:22 +0000 (22:51 +0100)
committerMartin Baulig <martin.baulig@xamarin.com>
Mon, 2 Dec 2013 21:56:58 +0000 (22:56 +0100)
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildProperty.cs
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildPropertyGroup.cs
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTaskPropertyGroup.cs
mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/TargetTest.cs

index 006fe2b3fa2ec2c44ff4703d567edf0ca283f14f..9c827f0953652ab5bb8bc25b71e14454f50954d3 100644 (file)
@@ -30,6 +30,7 @@
 using System;
 using System.Text;
 using System.Xml;
+using System.Collections.Generic;
 
 using Microsoft.Build.Framework;
 using Microsoft.Build.Utilities;
@@ -241,6 +242,14 @@ namespace Microsoft.Build.BuildEngine {
                internal XmlElement XmlElement {
                        get { return propertyElement; }
                }
+
+               internal IEnumerable<string> GetAttributes ()
+               {
+                       if (!FromXml)
+                               yield break;
+                       foreach (XmlAttribute attr in propertyElement.Attributes)
+                               yield return attr.Value;
+               }
        }
 
        internal enum PropertyType {
index fc6b02447c5e48c4057560c64591d89c49cb3e51..9800c6883f57527042e4bc6cbf9ca3be2dd3e921 100644 (file)
@@ -43,6 +43,7 @@ namespace Microsoft.Build.BuildEngine {
                List <BuildProperty>    properties;
                Dictionary <string, BuildProperty>      propertiesByName;
                bool evaluated;
+               bool isDynamic;
 
                public BuildPropertyGroup ()
                        : this (null, null, null, false)
@@ -50,12 +51,18 @@ namespace Microsoft.Build.BuildEngine {
                }
 
                internal BuildPropertyGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly)
+                       : this (xmlElement, project, importedProject, readOnly, false)
+               {
+               }
+
+               internal BuildPropertyGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly, bool isDynamic)
                {
                        this.importedProject = importedProject;
                        this.parentCollection = null;
                        this.parentProject = project;
                        this.propertyGroup = xmlElement;
                        this.read_only = readOnly;
+                       this.isDynamic = isDynamic;
 
                        if (FromXml) {
                                this.properties = new List <BuildProperty> ();
@@ -223,7 +230,7 @@ namespace Microsoft.Build.BuildEngine {
                
                internal void Evaluate ()
                {
-                       if (evaluated)
+                       if (!isDynamic && evaluated)
                                return;
 
                        foreach (BuildProperty bp in properties)
@@ -299,5 +306,16 @@ namespace Microsoft.Build.BuildEngine {
                internal XmlElement XmlElement {
                        get { return propertyGroup; }
                }
+
+               internal IEnumerable<string> GetAttributes ()
+               {
+                       foreach (XmlAttribute attrib in XmlElement.Attributes)
+                               yield return attrib.Value;
+
+                       foreach (BuildProperty bp in properties) {
+                               foreach (string attr in bp.GetAttributes ())
+                                       yield return attr;
+                       }
+               }
        }
 }
index 4df2f780a9022f9fb63595aae29c6d1828850d25..b5482ae16624f4ae2fc3bbc7f009a94756c09f65 100644 (file)
@@ -38,7 +38,7 @@ namespace Microsoft.Build.BuildEngine {
                }
                
                internal BuildTaskPropertyGroup (XmlElement element, Target target)
-                       : base (element, target.Project, null, false)
+                       : base (element, target.Project, null, false, true)
                {
                }
                
@@ -48,10 +48,9 @@ namespace Microsoft.Build.BuildEngine {
                        return true;
                }
 
-               public IEnumerable<string> GetAttributes ()
+               IEnumerable<string> IBuildTask.GetAttributes ()
                {
-                       foreach (XmlAttribute attrib in XmlElement.Attributes)
-                               yield return attrib.Value;
+                       return GetAttributes ();
                }
                
        }
index 2cced758f0500df01a85ad1a717b5bb81b709a68..84707e5cf12c5b571bcb4dcb142d8253d21f6d4a 100644 (file)
@@ -727,6 +727,28 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
                                        </Target>
                                </Project>", "Sun", "Rain");
                }
+
+               [Test]
+               public void PropertyGroupInsideTarget_Condition ()
+               {
+                       ItemGroupInsideTarget (
+                               @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
+                                       <ItemGroup>
+                                               <Shells Include=""/bin/sh;/bin/bash;/bin/false"" />
+                                       </ItemGroup>
+
+                                       <Target Name='Main'>
+                                               <PropertyGroup>
+                                                       <HasBash Condition=""'%(Shells.Filename)' == 'bash'"">true</HasBash>
+                                               </PropertyGroup>
+
+                                               <ItemGroup Condition=""'$(HasBash)' == 'true'"">
+                                                       <Weather Include='Rain' />
+                                               </ItemGroup>
+                                               <Message Text='%(Weather.Identity)' />
+                                       </Target>
+                               </Project>", "Rain");
+               }
                #endif
 
                [Test]