implemented a lot of ProjectTargetInstance and its descendants. Fixed a lot of Locati...
[mono.git] / mcs / class / Microsoft.Build / Microsoft.Build.Construction / ProjectTargetElement.cs
index d7cc6816bd0aae29d389f1561147e97ea040227a..0ac463d366663729eb9a2190e4193f48d431a73a 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,26 +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 { 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 { 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)); }
@@ -91,9 +112,33 @@ 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 ConditionLocation { get; private set; }
+                 public ElementLocation DependsOnTargetsLocation { get; private set; }
+                 public ElementLocation InputsLocation { get; private set; }
+                 public ElementLocation KeepDuplicateOutputsLocation { get; private set; }
+                 public ElementLocation LabelLocation { get; private set; }
+                 public ElementLocation NameLocation { get; private set; }
+                 public ElementLocation OutputsLocation { get; private set; }
+                 public ElementLocation ReturnsLocation { get; private set; }
+#else
+                 ElementLocation AfterTargetsLocation { get; set; }
+                 ElementLocation BeforeTargetsLocation { get; set; }
+                 ElementLocation ConditionLocation { get; set; }
+                 ElementLocation DependsOnTargetsLocation { get; set; }
+                 ElementLocation InputsLocation { get; set; }
+                 ElementLocation KeepDuplicateOutputsLocation { get; set; }
+                 ElementLocation LabelLocation { get; set; }
+                 ElementLocation NameLocation { get; set; }
+                 ElementLocation OutputsLocation { get; set; }
+                 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);
@@ -103,9 +148,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) {