Author: msierad
Date: 2007-01-16 08:28:39 -0500 (Tue, 16 Jan 2007)
New Revision: 71132
Modified:
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItem.cs
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItemGroup.cs
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItemGroupCollection.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/Engine.cs
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/GroupingCollection.cs
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetCollection.cs
Log:
2007-01-16 Marek Sieradzki <[EMAIL PROTECTED]>
* BuildItemGroup.cs (AddNewItem): Add XML and mark project as dirty.
(Project): Renamed to ParentProject.
* BuildItem.cs (ctor)
(CopyCustomMetadata): Add null check.
* BuildPropertyGroup.cs (AddNewProperty): Reorganized.
(RemoveProperty): Added null check.
* TargetCollection.cs (RemoveTarget): Added null check.
* Engine.cs (UnloadProject): Added null check.
* GroupingCollection.cs (Remove): Check if removed group belongs to
current project.
* Project.cs (AddNewItem): Implemented.
(RemoveItem): Reorganized.
(SetProjectExtensions): Added null check.
Modified:
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItem.cs
===================================================================
---
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItem.cs
2007-01-16 13:18:45 UTC (rev 71131)
+++
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItem.cs
2007-01-16 13:28:39 UTC (rev 71132)
@@ -59,6 +59,9 @@
public BuildItem (string itemName, ITaskItem taskItem)
{
+ if (taskItem == null)
+ throw new ArgumentNullException ("taskItem");
+
this.name = itemName;
this.finalItemSpec = taskItem.ItemSpec;
this.itemInclude = Utilities.Escape (taskItem.ItemSpec);
@@ -107,6 +110,9 @@
public void CopyCustomMetadataTo (BuildItem destinationItem)
{
+ if (destinationItem == null)
+ throw new ArgumentNullException
("destinationItem");
+
foreach (DictionaryEntry de in unevaluatedMetadata)
destinationItem.AddMetadata ((string) de.Key,
(string) de.Value, false);
}
@@ -203,7 +209,7 @@
if (parent_item_group != null) {
Expression e = new Expression ();
e.Parse (value);
- evaluatedMetadata.Add (name, (string)
e.ConvertTo (parent_item_group.Project, typeof (string)));
+ evaluatedMetadata.Add (name, (string)
e.ConvertTo (parent_item_group.ParentProject, typeof (string)));
} else
evaluatedMetadata.Add (name, Utilities.Unescape
(value));
@@ -226,7 +232,7 @@
{
// FIXME: maybe make Expression.ConvertTo (null, ...)
work as Utilities.Unescape ()?
if (project == null) {
- this.finalItemSpec = Utilities.Unescape
(itemInclude);
+ this.finalItemSpec = Utilities.Unescape
(Include);
return;
}
@@ -327,9 +333,9 @@
if (o is string) {
sb.Append ((string)o);
} else if (o is PropertyReference) {
- sb.Append
(((PropertyReference)o).ConvertToString (parent_item_group.Project));
+ sb.Append
(((PropertyReference)o).ConvertToString (parent_item_group.ParentProject));
} else if (o is ItemReference) {
- sb.Append
(((ItemReference)o).ConvertToString (parent_item_group.Project));
+ sb.Append
(((ItemReference)o).ConvertToString (parent_item_group.ParentProject));
} else if (o is MetadataReference) {
sb.Append (GetMetadata
(((MetadataReference)o).MetadataName));
}
Modified:
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItemGroup.cs
===================================================================
---
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItemGroup.cs
2007-01-16 13:18:45 UTC (rev 71131)
+++
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItemGroup.cs
2007-01-16 13:28:39 UTC (rev 71132)
@@ -82,17 +82,31 @@
string itemInclude,
bool treatItemIncludeAsLiteral)
{
+ BuildItem item;
+
if (treatItemIncludeAsLiteral)
itemInclude = Utilities.Escape (itemInclude);
- BuildItem bi = new BuildItem (itemName, itemInclude);
+ if (FromXml) {
+ XmlElement element =
itemGroupElement.OwnerDocument.CreateElement (itemName, Project.XmlNamespace);
+ itemGroupElement.AppendChild (element);
+ element.SetAttribute ("Include", itemInclude);
+ item = new BuildItem (element, this);
+ } else {
+ item = new BuildItem (itemName, itemInclude);
+ }
- bi.Evaluate (null, true);
+ item.Evaluate (null, true);
if (!read_only)
- buildItems.Add (bi);
+ buildItems.Add (item);
- return bi;
+ if (parentProject != null) {
+ parentProject.MarkProjectAsDirty ();
+ parentProject.NeedToReevaluate ();
+ }
+
+ return item;
}
public void Clear ()
@@ -252,7 +266,7 @@
set { parentCollection = value; }
}
- internal Project Project {
+ internal Project ParentProject {
get { return parentProject; }
}
Modified:
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItemGroupCollection.cs
===================================================================
---
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItemGroupCollection.cs
2007-01-16 13:18:45 UTC (rev 71131)
+++
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItemGroupCollection.cs
2007-01-16 13:28:39 UTC (rev 71132)
@@ -50,8 +50,7 @@
if (array == null)
throw new ArgumentNullException ("array");
if (index < 0)
- throw new
- IndexOutOfRangeException ("Index was
outside the bounds of the array.");
+ throw new IndexOutOfRangeException ("Index was
outside the bounds of the array.");
if (array.Rank > 1)
throw new ArgumentException ("array is
multidimensional");
if ((array.Length > 0) && (index >= array.Length))
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-16 13:18:45 UTC (rev 71131)
+++
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildPropertyGroup.cs
2007-01-16 13:28:39 UTC (rev 71132)
@@ -82,42 +82,38 @@
string propertyValue,
bool
treatPropertyValueAsLiteral)
{
- BuildProperty prop;
+ if (!FromXml)
+ throw new InvalidOperationException ("This
method is only valid for persisted property groups.");
- if (FromXml) {
- XmlElement xe;
-
- xe = propertyGroup.OwnerDocument.CreateElement
(propertyName, Project.XmlNamespace);
- propertyGroup.AppendChild (xe);
-
- if (treatPropertyValueAsLiteral)
- xe.InnerText = Utilities.Escape
(propertyValue);
- else
- xe.InnerText = propertyValue;
-
- prop = new BuildProperty (parentProject, xe);
- AddProperty (prop);
- parentProject.NeedToReevaluate ();
+ if (treatPropertyValueAsLiteral)
+ propertyValue = Utilities.Escape
(propertyValue);
- return prop;
- } else
- throw new InvalidOperationException ("This
method is only valid for persisted <System.Object[]> elements.");
+ XmlElement element =
propertyGroup.OwnerDocument.CreateElement (propertyName, Project.XmlNamespace);
+ propertyGroup.AppendChild (element);
+
+ BuildProperty property = new BuildProperty
(parentProject, element);
+ property.Value = propertyValue;
+ AddProperty (property);
+
+ parentProject.MarkProjectAsDirty ();
+ parentProject.NeedToReevaluate ();
+
+ return property;
}
internal void AddProperty (BuildProperty property)
{
- if (FromXml) {
+ if (FromXml)
properties.Add (property);
- } else {
+ else {
if (propertiesByName.ContainsKey
(property.Name)) {
BuildProperty existing =
propertiesByName [property.Name];
if (property.PropertyType <=
existing.PropertyType) {
propertiesByName.Remove
(property.Name);
propertiesByName.Add
(property.Name, property);
}
- } else {
+ } else
propertiesByName.Add (property.Name,
property);
- }
}
}
@@ -148,19 +144,17 @@
public void RemoveProperty (BuildProperty propertyToRemove)
{
+ if (propertyToRemove == null)
+ throw new ArgumentNullException
("propertyToRemove");
+
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 {
- foreach (KeyValuePair <string, BuildProperty>
kvp in propertiesByName)
- if (kvp.Value == propertyToRemove) {
- propertiesByName.Remove
(kvp.Key);
- break;
- }
- }
+ } else
+ propertiesByName.Remove (propertyToRemove.Name);
}
public void RemoveProperty (string propertyName)
Modified:
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
===================================================================
---
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
2007-01-16 13:18:45 UTC (rev 71131)
+++
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
2007-01-16 13:28:39 UTC (rev 71132)
@@ -1,3 +1,25 @@
+2007-01-16 Marek Sieradzki <[EMAIL PROTECTED]>
+
+ * BuildItemGroup.cs (AddNewItem): Add XML and mark project as dirty.
+ (Project): Renamed to ParentProject.
+
+ * BuildItem.cs (ctor)
+ (CopyCustomMetadata): Add null check.
+
+ * BuildPropertyGroup.cs (AddNewProperty): Reorganized.
+ (RemoveProperty): Added null check.
+
+ * TargetCollection.cs (RemoveTarget): Added null check.
+
+ * Engine.cs (UnloadProject): Added null check.
+
+ * GroupingCollection.cs (Remove): Check if removed group belongs to
+ current project.
+
+ * Project.cs (AddNewItem): Implemented.
+ (RemoveItem): Reorganized.
+ (SetProjectExtensions): Added null check.
+
2007-01-14 Marek Sieradzki <[EMAIL PROTECTED]>
* BuildItemGroup.cs (Detach): Added.
Modified:
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
===================================================================
---
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
2007-01-16 13:18:45 UTC (rev 71131)
+++
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
2007-01-16 13:28:39 UTC (rev 71132)
@@ -227,6 +227,9 @@
public void UnloadProject (Project project)
{
+ if (project == null)
+ throw new ArgumentNullException ("project");
+
if (project.ParentEngine != this)
throw new InvalidOperationException ("The
\"Project\" object specified does not belong to the correct \"Engine\"
object.");
Modified:
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/GroupingCollection.cs
===================================================================
---
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/GroupingCollection.cs
2007-01-16 13:18:45 UTC (rev 71131)
+++
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/GroupingCollection.cs
2007-01-16 13:28:39 UTC (rev 71132)
@@ -28,6 +28,7 @@
#if NET_2_0
+using System;
using System.Collections;
using System.Collections.Generic;
@@ -144,6 +145,10 @@
internal void Remove (BuildItemGroup big)
{
+ if (big.ParentProject != project)
+ throw new InvalidOperationException (
+ "The \"BuildItemGroup\" object
specified does not belong to the correct \"Project\" object.");
+
big.Detach ();
list.Remove (big);
}
Modified:
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
===================================================================
---
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
2007-01-16 13:18:45 UTC (rev 71131)
+++
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
2007-01-16 13:28:39 UTC (rev 71132)
@@ -122,12 +122,27 @@
return AddNewItem (itemName, itemInclude, false);
}
- [MonoTODO]
+ [MonoTODO ("Not tested")]
public BuildItem AddNewItem (string itemName,
string itemInclude,
bool treatItemIncludeAsLiteral)
{
- throw new NotImplementedException ();
+ BuildItemGroup big;
+
+ if (itemGroups.Count == 0)
+ big = AddNewItemGroup ();
+ else {
+ BuildItemGroup [] groups = new BuildItemGroup
[itemGroups.Count];
+ itemGroups.CopyTo (groups, 0);
+ big = groups [0];
+ }
+
+ BuildItem item = big.AddNewItem (itemName, itemInclude,
treatItemIncludeAsLiteral);
+
+ MarkProjectAsDirty ();
+ NeedToReevaluate ();
+
+ return item;
}
[MonoTODO ("Not tested")]
@@ -382,15 +397,16 @@
throw new InvalidOperationException ("The
object passed in is not part of the project.");
BuildItemGroup big = itemToRemove.ParentItemGroup;
-
- if (itemToRemove.FromXml) {
- if (big.Count == 1)
- groupingCollection.Remove (big);
- else
+
+ if (big.Count == 1) {
+ // ParentItemGroup for items from xml and that
have parent is the same
+ groupingCollection.Remove (big);
+ } else {
+ if (big.ParentProject != this)
+ throw new InvalidOperationException
("The object passed in is not part of the project.");
+
+ if (itemToRemove.FromXml)
big.RemoveItem (itemToRemove);
- } else {
- if (big.Count == 1)
- groupingCollection.Remove (big);
else
big.RemoveItem
(itemToRemove.ParentItem);
}
@@ -498,14 +514,15 @@
public void SetProjectExtensions (string id, string xmlText)
{
+ if (id == null)
+ throw new ArgumentNullException ("id");
+ if (xmlText == null)
+ throw new ArgumentNullException ("xmlText");
+
XmlNode projectExtensions, node;
- if (id == null || id == String.Empty || xmlText == null)
- return;
-
projectExtensions = xmlDocument.SelectSingleNode
("/tns:Project/tns:ProjectExtensions", XmlNamespaceManager);
-
if (projectExtensions == null) {
projectExtensions = xmlDocument.CreateElement
("ProjectExtensions", XmlNamespace);
xmlDocument.DocumentElement.AppendChild
(projectExtensions);
@@ -870,7 +887,7 @@
throw new ArgumentNullException
("value");
if (value.FromXml)
- throw new InvalidOperationException
("Can't do that.");
+ throw new InvalidOperationException
("GlobalProperties can not be set to persisted property group.");
globalProperties = value;
NeedToReevaluate ();
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-16 13:18:45 UTC (rev 71131)
+++
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetCollection.cs
2007-01-16 13:28:39 UTC (rev 71132)
@@ -88,6 +88,9 @@
public void RemoveTarget (Target targetToRemove)
{
+ if (targetToRemove == null)
+ throw new ArgumentNullException ();
+
targetsByName.Remove (targetToRemove.Name);
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches