Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
//
// ElementLocation.cs
//
// Author:
// Atsushi Enomoto (atsushi@xamarin.com)
//
// Copyright (C) 2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using Microsoft.Build.Framework;
using System;
using System.Collections.Generic;
namespace Microsoft.Build.Construction
{
[Serializable]
#if NET_4_5
public
#endif
abstract class ElementLocation
{
public abstract int Column { get; }
public abstract string File { get; }
public abstract int Line { get; }
public string LocationString {
get { return Line == 0 ? File : String.Format ("{0} ({1}{2})", File, Line, Column != 0 ? "," + Column : String.Empty); }
}
public override bool Equals (object other)
{
var o = other as ElementLocation;
return (object) o != null && o.File == File && o.Line == Line && o.Column == Column;
}
public override int GetHashCode ()
{
return (File.GetHashCode () << 16) + (Line << 8) + Column;
}
}
}

View File

@@ -0,0 +1,76 @@
//
// ProjectChooseElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Microsoft.Build.Exceptions;
using Microsoft.Build.Internal;
namespace Microsoft.Build.Construction
{
[System.Diagnostics.DebuggerDisplayAttribute ("ProjectChooseElement (#Children={Count} "
+ "HasOtherwise={OtherwiseElement != null})")]
public class ProjectChooseElement : ProjectElementContainer
{
internal ProjectChooseElement (ProjectRootElement containingProject)
{
ContainingProject = containingProject;
}
public override string Condition { get { return null; } set { throw new InvalidOperationException(
"Can not set Condition."); } }
public ProjectOtherwiseElement OtherwiseElement {
get { return LastChild as ProjectOtherwiseElement; }
}
public ICollection<ProjectWhenElement> WhenElements {
get { return new CollectionFromEnumerable<ProjectWhenElement> (
new FilteredEnumerable<ProjectWhenElement> (Children)); }
}
internal override string XmlName {
get { return "Choose"; }
}
internal override ProjectElement LoadChildElement (XmlReader reader)
{
var name = reader.LocalName;
switch (name) {
case "Otherwise":
var other = ContainingProject.CreateOtherwiseElement ();
AppendChild (other);
return other;
case "When":
var when = ContainingProject.CreateWhenElement (null);
PrependChild (when);
return when;
default:
throw new InvalidProjectFileException (string.Format (
"Child \"{0}\" is not a known node type.", name));
}
}
}
}

View File

@@ -0,0 +1,77 @@
//
// ProjectCommentElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Xml;
namespace Microsoft.Build.Construction
{
internal class ProjectCommentElement : ProjectElement
{
internal ProjectCommentElement (ProjectRootElement containingProject)
{
ContainingProject = containingProject;
}
string comment;
public string Comment { get { return comment ?? String.Empty; } set { comment = value; } }
internal override string XmlName {
get { return String.Empty; }
}
internal override void Load (XmlReader reader)
{
FillLocation (reader);
LoadValue (reader);
}
internal override void LoadAttribute (string name, string value)
{
}
internal override void LoadValue (XmlReader reader)
{
if (reader.NodeType == XmlNodeType.Comment) {
Comment = reader.Value;
}
}
internal override void Save (XmlWriter writer)
{
this.SaveValue (writer);
}
internal override void SaveValue (XmlWriter writer)
{
if (!String.IsNullOrEmpty (Comment)) {
writer.WriteComment (Comment);
}
}
}
}

View File

@@ -0,0 +1,169 @@
//
// ProjectElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Xml;
using Microsoft.Build.Exceptions;
namespace Microsoft.Build.Construction
{
public abstract class ProjectElement
{
internal const string MSBuildNamespace = "http://schemas.microsoft.com/developer/msbuild/2003";
internal ProjectElement ()
{
linkedListNode = new LinkedListNode<ProjectElement> (this);
}
public ProjectRootElement ContainingProject { get; internal set; }
public ProjectElement PreviousSibling {
get { return LinkedListNode.Previous == null ? null : LinkedListNode.Previous.Value; }
internal set { }
}
public ProjectElementContainer Parent { get; internal set; }
public ProjectElement NextSibling {
get { return LinkedListNode.Next == null ? null : LinkedListNode.Next.Value; }
internal 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;
while (parent != null) {
yield return parent;
parent = parent.Parent;
}
}
}
readonly LinkedListNode<ProjectElement> linkedListNode;
internal LinkedListNode<ProjectElement> LinkedListNode { get { return linkedListNode; } }
internal virtual void Load (XmlReader reader)
{
reader.ReadToFollowing (XmlName);
FillLocation (reader);
while (reader.MoveToNextAttribute ()) {
LoadAttribute (reader.Name, reader.Value);
}
reader.MoveToElement ();
LoadValue (reader);
}
internal virtual void LoadAttribute (string name, string value)
{
switch (name) {
case "xmlns":
break;
case "Label":
Label = value;
break;
case "Condition":
Condition = value;
break;
default:
throw new InvalidProjectFileException (Location, null, string.Format (
"Attribute \"{0}\" is not known on node \"{1}\" [type {2}].", name, XmlName,
GetType ()));
}
}
internal virtual void LoadValue (XmlReader reader)
{
}
internal abstract string XmlName { get; }
internal virtual void Save (XmlWriter writer)
{
writer.WriteStartElement (XmlName);
SaveValue (writer);
writer.WriteEndElement ();
}
internal virtual void SaveValue (XmlWriter writer)
{
SaveAttribute (writer, "Label", Label);
SaveAttribute (writer, "Condition", Condition);
}
internal void SaveAttribute (XmlWriter writer, string attributeName, string attributeValue)
{
if (!string.IsNullOrWhiteSpace (attributeValue))
writer.WriteAttributeString (attributeName, attributeValue);
}
#if NET_4_5
public ElementLocation Location { get; private set; }
public ElementLocation LabelLocation { get; private set; }
public ElementLocation ConditionLocation { get; private set; }
#else
internal ElementLocation Location { get; private set; }
internal ElementLocation LabelLocation { get; private set; }
internal ElementLocation ConditionLocation { get; private set; }
#endif
string GetFilePath (string baseURI)
{
return string.IsNullOrEmpty (baseURI) ? string.Empty : new Uri (baseURI).LocalPath;
}
internal void FillLocation (XmlReader reader)
{
var l = reader as IXmlLineInfo;
var path = GetFilePath (reader.BaseURI);
if (l != null && l.HasLineInfo ())
Location = new ProjectElementLocation (path, l);
if (reader.MoveToAttribute ("Condition") && l.HasLineInfo ())
ConditionLocation = new ProjectElementLocation (path, l);
if (reader.MoveToAttribute ("Label") && l.HasLineInfo ())
LabelLocation = new ProjectElementLocation (path, l);
reader.MoveToElement ();
}
class ProjectElementLocation : ElementLocation
{
public ProjectElementLocation (string file, IXmlLineInfo li)
{
this.file = file;
this.line = li.LineNumber;
this.column = li.LinePosition;
}
string file;
int line;
int column;
public override string File { get { return file; } }
public override int Line { get { return line; } }
public override int Column { get { return column; } }
}
internal InvalidProjectFileException CreateError (XmlReader reader, string message, int columnOffset = 0)
{
var li = reader as IXmlLineInfo;
bool valid = li != null && li.HasLineInfo ();
throw new InvalidProjectFileException (reader.BaseURI, valid ? li.LineNumber : 0, valid ? li.LinePosition + columnOffset : 0, 0, 0, message, null, null, null);
}
}
}

View File

@@ -0,0 +1,157 @@
//
// ProjectElementContainer.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Microsoft.Build.Exceptions;
using Microsoft.Build.Internal;
namespace Microsoft.Build.Construction
{
public abstract class ProjectElementContainer : ProjectElement
{
internal ProjectElementContainer () {}
LinkedList<ProjectElement> children = new LinkedList<ProjectElement> ();
public IEnumerable<ProjectElement> AllChildren {
get {
foreach (var child in Children) {
var container = child as ProjectElementContainer;
if (container != null)
foreach (var containersChild in container.AllChildren)
yield return containersChild;
yield return child;
}
}
}
public ICollection<ProjectElement> Children {
get { return new CollectionFromEnumerable<ProjectElement> (
children.Where (p => !(p is ProjectCommentElement))); }
}
public ICollection<ProjectElement> ChildrenReversed {
get { return new CollectionFromEnumerable<ProjectElement> (
new ReverseEnumerable<ProjectElement> (children)); }
}
public int Count {
get { return children.Count; }
}
public ProjectElement FirstChild {
get { return children.First == null ? null : children.First.Value; }
private set { }
}
public ProjectElement LastChild {
get { return children.Last == null ? null: children.Last.Value; }
private set { }
}
public void AppendChild (ProjectElement child)
{
children.AddLast (child.LinkedListNode);
child.Parent = this;
}
public void InsertAfterChild (ProjectElement child, ProjectElement reference)
{
if (reference == null) {
PrependChild (child);
} else {
child.Parent = this;
children.AddAfter (reference.LinkedListNode, child.LinkedListNode);
}
}
public void InsertBeforeChild (ProjectElement child, ProjectElement reference)
{
if (reference == null) {
AppendChild (child);
} else {
child.Parent = this;
children.AddBefore (reference.LinkedListNode, child.LinkedListNode);
}
}
public void PrependChild (ProjectElement child)
{
children.AddFirst (child.LinkedListNode);
child.Parent = this;
}
public void RemoveAllChildren ()
{
foreach (var child in children)
RemoveChild (child);
}
public void RemoveChild (ProjectElement child)
{
child.Parent = null;
children.Remove (child.LinkedListNode);
}
internal override void SaveValue (XmlWriter writer)
{
base.SaveValue (writer);
foreach (var child in children)
child.Save (writer);
}
internal override void Load (XmlReader reader)
{
reader.Read ();
reader.MoveToContent ();
FillLocation (reader);
if (reader.LocalName != XmlName || reader.NamespaceURI != MSBuildNamespace)
throw CreateError (reader, string.Format ("Unexpected XML {0} \"{1}\" in namespace \"{2}\" appeared, while \"{3}\" in namespace \"{4}\" is expected.",
reader.NodeType, reader.LocalName, reader.NamespaceURI, XmlName, MSBuildNamespace), -1);
while (reader.MoveToNextAttribute ()) {
LoadAttribute (reader.Name, reader.Value);
}
LoadValue (reader);
}
internal override void LoadValue (XmlReader reader)
{
while (reader.Read ()) {
if (reader.NodeType == XmlNodeType.Element) {
var child = LoadChildElement (reader);
child.Load (reader.ReadSubtree ());
} else if (reader.NodeType == XmlNodeType.Comment) {
var commentElement = new ProjectCommentElement (ContainingProject);
commentElement.Load (reader);
AppendChild (commentElement);
}
}
}
internal abstract ProjectElement LoadChildElement (XmlReader reader);
}
}

View File

@@ -0,0 +1,91 @@
//
// ProjectExtensionsElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Xml;
using System.Text;
namespace Microsoft.Build.Construction
{
public class ProjectExtensionsElement : ProjectElement
{
internal ProjectExtensionsElement (ProjectRootElement containingProject)
{
ContainingProject = containingProject;
}
public override string Condition {
get { return null; }
set {
throw new InvalidOperationException ("Can not set Condition.");
}
}
public string Content {
get { return element.InnerXml; }
set { element.InnerXml = value; }
}
public string this[string name] {
get {
var child = element[name];
return child == null ? string.Empty : child.InnerXml;
}
set {
var child = element[name];
if (child == null) {
if (string.IsNullOrEmpty (name))
return;
child = document.CreateElement (name);
element.AppendChild (child);
}
if (string.IsNullOrEmpty (value))
element.RemoveChild (child);
else
child.InnerXml = value;
}
}
internal override void Load (XmlReader reader)
{
while (reader.Read () && reader.NodeType != XmlNodeType.Element)
;
FillLocation (reader);
using (XmlReader subReader = reader.ReadSubtree ()) {
document = new XmlDocument ();
document.Load (subReader);
element = document.DocumentElement;
}
}
internal override void SaveValue (XmlWriter writer)
{
element.WriteContentTo (writer);
}
internal override string XmlName {
get { return "ProjectExtensions"; }
}
XmlDocument document;
XmlElement element;
}
}

View File

@@ -0,0 +1,82 @@
//
// ProjectImportElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Xml;
using Microsoft.Build.Exceptions;
namespace Microsoft.Build.Construction
{
[System.Diagnostics.DebuggerDisplayAttribute ("Project={Project} Condition={Condition}")]
public class ProjectImportElement : ProjectElement
{
internal ProjectImportElement (string project, ProjectRootElement containingProject)
: this(containingProject)
{
Project = project;
}
internal ProjectImportElement (ProjectRootElement containingProject)
{
ContainingProject = containingProject;
}
string project;
public string Project { get { return project ?? String.Empty; } set { project = value; } }
internal override string XmlName {
get { return "Import"; }
}
internal override void SaveValue (XmlWriter writer)
{
SaveAttribute (writer, "Project", Project);
base.SaveValue (writer);
}
internal override void LoadValue (XmlReader reader)
{
if (string.IsNullOrWhiteSpace (Project))
throw new InvalidProjectFileException (Location, null, "Project attribute is null or empty on an Import element");
base.LoadValue (reader);
}
internal override void LoadAttribute (string name, string value)
{
switch (name) {
case "Project":
Project = value;
break;
default:
base.LoadAttribute (name, value);
break;
}
}
}
}

View File

@@ -0,0 +1,59 @@
//
// ProjectImportGroupElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using Microsoft.Build.Internal;
using System.Xml;
namespace Microsoft.Build.Construction
{
[System.Diagnostics.DebuggerDisplayAttribute ("#Imports={Count} Condition={Condition} Label={Label}")]
public class ProjectImportGroupElement : ProjectElementContainer
{
internal ProjectImportGroupElement (ProjectRootElement containingProject)
{
ContainingProject = containingProject;
}
public ICollection<ProjectImportElement> Imports {
get { return new CollectionFromEnumerable<ProjectImportElement> (
new FilteredEnumerable<ProjectImportElement> (Children)); }
}
public ProjectImportElement AddImport (string project)
{
var import = ContainingProject.CreateImportElement (project);
AppendChild (import);
return import;
}
internal override string XmlName { get { return "ImportGroup"; } }
internal override ProjectElement LoadChildElement (XmlReader reader)
{
return AddImport (null);
}
}
}

View File

@@ -0,0 +1,65 @@
//
// ProjectItemDefinitionElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Microsoft.Build.Internal;
namespace Microsoft.Build.Construction
{
[System.Diagnostics.DebuggerDisplayAttribute ("{ItemType} #Metadata={Count} Condition={Condition}")]
public class ProjectItemDefinitionElement : ProjectElementContainer
{
internal ProjectItemDefinitionElement (string itemType, ProjectRootElement containingProject)
{
ItemType = itemType;
ContainingProject = containingProject;
}
public string ItemType { get; private set; }
public ICollection<ProjectMetadataElement> Metadata {
get { return new CollectionFromEnumerable<ProjectMetadataElement> (
new FilteredEnumerable<ProjectMetadataElement> (Children)); }
}
public ProjectMetadataElement AddMetadata (string name, string unevaluatedValue)
{
var metadata = ContainingProject.CreateMetadataElement (name);
metadata.Value = unevaluatedValue;
AppendChild (metadata);
return metadata;
}
internal override string XmlName {
get { return ItemType; }
}
internal override ProjectElement LoadChildElement (XmlReader reader)
{
return AddMetadata (reader.LocalName, null);
}
}
}

View File

@@ -0,0 +1,62 @@
//
// ProjectItemDefinitionGroupElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Microsoft.Build.Internal;
namespace Microsoft.Build.Construction
{
[System.Diagnostics.DebuggerDisplayAttribute ("#ItemDefinitions={Count} Condition={Condition} Label={Label}")]
public class ProjectItemDefinitionGroupElement : ProjectElementContainer
{
internal ProjectItemDefinitionGroupElement (ProjectRootElement containingProject)
{
ContainingProject = containingProject;
}
public ICollection<ProjectItemDefinitionElement> ItemDefinitions {
get { return new CollectionFromEnumerable<ProjectItemDefinitionElement> (
new FilteredEnumerable<ProjectItemDefinitionElement> (Children)); }
}
public ProjectItemDefinitionElement AddItemDefinition (string itemType)
{
var definition = ContainingProject.CreateItemDefinitionElement (itemType);
AppendChild (definition);
return definition;
}
internal override string XmlName {
get { return "ItemDefinitionGroup"; }
}
internal override ProjectElement LoadChildElement (XmlReader reader)
{
return AddItemDefinition (reader.LocalName);
}
}
}

View File

@@ -0,0 +1,149 @@
//
// ProjectItemElementa.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// 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;
using System.Xml;
using Microsoft.Build.Exceptions;
namespace Microsoft.Build.Construction
{
[System.Diagnostics.DebuggerDisplayAttribute ("{ItemType} Include={Include} Exclude={Exclude} "
+ "#Metadata={Count} Condition={Condition}")]
public class ProjectItemElement : ProjectElementContainer
{
internal ProjectItemElement (string itemType, ProjectRootElement containingProject)
{
ItemType = itemType;
ContainingProject = containingProject;
}
string exclude;
public string Exclude { get { return exclude ?? String.Empty; } set { exclude = value; } }
public bool HasMetadata {
get {
var metadata = Metadata.FirstOrDefault ();
return metadata != null;
}
}
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)); }
}
string @remove;
public string Remove { get { return @remove ?? String.Empty; } set { @remove = value; } }
#if NET_4_5
string keepDuplicates;
public string KeepDuplicates { get { return keepDuplicates ?? String.Empty; } set { keepDuplicates = value; } }
string keepMetadata;
public string KeepMetadata { get { return keepMetadata ?? String.Empty; } set { keepMetadata = value; } }
string removeMetadata;
public string RemoveMetadata { get { return removeMetadata ?? String.Empty; } set { removeMetadata = value; } }
#endif
public ProjectMetadataElement AddMetadata (string name, string unevaluatedValue)
{
var metadata = ContainingProject.CreateMetadataElement (name, unevaluatedValue);
AppendChild (metadata);
return metadata;
}
internal override string XmlName {
get { return ItemType; }
}
internal override void SaveValue (XmlWriter writer)
{
SaveAttribute (writer, "Include", Include);
SaveAttribute (writer, "Exclude", Exclude);
#if NET_4_5
SaveAttribute (writer, "KeepDuplicates", KeepDuplicates);
SaveAttribute (writer, "KeepMetadata", KeepMetadata);
SaveAttribute (writer, "RemoveMetadata", RemoveMetadata);
#endif
SaveAttribute (writer, "Remove", Remove);
base.SaveValue (writer);
}
internal override void LoadAttribute (string name, string value)
{
switch (name) {
case "Include":
Include = value;
break;
case "Exclude":
Exclude = value;
break;
#if NET_4_5
case "KeepDuplicates":
KeepDuplicates = value;
break;
case "KeepMetadata":
KeepMetadata = value;
break;
case "RemoveMetadata":
RemoveMetadata = value;
break;
#endif
case "Remove":
Remove = value;
break;
default:
base.LoadAttribute (name, value);
break;
}
}
internal override void LoadValue (XmlReader reader)
{
if (string.IsNullOrWhiteSpace (Include) && string.IsNullOrEmpty (Remove))
throw new InvalidProjectFileException (Location, null, string.Format ("Both Include and Remove attribute are null or empty on '{0}' item", ItemType));
base.LoadValue (reader);
}
internal override ProjectElement LoadChildElement (XmlReader reader)
{
var metadata = ContainingProject.CreateMetadataElement (reader.LocalName);
AppendChild (metadata);
return metadata;
}
#if NET_4_5
public ElementLocation ExcludeLocation { get; private set; }
public ElementLocation IncludeLocation { get; private set; }
public ElementLocation KeepDuplicatesLocation { get; private set; }
public ElementLocation RemoveLocation { get; private set; }
public ElementLocation RemoveMetadataLocation { get; private set; }
#else
ElementLocation ExcludeLocation { get; set; }
ElementLocation IncludeLocation { get; set; }
ElementLocation KeepDuplicatesLocation { get; set; }
ElementLocation RemoveLocation { get; set; }
ElementLocation RemoveMetadataLocation { get; set; }
#endif
}
}

View File

@@ -0,0 +1,95 @@
//
// ProjectItemGroupElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Microsoft.Build.Internal;
namespace Microsoft.Build.Construction
{
[System.Diagnostics.DebuggerDisplayAttribute ("#Items={Count} Condition={Condition} Label={Label}")]
public class ProjectItemGroupElement : ProjectElementContainer
{
public ProjectItemElement AddItem (string itemType, string include)
{
return AddItem (itemType, include, null);
}
public ProjectItemElement AddItem (string itemType, string include,
IEnumerable<KeyValuePair<string, string>> metadata)
{
var item = ContainingProject.CreateItemElement (itemType, include);
if (metadata != null)
foreach (var data in metadata)
item.AddMetadata (data.Key, data.Value);
var lastChild = LastChild;
foreach (var existingItem in Items) {
var compare = string.Compare (item.ItemType, existingItem.ItemType,
StringComparison.OrdinalIgnoreCase);
if (compare == 0) {
if (string.Compare (item.Include, existingItem.Include,
StringComparison.OrdinalIgnoreCase) >= 0)
continue;
lastChild = existingItem.PreviousSibling;
break;
}
if (compare < 0) {
lastChild = existingItem.PreviousSibling;
break;
}
}
InsertAfterChild (item, lastChild);
return item;
}
internal ProjectItemGroupElement (ProjectRootElement containingProject)
{
ContainingProject = containingProject;
}
public ICollection<ProjectItemElement> Items {
get { return new CollectionFromEnumerable<ProjectItemElement> (
new FilteredEnumerable<ProjectItemElement> (Children)); }
}
internal override string XmlName {
get { return "ItemGroup"; }
}
internal override ProjectElement LoadChildElement (XmlReader reader)
{
var item = ContainingProject.CreateItemElement (reader.LocalName);
AppendChild (item);
return item;
}
}
}

View File

@@ -0,0 +1,63 @@
//
// ProjectMetadataElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Xml;
namespace Microsoft.Build.Construction
{
[System.Diagnostics.DebuggerDisplayAttribute ("{Name} Value={Value} Condition={Condition}")]
public class ProjectMetadataElement : ProjectElement
{
internal ProjectMetadataElement (string name, ProjectRootElement containingProject)
{
Name = name;
ContainingProject = containingProject;
}
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; }
}
internal override void SaveValue (XmlWriter writer)
{
base.SaveValue (writer);
if (!string.IsNullOrWhiteSpace (Value))
writer.WriteValue (Value);
}
internal override void LoadValue (XmlReader reader)
{
while (reader.Read () & reader.NodeType != XmlNodeType.Text)
;
Value = reader.Value;
}
}
}

View File

@@ -0,0 +1,70 @@
//
// ProjectOnErrorElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Xml;
namespace Microsoft.Build.Construction
{
[System.Diagnostics.DebuggerDisplayAttribute ("ExecuteTargets={ExecuteTargets}")]
public class ProjectOnErrorElement : ProjectElement
{
internal ProjectOnErrorElement (string executeTargets, ProjectRootElement containingProject)
: this(containingProject)
{
ExecuteTargetsAttribute = executeTargets;
}
internal ProjectOnErrorElement (ProjectRootElement containingProject)
{
ContainingProject = containingProject;
}
public string ExecuteTargetsAttribute { get; set; }
internal override string XmlName {
get { return "OnError"; }
}
internal override void SaveValue (XmlWriter writer)
{
base.SaveValue (writer);
SaveAttribute (writer, "ExecuteTargets", ExecuteTargetsAttribute);
}
internal override void LoadAttribute (string name, string value)
{
switch (name) {
case "ExecuteTargets":
ExecuteTargetsAttribute = value;
break;
default:
base.LoadAttribute (name, value);
break;
}
}
#if NET_4_5
public
#endif
ElementLocation ExecuteTargetsAttributeLocation { get; set; }
}
}

View File

@@ -0,0 +1,87 @@
//
// ProjectOtherwiseElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections.Generic;
using System;
using System.Linq;
using System.Xml;
using Microsoft.Build.Exceptions;
using Microsoft.Build.Internal;
namespace Microsoft.Build.Construction
{
[System.Diagnostics.DebuggerDisplayAttribute ("#Children={Count}")]
public class ProjectOtherwiseElement : ProjectElementContainer
{
internal ProjectOtherwiseElement (ProjectRootElement containingProject)
{
ContainingProject = containingProject;
}
public ICollection<ProjectChooseElement> ChooseElements {
get { return new CollectionFromEnumerable<ProjectChooseElement> (
new FilteredEnumerable<ProjectChooseElement> (Children)); }
}
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)); }
}
public ICollection<ProjectPropertyGroupElement> PropertyGroups {
get { return new CollectionFromEnumerable<ProjectPropertyGroupElement> (
new FilteredEnumerable<ProjectPropertyGroupElement> (Children)); }
}
internal override string XmlName {
get { return "Otherwise"; }
}
internal override ProjectElement LoadChildElement (XmlReader reader)
{
switch (reader.LocalName) {
case "PropertyGroup":
var property = ContainingProject.CreatePropertyGroupElement ();
AppendChild (property);
return property;
case "ItemGroup":
var item = ContainingProject.CreateItemGroupElement ();
AppendChild (item);
return item;
case "When":
var when = ContainingProject.CreateWhenElement (null);
AppendChild (when);
return when;
default:
throw new InvalidProjectFileException (string.Format (
"Child \"{0}\" is not a known node type.", reader.LocalName));
}
}
}
}

View File

@@ -0,0 +1,97 @@
//
// ProjectOutputElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// 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={Name} TaskParameter={TaskParameter} ItemName={ItemName} "
+ "PropertyName={PropertyName} Condition={Condition}")]
public class ProjectOutputElement : ProjectElement
{
internal ProjectOutputElement (string taskParameter, string itemType, string propertyName,
ProjectRootElement containintProject)
{
TaskParameter = taskParameter;
ItemType = itemType;
PropertyName = propertyName;
ContainingProject = containintProject;
}
public bool IsOutputItem {
get { return !String.IsNullOrWhiteSpace(itemType); }
}
public bool IsOutputProperty {
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; }
}
#if NET_4_5
ElementLocation taskParameterLocation;
public ElementLocation TaskParameterLocation {
get { return taskParameterLocation; }
set { taskParameterLocation = value; }
}
#endif
internal override string XmlName {
get { return "Output"; }
}
internal override void SaveValue (XmlWriter writer)
{
base.SaveValue (writer);
SaveAttribute (writer, "TaskParameter", TaskParameter);
if (IsOutputProperty)
SaveAttribute (writer, "PropertyName", PropertyName);
else
SaveAttribute (writer, "ItemName", ItemType);
}
internal override void LoadAttribute (string name, string value)
{
switch (name) {
case "TaskParameter":
TaskParameter = value;
break;
case "PropertyName":
PropertyName = value;
break;
case "ItemName":
ItemType = value;
break;
default:
base.LoadAttribute (name, value);
break;
}
}
}
}

View File

@@ -0,0 +1,61 @@
//
// ProjectPropertyElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// 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
{
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;
ContainingProject = containingProject;
}
internal override string XmlName {
get { return Name; }
}
internal override void SaveValue (XmlWriter writer)
{
base.SaveValue (writer);
if (!string.IsNullOrWhiteSpace (Value))
writer.WriteValue (Value);
}
internal override void LoadValue (XmlReader reader)
{
while (reader.Read () & reader.NodeType != XmlNodeType.Text)
;
Value = reader.Value;
}
}
}

View File

@@ -0,0 +1,90 @@
//
// ProjectPropertyGroupElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// 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;
using System.Xml;
namespace Microsoft.Build.Construction
{
[System.Diagnostics.DebuggerDisplayAttribute ("#Properties={Count} Condition={Condition} Label={Label}")]
public class ProjectPropertyGroupElement : ProjectElementContainer
{
public ProjectPropertyElement AddProperty (string name, string unevaluatedValue)
{
var property = ContainingProject.CreatePropertyElement (name);
property.Value = unevaluatedValue;
AppendChild (property);
return property;
}
public ProjectPropertyElement SetProperty (string name, string unevaluatedValue)
{
var existing = Properties.Where (p => p.Name.Equals (name, StringComparison.OrdinalIgnoreCase)
&& p.Condition.Length == 0).FirstOrDefault ();
if (existing != null) {
existing.Value = unevaluatedValue;
return existing;
}
return AddProperty (name, unevaluatedValue);
}
internal ProjectPropertyGroupElement (ProjectRootElement containingProject)
{
ContainingProject = containingProject;
}
public ICollection<ProjectPropertyElement> Properties {
get { return new CollectionFromEnumerable<ProjectPropertyElement> (
new FilteredEnumerable<ProjectPropertyElement> (Children)); }
}
public ICollection<ProjectPropertyElement> PropertiesReversed {
get { return new CollectionFromEnumerable<ProjectPropertyElement> (
new FilteredEnumerable<ProjectPropertyElement> (ChildrenReversed)); }
}
internal override string XmlName {
get { return "PropertyGroup"; }
}
internal override ProjectElement LoadChildElement (XmlReader reader)
{
switch (reader.LocalName) {
case "ItemGroup":
case "PropertyGroup":
throw CreateError (reader, string.Format ("{0} is a reserved name that cannot be used for a property.", reader.LocalName));
// others need to be checked too, but things like "Project" are somehow allowed...
}
return AddProperty (reader.LocalName, null);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,197 @@
//
// ProjectTargetElement.cs
//
// Author:
// Leszek Ciesielski (skolima@gmail.com)
//
// (C) 2011 Leszek Ciesielski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Microsoft.Build.Internal;
namespace Microsoft.Build.Construction
{
[System.Diagnostics.DebuggerDisplayAttribute ("Name={Name} #Children={Count} Condition={Condition}")]
public class ProjectTargetElement : ProjectElementContainer
{
internal ProjectTargetElement (string name, ProjectRootElement containingProject)
: this(containingProject)
{
Name = name;
}
internal ProjectTargetElement (ProjectRootElement containingProject)
{
ContainingProject = containingProject;
}
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)); }
}
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)); }
}
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)); }
}
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)); }
}
public ProjectItemGroupElement AddItemGroup ()
{
var item = ContainingProject.CreateItemGroupElement ();
AppendChild (item);
return item;
}
public ProjectPropertyGroupElement AddPropertyGroup ()
{
var property = ContainingProject.CreatePropertyGroupElement ();
AppendChild (property);
return property;
}
public ProjectTaskElement AddTask (string taskName)
{
var task = ContainingProject.CreateTaskElement (taskName);
AppendChild (task);
return task;
}
internal override string XmlName {
get { return "Target"; }
}
#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 (reader.LocalName) {
case "OnError":
var error = new ProjectOnErrorElement (ContainingProject);
AppendChild (error);
return error;
case "PropertyGroup":
return AddPropertyGroup ();
case "ItemGroup":
return AddItemGroup ();
default:
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) {
case "Name":
Name = value;
break;
case "DependsOnTargets":
DependsOnTargets = value;
break;
case "Returns":
Returns = value;
break;
case "Inputs":
Inputs = value;
break;
case "Outputs":
Outputs = value;
break;
case "BeforeTargets":
BeforeTargets = value;
break;
case "AfterTargets":
AfterTargets = value;
break;
case "KeepDuplicateOutputs":
KeepDuplicateOutputs = value;
break;
default:
base.LoadAttribute (name, value);
break;
}
}
internal override void SaveValue (System.Xml.XmlWriter writer)
{
SaveAttribute (writer, "Name", Name);
SaveAttribute (writer, "DependsOnTargets", DependsOnTargets);
SaveAttribute (writer, "Returns", Returns);
SaveAttribute (writer, "Inputs", Inputs);
SaveAttribute (writer, "Outputs", Outputs);
SaveAttribute (writer, "BeforeTargets", BeforeTargets);
SaveAttribute (writer, "AfterTargets", AfterTargets);
SaveAttribute (writer, "KeepDuplicateOutputs", KeepDuplicateOutputs);
base.SaveValue (writer);
}
}
}

Some files were not shown because too many files have changed in this diff Show More