[MSBuild] Fixed issues found by Paul Selormey.
authorLeszek 'skolima' Ciesielski <skolima@gmail.com>
Sat, 25 Jun 2011 13:57:06 +0000 (15:57 +0200)
committerLeszek 'skolima' Ciesielski <skolima@gmail.com>
Sat, 25 Jun 2011 14:53:56 +0000 (16:53 +0200)
Unset attributes should return String.Empty, null is only for invalid.

14 files changed:
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectCommentElement.cs
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectElement.cs
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectImportElement.cs
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectItemElement.cs
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectMetadataElement.cs
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectOtherwiseElement.cs
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectOutputElement.cs
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectPropertyElement.cs
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectRootElement.cs
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectTargetElement.cs
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectTaskElement.cs
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectUsingTaskBodyElement.cs
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectUsingTaskElement.cs
mcs/class/Microsoft.Build/Microsoft.Build.Construction/ProjectUsingTaskParameterElement.cs

index 25078185493b7688af046284dba2c9ebc90dc256..23666183d10b77662988932ea4c85a0370845026 100644 (file)
@@ -1,5 +1,5 @@
 //
-// ProjectUsingTaskBodyElement.cs
+// ProjectCommentElement.cs
 //
 // Author:
 //   Leszek Ciesielski (skolima@gmail.com)
@@ -38,7 +38,8 @@ namespace Microsoft.Build.Construction
                         ContainingProject = containingProject;
                 }
 
-                public string Comment { get; set; }
+                string comment;
+                public string Comment { get { return comment ?? String.Empty; } set { comment = value; } }
 
                 internal override string XmlName {
                         get { return String.Empty; }
index 89c1016a9f73f83eeb53d586f4ebd8c36bbecaed..7454665b7e2c73b0bb9849de8d124ed47b9d7004 100644 (file)
@@ -49,8 +49,10 @@ namespace Microsoft.Build.Construction
                         get { return LinkedListNode.Next == null ? null : LinkedListNode.Next.Value; }
                         internal set { }
                 }
-                public string Label { get; set; }
-                public virtual string Condition { get; set; }
+                string label;
+                public string Label { get { return label ?? String.Empty; } set { label = value; } }
+                string condition;
+                public virtual string Condition { get { return condition ?? String.Empty; } set { condition = value; } }
                 public IEnumerable<ProjectElementContainer> AllParents {
                         get {
                                 var parent = Parent;
index d5458d8cd274eb24ddb85428ccbdc0ceb658095a..d824cc7ee307dda80d679454d7eaa4cfaf59cc2d 100644 (file)
@@ -26,6 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System;
 using System.Xml;
 namespace Microsoft.Build.Construction
 {
@@ -43,7 +44,8 @@ namespace Microsoft.Build.Construction
                         ContainingProject = containingProject;
                 }
 
-                public string Project { get; set; }
+                string project;
+                public string Project { get { return project ?? String.Empty; } set { project = value; } }
 
                 internal override string XmlName {
                         get { return "Import"; }
index 89f7eee7dd7e2e2d3c321e3ef2ccd881c56a6474..02a1a6ec4995f231f27bcc7501802ee4043cb2c2 100644 (file)
@@ -26,6 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using Microsoft.Build.Internal;
@@ -42,20 +43,24 @@ namespace Microsoft.Build.Construction
                         ItemType = itemType;
                         ContainingProject = containingProject;
                 }
-                public string Exclude { get; set; }
+                string exclude;
+                public string Exclude { get { return exclude ?? String.Empty; } set { exclude = value; } }
                 public bool HasMetadata {
                         get {
                                 var metadata = Metadata.FirstOrDefault ();
                                 return metadata != null;
                         }
                 }
-                public string Include { get; set; }
-                public string ItemType { get; set; }
+                string include;
+                public string Include { get { return include ?? String.Empty; } set { include = value; } }
+                string itemType;
+                public string ItemType { get { return itemType ?? String.Empty; } set { itemType = value; } }
                 public ICollection<ProjectMetadataElement> Metadata {
                         get { return new CollectionFromEnumerable<ProjectMetadataElement> (
                                 new FilteredEnumerable<ProjectMetadataElement> (Children)); }
                 }
-                public string Remove { get; set; }
+                string @remove;
+                public string Remove { get { return @remove ?? String.Empty; } set { @remove = value; } }
                 public ProjectMetadataElement AddMetadata (string name, string unevaluatedValue)
                 {
                         var metadata = ContainingProject.CreateMetadataElement (name, unevaluatedValue);
index cf3978e88e8e3260f56e7a48c61b66491c938e39..797a04d04d425158adf82570694fe4b938fd1ff4 100644 (file)
@@ -26,6 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System;
 using System.Collections.Generic;
 using System.Xml;
 
@@ -39,8 +40,10 @@ namespace Microsoft.Build.Construction
                         Name = name;
                         ContainingProject = containingProject;
                 }
-                public string Name { get; set; }
-                public string Value { get; set; }
+                string name;
+                public string Name { get { return name ?? String.Empty; } set { name = value; } }
+                string internalValue;
+                public string Value { get { return internalValue ?? String.Empty; } set { internalValue = value; } }
                 internal override string XmlName {
                         get { return Name; }
                 }
index 781ffbffa958378bdb9f366bd3405c61f0a29fa8..9c25e506581456b118a5cc844ad1655216ef0d44 100644 (file)
@@ -45,7 +45,12 @@ namespace Microsoft.Build.Construction
                         get { return new CollectionFromEnumerable<ProjectChooseElement> (
                                 new FilteredEnumerable<ProjectChooseElement> (Children)); }
                 }
-                public override string Condition { get; set; }
+                public override string Condition {
+                        get { return null; }
+                        set {
+                                throw new InvalidOperationException ("Can not set Condition.");
+                        }
+                }
                 public ICollection<ProjectItemGroupElement> ItemGroups {
                         get { return new CollectionFromEnumerable<ProjectItemGroupElement> (
                                 new FilteredEnumerable<ProjectItemGroupElement> (Children)); }
index 130df77c955682cbd8c8ed8a6cd8f7e386ee367f..bb5693758d8c4264e113a4ba89e7160be1b3025a 100644 (file)
@@ -26,6 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System;
 using System.Xml;
 namespace Microsoft.Build.Construction
 {
@@ -42,14 +43,20 @@ namespace Microsoft.Build.Construction
                         ContainingProject = containintProject;
                 }
                 public bool IsOutputItem {
-                        get { return true; }
+                        get { return !String.IsNullOrWhiteSpace(itemType); }
                 }
                 public bool IsOutputProperty {
-                        get { return !IsOutputItem; }
+                        get { return !String.IsNullOrWhiteSpace(propertyName); }
+                }
+                string itemType;
+                public string ItemType { get { return itemType ?? String.Empty; } set { itemType = value; } }
+                string propertyName;
+                public string PropertyName { get { return propertyName ?? String.Empty; } set { propertyName = value; } }
+                string taskParameter;
+                public string TaskParameter {
+                        get { return taskParameter ?? String.Empty; }
+                        set { taskParameter = value; }
                 }
-                public string ItemType { get; set; }
-                public string PropertyName { get; set; }
-                public string TaskParameter { get; set; }
                 internal override string XmlName {
                         get { return "Output"; }
                 }
index 6247e5631cd4136bed5d2e1bb3fe6108f84ba142..27cba95cee4c7853091c67604c373c569b69d021 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System;
 using System.Xml;
 namespace Microsoft.Build.Construction
 {
         [System.Diagnostics.DebuggerDisplayAttribute ("{Name} Value={Value} Condition={Condition}")]
         public class ProjectPropertyElement : ProjectElement
         {
-                public string Name { get; set; }
-                public string Value { get; set; }
+                string name;
+                public string Name { get { return name ?? String.Empty; } set { name = value; } }
+                string internalValue;
+                public string Value { get { return internalValue ?? String.Empty; } set { internalValue = value; } }
                 internal ProjectPropertyElement (string name, ProjectRootElement containingProject)
                 {
                         Name = name;
index 83d157cc0efa9c720ad675cfea7f0874d3abd096..ddbed1f42c55342d615e3235b4a72d236fbb2070 100644 (file)
@@ -46,7 +46,11 @@ namespace Microsoft.Build.Construction
         {
                 public override string Condition { get { return null; } set { throw new InvalidOperationException (
                         "Can not set Condition."); } }
-                public string DefaultTargets { get; set; }
+                string defaultTargets;
+                public string DefaultTargets {
+                        get { return defaultTargets ?? String.Empty; }
+                        set { defaultTargets = value; }
+                }
 
                 string fullPath;
                 public string FullPath {
@@ -96,7 +100,11 @@ namespace Microsoft.Build.Construction
                                 new FilteredEnumerable<ProjectImportElement> (AllChildren)); }
                 }
 
-                public string InitialTargets { get; set; }
+                string initialTargets;
+                public string InitialTargets {
+                        get { return initialTargets ?? String.Empty; }
+                        set { initialTargets = value; }
+                }
 
                 public ICollection<ProjectItemDefinitionGroupElement> ItemDefinitionGroups {
                         get { return new CollectionFromEnumerable<ProjectItemDefinitionGroupElement> (
@@ -160,9 +168,9 @@ namespace Microsoft.Build.Construction
                         get { return DateTime.Now; }
                 }
 
-                string toolsVersion = "4.0";
+                string toolsVersion;
                 public string ToolsVersion {
-                        get { return toolsVersion; }
+                        get { return toolsVersion ?? "4.0"; }
                         set { toolsVersion = value; }
                 }
 
index d7cc6816bd0aae29d389f1561147e97ea040227a..66129eb7daf013d0c6e6ab00dfcf4a16144d035d 100644 (file)
@@ -45,26 +45,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)); }
index a1d2fd9ebfa08932a498a1798af29a4815bb201e..00e0654526206a930df28bc04c21bfb5fc2fed59 100644 (file)
@@ -48,8 +48,13 @@ namespace Microsoft.Build.Construction
                 {
                         ContainingProject = containingProject;
                 }
-                public string ContinueOnError { get; set; }
-                public string Name { get; private set; }
+                string continueOnError;
+                public string ContinueOnError {
+                        get { return continueOnError ?? String.Empty; }
+                        set { continueOnError = value; }
+                }
+                string name;
+                public string Name { get { return name ?? String.Empty; } private set { name = value; } }
                 public ICollection<ProjectOutputElement> Outputs {
                         get { return new CollectionFromEnumerable<ProjectOutputElement> (
                                 new FilteredEnumerable<ProjectOutputElement> (AllChildren)); }
index 92a491fec46db9f419949d522b79071f91f04ff0..eecc92aa27974cffe2bc270643b4af5f85978536 100644 (file)
@@ -39,10 +39,12 @@ namespace Microsoft.Build.Construction
                         TaskBody = body;
                         ContainingProject = containingProject;
                 }
-                public string Evaluate { get; set; }
+                string evaluate;
+                public string Evaluate { get { return evaluate ?? String.Empty; } set { evaluate = value; } }
                 public override string Condition { get { return null; } set { throw new InvalidOperationException (
                         "Can not set Condition."); } }
-                public string TaskBody { get; set; }
+                string taskBody;
+                public string TaskBody { get { return taskBody ?? String.Empty; } set { taskBody = value; } }
                 internal override string XmlName {
                         get { return "Task"; }
                 }
index 80c859aa2e2a2a666e551f42bf18d551213aef38..83a5d607493a502c50c656854ba566933e7701d9 100644 (file)
@@ -44,16 +44,26 @@ namespace Microsoft.Build.Construction
                         AssemblyName = assemblyName;
                         ContainingProject = containingProject;
                 }
-                public string AssemblyFile { get; set; }
-                public string AssemblyName { get; set; }
+                string assemblyFile;
+                public string AssemblyFile {
+                        get { return assemblyFile ?? String.Empty; }
+                        set { assemblyFile = value; }
+                }
+                string assemblyName;
+                public string AssemblyName {
+                        get { return assemblyName ?? String.Empty; }
+                        set { assemblyName = value; }
+                }
                 public UsingTaskParameterGroupElement ParameterGroup {
                         get { return FirstChild as UsingTaskParameterGroupElement; }
                 }
                 public ProjectUsingTaskBodyElement TaskBody {
                         get { return LastChild as ProjectUsingTaskBodyElement; }
                 }
-                public string TaskFactory { get; set; }
-                public string TaskName { get; set; }
+                string taskFactory;
+                public string TaskFactory { get { return taskFactory ?? String.Empty; } set { taskFactory = value; } }
+                string taskName;
+                public string TaskName { get { return taskName ?? String.Empty; } set { taskName = value; } }
                 public UsingTaskParameterGroupElement AddParameterGroup ()
                 {
                         var @group = ContainingProject.CreateUsingTaskParameterGroupElement ();
index c6e8056d10585b0733765832157747c29a0d9a6b..845b8b7f0688829bea7bb1ce246215aeb80f64e6 100644 (file)
@@ -42,12 +42,19 @@ namespace Microsoft.Build.Construction
                         ParameterType = parameterType;
                         ContainingProject = containingProject;
                 }
-                public string Name { get; set; }
+                string name;
+                public string Name { get { return name ?? String.Empty; } set { name = value; } }
                 public override string Condition { get { return null; } set { throw new InvalidOperationException (
                         "Can not set Condition."); } }
-                public string Output { get; set; }
-                public string ParameterType { get; set; }
-                public string Required { get; set; }
+                string output;
+                public string Output { get { return output ?? String.Empty; } set { output = value; } }
+                string parameterType;
+                public string ParameterType {
+                        get { return parameterType ?? String.Empty; }
+                        set { parameterType = value; }
+                }
+                string required;
+                public string Required { get { return required ?? String.Empty; } set { required = value; } }
                 internal override string XmlName {
                         get { return Name; }
                 }