Merge pull request #4453 from lambdageek/bug-49721
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / BuildProperty.cs
index beac4824396ea67c4a54b3a47c7b26343e4ebc49..f0936a3f65be3a40311e12ecc59e3300bfba0591 100644 (file)
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-#if NET_2_0
-
 using System;
 using System.Text;
 using System.Xml;
+using System.Collections.Generic;
 
 using Microsoft.Build.Framework;
 using Microsoft.Build.Utilities;
+using Mono.XBuild.Utilities;
 
 namespace Microsoft.Build.BuildEngine {
        public class BuildProperty {
@@ -80,7 +80,7 @@ namespace Microsoft.Build.BuildEngine {
                        this.propertyType = PropertyType.Normal;
                        this.parentProject = parentProject;
                        this.name = propertyElement.Name;
-                       this.value = Utilities.UnescapeFromXml (propertyElement.InnerXml);
+                       this.value = MSBuildUtils.UnescapeFromXml (propertyElement.InnerXml);
                        this.isImported = false;
                }
 
@@ -121,10 +121,8 @@ namespace Microsoft.Build.BuildEngine {
                        BuildProperty evaluated = new BuildProperty (Name, Value);
 
                        // In evaluate phase, properties are not expanded
-                       Expression exp = new Expression ();
-                       exp.Parse (Value, ParseOptions.None);
-                       evaluated.finalValue = (string) exp.ConvertTo (parentProject, typeof (string),
-                                       ExpressionOptions.DoNotExpandItemRefs);
+                       evaluated.finalValue = Expression.ParseAs<string> (Value, ParseOptions.None, 
+                               parentProject, ExpressionOptions.DoNotExpandItemRefs);
 
                        parentProject.EvaluatedProperties.AddProperty (evaluated);
                }
@@ -173,8 +171,8 @@ namespace Microsoft.Build.BuildEngine {
                                Expression exp = new Expression ();
 
                                // in non-evaluation phase, properties are always expanded
-                               exp.Parse (FinalValue, options == ExpressionOptions.ExpandItemRefs ?
-                                                       ParseOptions.AllowItems : ParseOptions.None);
+                               exp.Parse (FinalValue, ParseOptions.Split | (options == ExpressionOptions.ExpandItemRefs ?
+                                                       ParseOptions.AllowItems : ParseOptions.None));
                                return (ITaskItem[]) exp.ConvertTo (project, typeof (ITaskItem[]), options);
                        } finally {
                                converting = false;
@@ -242,6 +240,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 {
@@ -251,5 +257,3 @@ namespace Microsoft.Build.BuildEngine {
                Environment
        }
 }
-
-#endif