Merge pull request #820 from brendanzagaeski/master
[mono.git] / mcs / class / Microsoft.Build / Microsoft.Build.Construction / ProjectTargetElement.cs
index ada608a22065612fc306137e1907295952c03514..cfaaa60c18c0803503451ee12d364665c216cf84 100644 (file)
@@ -29,6 +29,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Xml;
 using Microsoft.Build.Internal;
 
 namespace Microsoft.Build.Construction
@@ -45,28 +46,46 @@ namespace Microsoft.Build.Construction
                 {
                         ContainingProject = containingProject;
                 }
-                public string AfterTargets { get; set; }
-                public string BeforeTargets { get; set; }
-                public string DependsOnTargets { get; set; }
-                public string Inputs { get; set; }
+                string afterTargets;
+                public string AfterTargets {
+                        get { return afterTargets ?? String.Empty; }
+                        set { afterTargets = value; }
+                }
+                string beforeTargets;
+                public string BeforeTargets {
+                        get { return beforeTargets ?? String.Empty; }
+                        set { beforeTargets = value; }
+                }
+                string dependsOnTargets;
+                public string DependsOnTargets {
+                        get { return dependsOnTargets ?? String.Empty; }
+                        set { dependsOnTargets = value; }
+                }
+                string inputs;
+                public string Inputs { get { return inputs ?? String.Empty; } set { inputs = value; } }
                 public ICollection<ProjectItemGroupElement> ItemGroups {
-                        get {
-                                throw new NotImplementedException ();
-                        }
+                        get { return new CollectionFromEnumerable<ProjectItemGroupElement> (
+                                new FilteredEnumerable<ProjectItemGroupElement> (Children)); }
                 }
-                public string KeepDuplicateOutputs { get; set; }
-                public string Name { get; set; }
+                string keepDuplicateOutputs;
+                public string KeepDuplicateOutputs {
+                        get { return keepDuplicateOutputs ?? String.Empty; }
+                        set { keepDuplicateOutputs = value; }
+                }
+                string name;
+                public string Name { get { return name ?? String.Empty; } set { name = value; } }
                 public ICollection<ProjectOnErrorElement> OnErrors {
                         get { return new CollectionFromEnumerable<ProjectOnErrorElement> (
                                 new FilteredEnumerable<ProjectOnErrorElement> (Children)); }
                 }
-                public string Outputs { get; set; }
+                string outputs;
+                public string Outputs { get { return outputs ?? String.Empty; } set { outputs = value; } }
                 public ICollection<ProjectPropertyGroupElement> PropertyGroups {
-                        get {
-                                throw new NotImplementedException ();
-                        }
+                        get { return new CollectionFromEnumerable<ProjectPropertyGroupElement> (
+                                new FilteredEnumerable<ProjectPropertyGroupElement> (Children)); }
                 }
-                public string Returns { get; set; }
+                string returns;
+                public string Returns { get { return returns ?? String.Empty; } set { returns = value; } }
                 public ICollection<ProjectTaskElement> Tasks {
                         get { return new CollectionFromEnumerable<ProjectTaskElement> (
                                 new FilteredEnumerable<ProjectTaskElement> (Children)); }
@@ -93,9 +112,30 @@ namespace Microsoft.Build.Construction
                         get { return "Target"; }
                 }
 
-                internal override ProjectElement LoadChildElement (string name)
+#if NET_4_5
+                 public ElementLocation AfterTargetsLocation { get; private set; }
+                 public ElementLocation BeforeTargetsLocation { get; private set; }
+                 public ElementLocation DependsOnTargetsLocation { get; private set; }
+                 public ElementLocation InputsLocation { get; private set; }
+                 public ElementLocation KeepDuplicateOutputsLocation { get; private set; }
+                 public ElementLocation NameLocation { get; private set; }
+                 public ElementLocation OutputsLocation { get; private set; }
+                 public ElementLocation ReturnsLocation { get; private set; }
+#else
+                 internal ElementLocation AfterTargetsLocation { get; set; }
+                 internal ElementLocation BeforeTargetsLocation { get; set; }
+                 internal ElementLocation DependsOnTargetsLocation { get; set; }
+                 internal ElementLocation InputsLocation { get; set; }
+                 internal ElementLocation KeepDuplicateOutputsLocation { get; set; }
+                 internal ElementLocation LabelLocation { get; set; }
+                 internal ElementLocation NameLocation { get; set; }
+                 internal ElementLocation OutputsLocation { get; set; }
+                 internal ElementLocation ReturnsLocation { get; set; }
+#endif
+
+                internal override ProjectElement LoadChildElement (XmlReader reader)
                 {
-                        switch (name) {
+                        switch (reader.LocalName) {
                         case "OnError":
                                 var error = new ProjectOnErrorElement (ContainingProject);
                                 AppendChild (error);
@@ -105,9 +145,10 @@ namespace Microsoft.Build.Construction
                         case "ItemGroup":
                                 return AddItemGroup ();
                         default:
-                                return AddTask (name);
+                                return AddTask (reader.LocalName);
                         }
                 }
+                // This seriously needs to change to become able to fill ElementLocation...
                 internal override void LoadAttribute (string name, string value)
                 {
                         switch (name) {