* Makefile ($(build_lib)): Make CYCLIC_DEP_FILES depend on this.
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / BuildProperty.cs
index 50e0877bdf2eb4a364eff640d5ce5fbe007fb58d..f8701183adf847cf173df37e74b2eda7df633dc2 100644 (file)
@@ -42,19 +42,17 @@ namespace Microsoft.Build.BuildEngine {
                Project         parentProject;
                PropertyType    propertyType;
 
-               internal bool FromXml {
-                       get {
-                               return propertyElement != null;
-                       }
-               }
-       
-               private BuildProperty ()
+               BuildProperty ()
                {
                }
 
-               public BuildProperty (string propertyName, string propertyValue):
-                       this(propertyName, propertyValue, PropertyType.Global)
+               public BuildProperty (string propertyName, string propertyValue)
+                       : this (propertyName, propertyValue, PropertyType.Normal)
                {
+                       if (propertyName == null)
+                               throw new ArgumentNullException ("propertyName");
+                       if (propertyValue == null)
+                               throw new ArgumentNullException ("propertyValue");
                }
 
                internal BuildProperty (string propertyName,
@@ -76,31 +74,32 @@ namespace Microsoft.Build.BuildEngine {
                        this.propertyType = PropertyType.Normal;
                        this.parentProject = parentProject;
                        this.name = propertyElement.Name;
-                       this.value = propertyElement.InnerText;
+                       this.value = propertyElement.InnerXml;
                        this.isImported = false;
                }
 
                [MonoTODO]
                public BuildProperty Clone (bool deepClone)
                {
-                       return (BuildProperty) this.MemberwiseClone ();
-               }
-
-               // Evaluate the property.
-               internal void Evaluate()
-               {
-                       if (FromXml) {
-                               Expression exp = new Expression (parentProject, Value);
-                               finalValue = (string) exp.ToNonArray (typeof (string));
-                               parentProject.EvaluatedProperties.AddProperty (this);
+                       if (deepClone) {
+                               if (FromXml) 
+                                       throw new NotImplementedException ();
+                               else
+                                       return (BuildProperty) this.MemberwiseClone ();
+                       } else {
+                               if (FromXml)
+                                       throw new NotImplementedException ();
+                               else
+                                       throw new InvalidOperationException ("A shallow clone of this object cannot be created.");
                        }
                }
 
-               public static implicit operator string (BuildProperty propertyToCast)
+               public static explicit operator string (BuildProperty propertyToCast)
                {
                        if (propertyToCast == null)
-                               throw new ArgumentNullException ("propertyToCast");
-                       return propertyToCast.ToString ();
+                               return String.Empty;
+                       else
+                               return propertyToCast.ToString ();
                }
 
                public override string ToString ()
@@ -111,9 +110,36 @@ namespace Microsoft.Build.BuildEngine {
                                return Value;
                }
 
+               internal void Evaluate ()
+               {
+                       BuildProperty evaluated = new BuildProperty (Name, Value);
+
+                       Expression exp = new Expression ();
+                       exp.Parse (Value, false, false);
+                       evaluated.finalValue = (string) exp.ConvertTo (parentProject, typeof (string));
+
+                       parentProject.EvaluatedProperties.AddProperty (evaluated);
+               }
+
+               internal bool FromXml {
+                       get {
+                               return propertyElement != null;
+                       }
+               }
+       
                public string Condition {
-                       get { return propertyElement.GetAttribute ("Condition"); }
-                       set { propertyElement.SetAttribute ("Condition", value); }
+                       get {
+                               if (FromXml)
+                                       return propertyElement.GetAttribute ("Condition");
+                               else
+                                       return String.Empty;
+                       }
+                       set {
+                               if (FromXml)
+                                       propertyElement.SetAttribute ("Condition", value);
+                               else
+                                       throw new InvalidOperationException ("Cannot set a condition on an object not represented by an XML element in the project file.");
+                       }
                }
 
                public string FinalValue {
@@ -138,10 +164,12 @@ namespace Microsoft.Build.BuildEngine {
                                return value;
                        }
                        set {
+                               this.@value = value;
                                if (FromXml) {
-                                       propertyElement.InnerText = value;
+                                       propertyElement.InnerXml = value;
+                               } else {
+                                       finalValue = value;
                                }
-                               this.@value = value;
                        }
                }
 
@@ -150,6 +178,10 @@ namespace Microsoft.Build.BuildEngine {
                                return propertyType;
                        }
                }
+
+               internal XmlElement XmlElement {
+                       get { return propertyElement; }
+               }
        }
 
        internal enum PropertyType {