2007-02-03 Marek Sieradzki <marek.sieradzki@gmail.com>
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / TaskEngine.cs
index ea4e29db8f88b721fa6647f99586194204e6d272..02e4213cd6c7539832b153e7dcd6177478f9792e 100644 (file)
@@ -107,60 +107,64 @@ namespace Microsoft.Build.BuildEngine {
                        object          o;
                
                        foreach (XmlNode xmlNode in taskElement.ChildNodes) {
-                               if (xmlNode is XmlElement) {
-                                       xmlElement = (XmlElement) xmlNode;
-                                       
-                                       if (xmlElement.Name != "Output")
-                                               throw new InvalidProjectFileException ("Only Output elements can be Task's child nodes.");
-                                       if (xmlElement.GetAttribute ("ItemName") != String.Empty && xmlElement.GetAttribute ("PropertyName") != String.Empty)
-                                               throw new InvalidProjectFileException ("Only one of ItemName and ProperytyName attributes can be specified.");
-                                       if (xmlElement.GetAttribute ("TaskParameter") == String.Empty)
-                                               throw new InvalidProjectFileException ("TaskParameter attribute must be specified.");
-                                               
-                                       taskParameter = xmlElement.GetAttribute ("TaskParameter");
-                                       itemName = xmlElement.GetAttribute ("ItemName");
-                                       propertyName = xmlElement.GetAttribute ("PropertyName");
-                                       
-                                       propertyInfo = taskType.GetProperty (taskParameter);
-                                       if (propertyInfo == null)
-                                               throw new Exception ("Could not get property info.");
-                                       if (propertyInfo.IsDefined (outputAttribute, false) == false)
-                                               throw new Exception ("This is not output property.");
-                                       
-                                       o = propertyInfo.GetValue (task, null);
-                                       if (o == null)
-                                               continue;
+                               if (!(xmlNode is XmlElement))
+                                       continue;
+                       
+                               xmlElement = (XmlElement) xmlNode;
+                               
+                               if (xmlElement.Name != "Output")
+                                       throw new InvalidProjectFileException ("Only Output elements can be Task's child nodes.");
+                               if (xmlElement.GetAttribute ("ItemName") != String.Empty && xmlElement.GetAttribute ("PropertyName") != String.Empty)
+                                       throw new InvalidProjectFileException ("Only one of ItemName and PropertyName attributes can be specified.");
+                               if (xmlElement.GetAttribute ("TaskParameter") == String.Empty)
+                                       throw new InvalidProjectFileException ("TaskParameter attribute must be specified.");
                                        
-                                       if (itemName != String.Empty) {
-                                               PublishItemGroup (propertyInfo, o, itemName);
-                                       } else {
-                                               PublishProperty (propertyInfo, o, propertyName);
-                                       }
+                               taskParameter = xmlElement.GetAttribute ("TaskParameter");
+                               itemName = xmlElement.GetAttribute ("ItemName");
+                               propertyName = xmlElement.GetAttribute ("PropertyName");
+                               
+                               propertyInfo = taskType.GetProperty (taskParameter);
+                               if (propertyInfo == null)
+                                       throw new Exception ("Could not get property info.");
+                               if (!propertyInfo.IsDefined (outputAttribute, false))
+                                       throw new Exception ("This is not output property.");
+                               
+                               o = propertyInfo.GetValue (task, null);
+                               if (o == null)
+                                       continue;
+                               
+                               if (itemName != String.Empty) {
+                                       PublishItemGroup (propertyInfo, o, itemName);
+                               } else {
+                                       PublishProperty (propertyInfo, o, propertyName);
                                }
                        }
                }
                
-               private void InitializeParameter (PropertyInfo propertyInfo, object value)
+               void InitializeParameter (PropertyInfo propertyInfo, object value)
                {
                        propertyInfo.SetValue (task, value, null);
                }
 
-               private void PublishItemGroup (PropertyInfo propertyInfo,
+               void PublishItemGroup (PropertyInfo propertyInfo,
                                               object o,
                                               string itemName)
                {
                        BuildItemGroup newItems = CollectItemGroup (propertyInfo, o, itemName);
-                       if (parentProject.EvaluatedItemsByName.Contains (itemName)) {
-                               BuildItemGroup big = (BuildItemGroup) parentProject.EvaluatedItemsByName [itemName];
+                       
+                       if (parentProject.EvaluatedItemsByName.ContainsKey (itemName)) {
+                               BuildItemGroup big = parentProject.EvaluatedItemsByName [itemName];
                                big.Clear ();
                                parentProject.EvaluatedItemsByName.Remove (itemName);
                                parentProject.EvaluatedItemsByName.Add (itemName, newItems);
                        } else {
                                parentProject.EvaluatedItemsByName.Add (itemName, newItems);
                        }
+                       foreach (BuildItem bi in newItems)
+                               parentProject.EvaluatedItems.AddItem (bi);
                }
                
-               private void PublishProperty (PropertyInfo propertyInfo,
+               void PublishProperty (PropertyInfo propertyInfo,
                                              object o,
                                              string propertyName)
                {
@@ -168,7 +172,7 @@ namespace Microsoft.Build.BuildEngine {
                        parentProject.EvaluatedProperties.AddProperty (bp);
                }
                
-               private BuildProperty CollectProperty (PropertyInfo propertyInfo, object o, string name)
+               BuildProperty CollectProperty (PropertyInfo propertyInfo, object o, string name)
                {
                        string output = null;
                        BuildProperty bp;
@@ -197,7 +201,7 @@ namespace Microsoft.Build.BuildEngine {
                        return bp;
                }
                
-               private BuildItemGroup CollectItemGroup (PropertyInfo propertyInfo, object o, string name)
+               BuildItemGroup CollectItemGroup (PropertyInfo propertyInfo, object o, string name)
                {
                        BuildItemGroup big;
                        string temp;
@@ -226,18 +230,18 @@ namespace Microsoft.Build.BuildEngine {
                        return big;     
                }
                                
-               private object GetObjectFromString (string raw, Type type)
+               object GetObjectFromString (string raw, Type type)
                {
-                       OldExpression e;
+                       Expression e;
                        object result;
                        
-                       e = new OldExpression (parentProject);
-                       e.ParseSource (raw);
+                       e = new Expression ();
+                       e.Parse (raw, true);
                        
-                       if ((string) e.ConvertTo (typeof (string)) == String.Empty)
+                       if ((string) e.ConvertTo (parentProject, typeof (string)) == String.Empty)
                                return null;
                        
-                       result = e.ConvertTo (type);
+                       result = e.ConvertTo (parentProject, type);
                        
                        return result;
                }