Author: msierad
Date: 2007-01-12 04:59:34 -0500 (Fri, 12 Jan 2007)
New Revision: 70908

Modified:
   
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildProperty.cs
   
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildPropertyGroup.cs
   trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
   trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs
   
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetCollection.cs
Log:
2007-01-12  Marek Sieradzki  <[EMAIL PROTECTED]>

        * Target.cs: Throw an exception when <OnError> is not last element in
        target.

        * BuildPropertyGroup.cs (RemoveProperty): Remove from XML.

        * TargetCollection.cs: If a target is already there replace it with
        new target.

        * BuildProperty.cs: Added XmlElement property.



Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildProperty.cs
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildProperty.cs
 2007-01-12 09:56:48 UTC (rev 70907)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildProperty.cs
 2007-01-12 09:59:34 UTC (rev 70908)
@@ -121,7 +121,7 @@
                        parentProject.EvaluatedProperties.AddProperty 
(evaluated);
                }
 
-               bool FromXml {
+               internal bool FromXml {
                        get {
                                return propertyElement != null;
                        }
@@ -178,6 +178,10 @@
                                return propertyType;
                        }
                }
+
+               internal XmlElement XmlElement {
+                       get { return propertyElement; }
+               }
        }
 
        internal enum PropertyType {

Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildPropertyGroup.cs
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildPropertyGroup.cs
    2007-01-12 09:56:48 UTC (rev 70907)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildPropertyGroup.cs
    2007-01-12 09:59:34 UTC (rev 70908)
@@ -147,9 +147,13 @@
 
                public void RemoveProperty (BuildProperty propertyToRemove)
                {
-                       if (FromXml)
+                       if (FromXml) {
+                               if (!propertyToRemove.FromXml)
+                                       throw new InvalidOperationException 
("The specified property does not belong to the current property group.");
+
+                               
propertyToRemove.XmlElement.ParentNode.RemoveChild 
(propertyToRemove.XmlElement);
                                properties.Remove (propertyToRemove);
-                       else {
+                       } else {
                                foreach (KeyValuePair <string, BuildProperty> 
kvp in propertiesByName)
                                        if (kvp.Value == propertyToRemove) {
                                                propertiesByName.Remove 
(kvp.Key);
@@ -163,7 +167,7 @@
                        if (FromXml) {
                                foreach (BuildProperty bp in properties)
                                        if (bp.Name == propertyName) {
-                                               properties.Remove (bp);
+                                               RemoveProperty (bp);
                                                break;
                                        }
                        } else

Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog    
    2007-01-12 09:56:48 UTC (rev 70907)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog    
    2007-01-12 09:59:34 UTC (rev 70908)
@@ -1,5 +1,17 @@
-2007-01-12  Marek Sieradzki  <[EMAIL PROTECTED]>\
+2007-01-12  Marek Sieradzki  <[EMAIL PROTECTED]>
 
+       * Target.cs: Throw an exception when <OnError> is not last element in
+       target.
+
+       * BuildPropertyGroup.cs (RemoveProperty): Remove from XML.
+
+       * TargetCollection.cs: If a target is already there replace it with
+       new target.
+
+       * BuildProperty.cs: Added XmlElement property.
+
+2007-01-12  Marek Sieradzki  <[EMAIL PROTECTED]>
+
        * ImportCollection.cs: Don't add imports that are already added.
 
        * BuildItemGroup.cs: MonoTODOs.

Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs    
    2007-01-12 09:56:48 UTC (rev 70907)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs    
    2007-01-12 09:59:34 UTC (rev 70908)
@@ -65,14 +65,18 @@
                        this.buildTasks = new List <BuildTask> ();
                        this.batchingImpl = new BatchingImpl (project, 
this.targetElement);
 
+                       bool onErrorFound = false;
                        foreach (XmlNode xn in targetElement.ChildNodes) {
                                if (xn is XmlElement) {
                                        XmlElement xe = (XmlElement) xn;
                                        if (xe.Name == "OnError") {
                                                onErrorElements.Add (xe);
-                                               continue;
-                                       }
-                                       buildTasks.Add (new BuildTask (xe, 
this));
+                                               onErrorFound = true;
+                                       } else if (onErrorFound)
+                                               throw new 
InvalidProjectFileException (
+                                                       "The element <OnError> 
must be last under element <Target>. Found element <Error> instead.");
+                                       else
+                                               buildTasks.Add (new BuildTask 
(xe, this));
                                }
                        }
                }

Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetCollection.cs
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetCollection.cs
      2007-01-12 09:56:48 UTC (rev 70907)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetCollection.cs
      2007-01-12 09:59:34 UTC (rev 70908)
@@ -52,10 +52,6 @@
                                throw new InvalidProjectFileException (
                                        "The required attribute \"Name\" is 
missing from element <Target>.");
                
-                       // FIXME: test it
-                       if (targetsByName.ContainsKey (targetName))
-                               throw new Exception ("target already exists");
-                               
                        XmlElement targetElement = 
parentProject.XmlDocument.CreateElement ("Target", Project.XmlNamespace);
                        parentProject.XmlDocument.DocumentElement.AppendChild 
(targetElement);
                        targetElement.SetAttribute ("Name", targetName);
@@ -69,6 +65,8 @@
 
                internal void AddTarget (Target target)
                {
+                       if (targetsByName.ContainsKey (target.Name))
+                               targetsByName.Remove (target.Name);
                        targetsByName.Add (target.Name, target);
                }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to