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,256 @@
//
// BatchingImplBase.cs: Base class that implements BatchingAlgorithm from the wiki.
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
// Ankit Jain (jankit@novell.com)
//
// (C) 2005 Marek Sieradzki
// Copyright 2008 Novell, Inc (http://www.novell.com)
// Copyright 2009 Novell, Inc (http://www.novell.com)
//
// 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.IO;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using Microsoft.Build.Framework;
namespace Microsoft.Build.BuildEngine {
internal class BatchingImplBase {
protected Dictionary<string, BuildItemGroup> consumedItemsByName;
protected List<MetadataReference> consumedMetadataReferences;
protected List<MetadataReference> consumedQMetadataReferences;
protected List<MetadataReference> consumedUQMetadataReferences;
protected Dictionary<string, BuildItemGroup> batchedItemsByName;
protected Dictionary<string, BuildItemGroup> commonItemsByName;
protected Project project;
protected ICollection<Dictionary<string, BuildItemGroup>> buckets;
protected BatchingImplBase (Project project)
{
if (project == null)
throw new ArgumentNullException ("project");
this.project = project;
}
protected void Init ()
{
// all referenced item lists
consumedItemsByName = new Dictionary<string, BuildItemGroup> (StringComparer.OrdinalIgnoreCase);
// all referenced metadata
consumedMetadataReferences = new List<MetadataReference> ();
consumedQMetadataReferences = new List<MetadataReference> ();
consumedUQMetadataReferences = new List<MetadataReference> ();
}
protected void BatchAndPrepareBuckets ()
{
batchedItemsByName = new Dictionary<string, BuildItemGroup> (StringComparer.OrdinalIgnoreCase);
// These will passed as is for every batch
commonItemsByName = new Dictionary<string, BuildItemGroup> (StringComparer.OrdinalIgnoreCase);
ValidateUnqualifiedMetadataReferences ();
if (consumedUQMetadataReferences.Count > 0) {
// Atleast one unqualified metadata ref is found, so
// batching will be done for all referenced item lists
foreach (KeyValuePair<string, BuildItemGroup> pair in consumedItemsByName)
batchedItemsByName [pair.Key] = pair.Value;
}
// All items referred via qualified metadata refs will be batched
foreach (MetadataReference mr in consumedQMetadataReferences) {
BuildItemGroup group;
if (project.TryGetEvaluatedItemByNameBatched (mr.ItemName, out group))
batchedItemsByName [mr.ItemName] = group;
}
// CommonItemNames = ConsumedItemNames - BatchedItemNames
foreach (KeyValuePair<string, BuildItemGroup> pair in consumedItemsByName) {
if (!batchedItemsByName.ContainsKey (pair.Key))
commonItemsByName [pair.Key] = pair.Value;
}
// Bucketizing
buckets = Bucketize ();
}
protected void ParseAttribute (string value)
{
Expression expr = new Expression ();
expr.Parse (value, ParseOptions.AllowItemsMetadataAndSplit);
foreach (object o in expr.Collection) {
MetadataReference mr = o as MetadataReference;
if (mr != null) {
consumedMetadataReferences.Add (mr);
if (mr.IsQualified)
consumedQMetadataReferences.Add (mr);
else
consumedUQMetadataReferences.Add (mr);
continue;
}
ItemReference ir = o as ItemReference;
if (ir != null) {
BuildItemGroup group;
if (!project.TryGetEvaluatedItemByNameBatched (ir.ItemName, out group))
if (!project.EvaluatedItemsByName.TryGetValue (ir.ItemName, out group))
group = new BuildItemGroup ();
consumedItemsByName [ir.ItemName] = group;
}
}
}
//Ensure that for every metadataReference in consumedUQMetadataReferences,
//every item in every itemlist in consumedItemsByName has a non-null value
//for that metadata
void ValidateUnqualifiedMetadataReferences ()
{
if (consumedUQMetadataReferences.Count > 0 &&
consumedItemsByName.Count == 0 &&
consumedQMetadataReferences.Count == 0) {
throw new Exception ("Item metadata should be referenced with the item name %(ItemName.MetadataName)");
}
foreach (MetadataReference mr in consumedUQMetadataReferences) {
foreach (KeyValuePair<string, BuildItemGroup> pair in consumedItemsByName) {
foreach (BuildItem item in pair.Value) {
if (item.HasMetadata (mr.MetadataName))
continue;
throw new Exception (String.Format (
"Metadata named '{0}' not found in item named {1} in item list named {2}",
mr.MetadataName, item.FinalItemSpec, pair.Key));
}
}
}
}
ICollection<Dictionary<string, BuildItemGroup>> Bucketize ()
{
var buckets = new Dictionary<string, Dictionary<string, BuildItemGroup>> (
StringComparer.OrdinalIgnoreCase);
// For each item list represented in "BatchedItemNames", and then for each item
// within that list, get the values for that item for each of the metadata in
// "ConsumedMetadataReferences". In the table of metadata values, "%(MyItem.MyMetadata)"
// would get a separate entry than "%(MyMetadata)", even though the metadata name is the same.
foreach (KeyValuePair<string, BuildItemGroup> pair in batchedItemsByName) {
string itemName = pair.Key;
BuildItemGroup group = pair.Value;
foreach (BuildItem item in group) {
StringBuilder key_sb = new StringBuilder ();
string value = String.Empty;
// build the bucket key, unique set of metadata values
foreach (MetadataReference mr in consumedMetadataReferences) {
value = String.Empty;
if (mr.IsQualified) {
if (String.Compare (mr.ItemName, itemName) == 0)
value = item.GetEvaluatedMetadata (mr.MetadataName);
} else {
if (item.HasMetadata (mr.MetadataName))
value = item.GetEvaluatedMetadata (mr.MetadataName);
}
key_sb.AppendFormat ("{0}.{1}:{2},",
mr.IsQualified ? mr.ItemName : "",
mr.MetadataName,
value);
}
// Every bucket corresponds to a unique _set_ of metadata values
// So, every bucket would have itemGroups with same set of metadata
// values
string bucket_key = key_sb.ToString ();
Dictionary<string, BuildItemGroup> bucket;
if (!buckets.TryGetValue (bucket_key, out bucket))
// new bucket
buckets [bucket_key] = bucket = new Dictionary<string, BuildItemGroup> (
StringComparer.OrdinalIgnoreCase);
string itemGroup_key = item.Name;
BuildItemGroup itemGroup;
if (!bucket.TryGetValue (itemGroup_key, out itemGroup))
bucket [itemGroup_key] = itemGroup = new BuildItemGroup ();
itemGroup.AddItem (item);
}
}
if (buckets.Values.Count == 0) {
// no buckets
buckets.Add ("none", new Dictionary<string, BuildItemGroup> ());
AddEmptyGroups (buckets);
if (buckets ["none"].Values.Count == 0)
buckets.Remove ("none");
} else {
AddEmptyGroups (buckets);
}
return buckets.Values;
}
void AddEmptyGroups (Dictionary<string, Dictionary<string, BuildItemGroup>> buckets)
{
foreach (Dictionary<string, BuildItemGroup> bucket in buckets.Values) {
foreach (string name in batchedItemsByName.Keys) {
BuildItemGroup group;
if (!bucket.TryGetValue (name, out group))
bucket [name] = new BuildItemGroup ();
}
}
}
public void DumpBuckets (Dictionary<string, Dictionary<string, BuildItemGroup>> buckets)
{
foreach (KeyValuePair<string, Dictionary<string, BuildItemGroup>> pair in buckets) {
Console.WriteLine ("Bucket> {0} {", pair.Key);
DumpBucket (pair.Value);
Console.WriteLine ("}");
}
}
public static void DumpBucket (Dictionary<string, BuildItemGroup> bucket)
{
foreach (KeyValuePair<string, BuildItemGroup> bpair in bucket) {
Console.WriteLine ("\t{0} [", bpair.Key);
foreach (BuildItem item in bpair.Value)
Console.WriteLine ("\t\t{0} - {1}", item.Name, item.FinalItemSpec);
Console.WriteLine ("\t]");
}
}
}
}

View File

@@ -0,0 +1,99 @@
//
// BuildChoose.cs: Represents <Choose>.
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2005 Marek Sieradzki
//
// 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.BuildEngine {
internal class BuildChoose {
BuildWhen otherwise;
//Project project;
//ImportedProject importedProject;
//XmlElement xmlElement;
List <BuildWhen> whens;
public BuildChoose (XmlElement xmlElement, Project project)
: this (xmlElement, project, null)
{
}
internal BuildChoose (XmlElement xmlElement, Project project, ImportedProject importedProject)
{
//this.xmlElement = xmlElement;
//this.project = project;
//this.importedProject = importedProject;
this.whens = new List <BuildWhen> ();
foreach (XmlNode xn in xmlElement.ChildNodes) {
if (!(xn is XmlElement))
continue;
XmlElement xe = (XmlElement)xn;
if (xe.Name == "When") {
if (otherwise != null)
throw new InvalidProjectFileException ("The 'Otherwise' element must be last in a 'Choose' element.");
if (xe.Attributes.GetNamedItem ("Condition") == null)
throw new InvalidProjectFileException ("The 'When' element requires a 'Condition' attribute.");
BuildWhen bw = new BuildWhen (xe, project);
whens.Add (bw);
} else if (xe.Name == "Otherwise") {
if (this.whens.Count == 0)
throw new InvalidProjectFileException ("At least one 'When' element must occur in a 'Choose' element.");
otherwise = new BuildWhen (xe, project);
}
}
DefinedInFileName = importedProject != null ? importedProject.FullFileName :
project != null ? project.FullFileName : null;
}
public void Evaluate ()
{
}
//public bool IsImported {
// get { return isImported; }
// set { isImported = value; }
//}
public BuildWhen Otherwise {
get { return otherwise; }
set { otherwise = value; }
}
public List <BuildWhen> Whens {
get { return whens; }
set { whens = value; }
}
internal string DefinedInFileName { get; private set; }
}
}

View File

@@ -0,0 +1,160 @@
//
// BuildEngine.cs: Class that can be accessed by task.
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2005 Marek Sieradzki
//
// 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;
using Microsoft.Build.Framework;
namespace Microsoft.Build.BuildEngine {
internal class BuildEngine : IBuildEngine2 {
Engine engine;
int columnNumberOfTaskNode;
bool continueOnError;
int lineNumberOfTaskNode;
Project project;
string taskfile;
public BuildEngine (Engine engine, Project project, string taskfile, int column, int line,
bool continueOnError)
{
this.engine = engine;
this.project = project;
this.columnNumberOfTaskNode = column;
this.continueOnError = continueOnError;
this.lineNumberOfTaskNode = line;
this.taskfile = taskfile;
}
// Initiates a build of a project file. If the build is
// successful, the outputs (if any) of the specified targets
// are returned.
public bool BuildProjectFile (string projectFileName,
string[] targetNames,
IDictionary globalProperties,
IDictionary targetOutputs)
{
return BuildProjectFile (projectFileName, targetNames, globalProperties, targetOutputs, null);
}
public bool BuildProjectFile (string projectFileName,
string[] targetNames,
IDictionary globalProperties,
IDictionary targetOutputs, string toolsVersion)
{
if (String.IsNullOrEmpty (projectFileName)) {
string oldProjectToolsVersion = project.ToolsVersion;
project.ToolsVersion = toolsVersion;
try {
return engine.BuildProject (project, targetNames, targetOutputs,
BuildSettings.DoNotResetPreviouslyBuiltTargets);
} finally {
project.ToolsVersion = oldProjectToolsVersion;
}
} else {
BuildPropertyGroup bpg = new BuildPropertyGroup ();
if (globalProperties != null)
foreach (DictionaryEntry de in globalProperties)
bpg.AddProperty (new BuildProperty (
(string) de.Key, (string) de.Value,
PropertyType.Global));
return engine.BuildProjectFile (projectFileName,
targetNames, bpg, targetOutputs, BuildSettings.DoNotResetPreviouslyBuiltTargets, toolsVersion);
}
}
public bool BuildProjectFilesInParallel (string[] projectFileNames,
string [] targetNames,
IDictionary[] globalProperties,
IDictionary[] targetOutputsPerProject,
string[] toolsVersion,
bool useResultsCache,
bool unloadProjectsOnCompletion)
{
throw new NotImplementedException ();
}
// Raises a custom event to all registered loggers.
public void LogCustomEvent (CustomBuildEventArgs e)
{
engine.EventSource.FireCustomEventRaised (this, e);
}
// Raises an error to all registered loggers.
public void LogErrorEvent (BuildErrorEventArgs e)
{
if (ContinueOnError) {
// log the error as a warning
LogWarningEvent (new BuildWarningEventArgs (
e.Subcategory, e.Code, e.File, e.LineNumber, e.ColumnNumber,
e.EndLineNumber, e.EndColumnNumber, e.Message,
e.HelpKeyword, e.SenderName));
LogMessageEvent (new BuildMessageEventArgs (
"Previous error was converted to a warning as the " +
"task was called with ContinueOnError=true.",
null, null, MessageImportance.Normal));
} else {
engine.EventSource.FireErrorRaised (this, e);
}
}
// Raises a message event to all registered loggers.
public void LogMessageEvent (BuildMessageEventArgs e)
{
engine.EventSource.FireMessageRaised (this, e);
}
// Raises a warning to all registered loggers.
public void LogWarningEvent (BuildWarningEventArgs e)
{
engine.EventSource.FireWarningRaised (this, e);
}
public int ColumnNumberOfTaskNode {
get { return columnNumberOfTaskNode; }
}
public bool ContinueOnError {
get { return continueOnError; }
}
public int LineNumberOfTaskNode {
get { return lineNumberOfTaskNode; }
}
public string ProjectFileOfTaskNode {
get { return taskfile; }
}
public bool IsRunningMultipleNodes {
get { return false; }
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,358 @@
//
// BuildItemGroup.cs: Represents a group of build items.
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2005 Marek Sieradzki
//
// 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.Linq;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.Build.BuildEngine {
public class BuildItemGroup : IEnumerable {
List <BuildItem> buildItems;
ImportedProject importedProject;
XmlElement itemGroupElement;
GroupingCollection parentCollection;
Project parentProject;
bool read_only;
bool evaluated;
bool isDynamic;
public BuildItemGroup ()
: this (null, null, null, false)
{
}
internal BuildItemGroup (Project project)
: this (null, project, null, false)
{
}
internal BuildItemGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly)
: this (xmlElement, project, importedProject, readOnly, false)
{
}
internal BuildItemGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly, bool dynamic)
{
this.buildItems = new List <BuildItem> ();
this.importedProject = importedProject;
this.itemGroupElement = xmlElement;
this.parentProject = project;
this.read_only = readOnly;
this.isDynamic = dynamic;
if (!FromXml)
return;
foreach (XmlNode xn in xmlElement.ChildNodes) {
if (!(xn is XmlElement))
continue;
XmlElement xe = (XmlElement) xn;
BuildItem bi = CreateItem (project, xe);
buildItems.Add (bi);
project.LastItemGroupContaining [bi.Name] = this;
}
DefinedInFileName = importedProject != null ? importedProject.FullFileName :
project != null ? project.FullFileName : null;
}
internal virtual BuildItem CreateItem (Project project, XmlElement xe)
{
return new BuildItem (xe, this);
}
public BuildItem AddNewItem (string itemName,
string itemInclude)
{
return AddNewItem (itemName, itemInclude, false);
}
[MonoTODO]
public BuildItem AddNewItem (string itemName,
string itemInclude,
bool treatItemIncludeAsLiteral)
{
BuildItem item;
if (treatItemIncludeAsLiteral)
itemInclude = Utilities.Escape (itemInclude);
if (FromXml) {
XmlElement element = itemGroupElement.OwnerDocument.CreateElement (itemName, Project.XmlNamespace);
itemGroupElement.AppendChild (element);
element.SetAttribute ("Include", itemInclude);
item = new BuildItem (element, this);
} else {
item = new BuildItem (itemName, itemInclude);
item.ParentItemGroup = this;
}
item.Evaluate (null, true);
if (!read_only)
buildItems.Add (item);
if (parentProject != null) {
parentProject.MarkProjectAsDirty ();
parentProject.NeedToReevaluate ();
}
return item;
}
public void Clear ()
{
if (FromXml)
itemGroupElement.RemoveAll ();
buildItems = new List <BuildItem> ();
if (parentProject != null) {
parentProject.MarkProjectAsDirty ();
parentProject.NeedToReevaluate ();
}
}
[MonoTODO]
public BuildItemGroup Clone (bool deepClone)
{
if (deepClone) {
if (FromXml)
throw new NotImplementedException ();
else
throw new NotImplementedException ();
} else {
if (FromXml)
throw new InvalidOperationException ("A shallow clone of this object cannot be created.");
else
throw new NotImplementedException ();
}
}
public IEnumerator GetEnumerator ()
{
return buildItems.GetEnumerator ();
}
public void RemoveItem (BuildItem itemToRemove)
{
if (itemToRemove == null)
return;
itemToRemove.Detach ();
buildItems.Remove (itemToRemove);
}
public void RemoveItemAt (int index)
{
BuildItem item = buildItems [index];
RemoveItem (item);
}
internal BuildItem FindItem (ITaskItem taskItem)
{
return buildItems.FirstOrDefault (i => i.FinalItemSpec == taskItem.ItemSpec);
}
internal void RemoveItem (ITaskItem itemToRemove)
{
if (itemToRemove == null)
return;
var item = FindItem (itemToRemove);
if (item == null)
return;
item.Detach ();
buildItems.Remove (item);
}
public BuildItem[] ToArray ()
{
return buildItems.ToArray ();
}
internal void AddItem (BuildItem buildItem)
{
buildItems.Add (buildItem);
}
internal void AddItem (string name, ITaskItem taskItem)
{
BuildItem buildItem;
buildItem = new BuildItem (name, taskItem);
buildItem.ParentItemGroup = this;
buildItems.Add (buildItem);
}
// In eval phase, any ref'ed item would've already been expanded
// or it doesnt exist, so dont expand again
// In non-eval, items have _already_ been expanded, so dont expand again
// So, ignore @options
internal string ConvertToString (Expression transform,
Expression separator, ExpressionOptions options)
{
string separatorString;
// Item refs are not expanded for separator or transform
if (separator == null)
separatorString = ";";
else
separatorString = (string) separator.ConvertTo (parentProject, typeof (string),
ExpressionOptions.DoNotExpandItemRefs);
string[] items = new string [buildItems.Count];
int i = 0;
foreach (BuildItem bi in buildItems)
items [i++] = bi.ConvertToString (transform, ExpressionOptions.DoNotExpandItemRefs);
return String.Join (separatorString, items);
}
// In eval phase, any ref'ed item would've already been expanded
// or it doesnt exist, so dont expand again
// In non-eval, items have _already_ been expanded, so dont expand again
// So, ignore @options
internal ITaskItem[] ConvertToITaskItemArray (Expression transform, Expression separator, ExpressionOptions options)
{
if (separator != null)
// separator present, so return as a single "join'ed" string
return new ITaskItem [] {
new TaskItem (ConvertToString (transform, separator, options))
};
ITaskItem[] array = new ITaskItem [buildItems.Count];
int i = 0;
foreach (BuildItem item in buildItems)
array [i++] = item.ConvertToITaskItem (transform, ExpressionOptions.DoNotExpandItemRefs);
return array;
}
internal void Detach ()
{
if (!FromXml)
throw new InvalidOperationException ();
itemGroupElement.ParentNode.RemoveChild (itemGroupElement);
}
internal void Evaluate ()
{
if (!isDynamic && evaluated)
return;
foreach (BuildItem bi in buildItems) {
if (bi.Condition == String.Empty)
bi.Evaluate (parentProject, true);
else {
ConditionExpression ce = ConditionParser.ParseCondition (bi.Condition);
bi.Evaluate (parentProject, ce.BoolEvaluate (parentProject));
}
}
evaluated = true;
}
internal void ReplaceWith (BuildItem item, List <BuildItem> list)
{
int index = buildItems.IndexOf (item);
buildItems.RemoveAt (index);
buildItems.InsertRange (index, list);
}
public string Condition {
get {
if (FromXml)
return itemGroupElement.GetAttribute ("Condition");
else
return String.Empty;
}
set {
if (FromXml)
itemGroupElement.SetAttribute ("Condition", value);
else
throw new InvalidOperationException ("Cannot set a condition on an object not represented by an XML element in the project file.");
}
}
public int Count {
get { return buildItems.Count; }
}
public bool IsImported {
get { return importedProject != null; }
}
[MonoTODO]
public BuildItem this [int index] {
get {
return buildItems [index];
}
}
internal GroupingCollection GroupingCollection {
get { return parentCollection; }
set { parentCollection = value; }
}
internal Project ParentProject {
get { return parentProject; }
set {
if (parentProject != null)
throw new InvalidOperationException ("parentProject is already set");
parentProject = value;
}
}
internal string DefinedInFileName { get; private set; }
internal bool FromXml {
get {
return itemGroupElement != null;
}
}
internal XmlElement XmlElement {
get {
return itemGroupElement;
}
}
internal bool IsDynamic {
get {
return isDynamic;
}
}
}
}

View File

@@ -0,0 +1,95 @@
//
// BuildItemGroupCollection.cs:
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2005 Marek Sieradzki
//
// 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;
namespace Microsoft.Build.BuildEngine {
public class BuildItemGroupCollection : ICollection, IEnumerable {
GroupingCollection groupingCollection;
BuildItemGroupCollection ()
{
groupingCollection = new GroupingCollection (null);
}
internal BuildItemGroupCollection (GroupingCollection groupingCollection)
{
this.groupingCollection = groupingCollection;
}
public void CopyTo (Array array, int index)
{
if (array == null)
throw new ArgumentNullException ("array");
if (index < 0)
throw new IndexOutOfRangeException ("Index was outside the bounds of the array.");
if (array.Rank > 1)
throw new ArgumentException ("array is multidimensional");
if ((array.Length > 0) && (index >= array.Length))
throw new IndexOutOfRangeException ("Index was outside the bounds of the array.");
if (index + this.Count > array.Length)
throw new IndexOutOfRangeException ("Not enough room from index to end of array for this BuildItemGroupCollection");
IEnumerator it = GetEnumerator ();
int i = index;
while (it.MoveNext ()) {
array.SetValue(it.Current, i++);
}
}
public IEnumerator GetEnumerator ()
{
return groupingCollection.GetItemGroupEnumerator ();
}
internal void Add (BuildItemGroup buildItemGroup)
{
buildItemGroup.GroupingCollection = this.groupingCollection;
groupingCollection.Add (buildItemGroup);
}
public int Count {
get {
return groupingCollection.ItemGroups;
}
}
public bool IsSynchronized {
get {
return false;
}
}
public object SyncRoot {
get {
return this;
}
}
}
}

View File

@@ -0,0 +1,259 @@
//
// BuildProperty.cs: Represents a property
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
// Ankit Jain (jankit@novell.com)
//
// (C) 2005 Marek Sieradzki
// Copyright 2009 Novell, Inc (http://www.novell.com)
//
// 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.Text;
using System.Xml;
using System.Collections.Generic;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Mono.XBuild.Utilities;
namespace Microsoft.Build.BuildEngine {
public class BuildProperty {
XmlElement propertyElement;
string finalValue;
bool isImported;
string value;
string name;
Project parentProject;
PropertyType propertyType;
bool converting;
BuildProperty ()
{
}
public BuildProperty (string propertyName, string propertyValue)
: this (propertyName, propertyValue, PropertyType.Normal)
{
if (propertyName == null)
throw new ArgumentNullException ("propertyName");
if (propertyValue == null)
throw new ArgumentNullException ("propertyValue");
}
internal BuildProperty (string propertyName,
string propertyValue, PropertyType propertyType)
{
this.name = propertyName;
this.value = propertyValue;
this.finalValue = propertyValue;
this.propertyType = propertyType;
this.isImported = false;
}
internal BuildProperty (Project parentProject, XmlElement propertyElement)
{
if (propertyElement == null)
throw new ArgumentNullException ("propertyElement");
this.propertyElement = propertyElement;
this.propertyType = PropertyType.Normal;
this.parentProject = parentProject;
this.name = propertyElement.Name;
this.value = MSBuildUtils.UnescapeFromXml (propertyElement.InnerXml);
this.isImported = false;
}
[MonoTODO]
public BuildProperty Clone (bool deepClone)
{
if (deepClone) {
if (FromXml)
throw new NotImplementedException ();
else
return (BuildProperty) this.MemberwiseClone ();
} else {
if (FromXml)
throw new NotImplementedException ();
else
throw new InvalidOperationException ("A shallow clone of this object cannot be created.");
}
}
public static explicit operator string (BuildProperty propertyToCast)
{
if (propertyToCast == null)
return String.Empty;
else
return propertyToCast.ToString ();
}
public override string ToString ()
{
if (finalValue != null)
return finalValue;
else
return Value;
}
internal void Evaluate ()
{
BuildProperty evaluated = new BuildProperty (Name, Value);
// In evaluate phase, properties are not expanded
evaluated.finalValue = Expression.ParseAs<string> (Value, ParseOptions.None,
parentProject, ExpressionOptions.DoNotExpandItemRefs);
parentProject.EvaluatedProperties.AddProperty (evaluated);
}
// during property's eval phase, this is never reached, as PropertyReference
// handles the eval case
//
// during item's eval phase, we have expand: true, that's what we
// do here..
//
// during non-eval, expand: true
// So, its always true here
internal string ConvertToString (Project project, ExpressionOptions options)
{
if (converting) {
// found ref to @this while trying to ConvertToString
// for @this!
return FinalValue;
}
converting = true;
try {
Expression exp = new Expression ();
// in non-evaluation phase, properties are always expanded
exp.Parse (FinalValue, options == ExpressionOptions.ExpandItemRefs ?
ParseOptions.AllowItems : ParseOptions.None);
return (string) exp.ConvertTo (project, typeof (string), options);
} finally {
converting = false;
}
}
internal ITaskItem[] ConvertToITaskItemArray (Project project, ExpressionOptions options)
{
if (converting) {
// found ref to @this while trying to ConvertToITaskItemArray
// for @this!
ITaskItem []items = new ITaskItem [1];
items [0] = new TaskItem (FinalValue);
return items;
}
converting = true;
try {
Expression exp = new Expression ();
// in non-evaluation phase, properties are always expanded
exp.Parse (FinalValue, ParseOptions.Split | (options == ExpressionOptions.ExpandItemRefs ?
ParseOptions.AllowItems : ParseOptions.None));
return (ITaskItem[]) exp.ConvertTo (project, typeof (ITaskItem[]), options);
} finally {
converting = false;
}
}
internal bool FromXml {
get {
return propertyElement != null;
}
}
public string Condition {
get {
if (FromXml)
return propertyElement.GetAttribute ("Condition");
else
return String.Empty;
}
set {
if (FromXml)
propertyElement.SetAttribute ("Condition", value);
else
throw new InvalidOperationException ("Cannot set a condition on an object not represented by an XML element in the project file.");
}
}
public string FinalValue {
get {
if (finalValue == null)
return this.@value;
else
return finalValue;
}
}
public bool IsImported {
get { return isImported; }
}
public string Name {
get { return name; }
}
public string Value {
get {
return value;
}
set {
this.@value = value;
if (FromXml) {
propertyElement.InnerXml = value;
} else {
finalValue = value;
}
}
}
internal PropertyType PropertyType {
get {
return propertyType;
}
}
internal XmlElement XmlElement {
get { return propertyElement; }
}
internal IEnumerable<string> GetAttributes ()
{
if (!FromXml)
yield break;
foreach (XmlAttribute attr in propertyElement.Attributes)
yield return attr.Value;
}
}
internal enum PropertyType {
Reserved,
Global,
Normal,
Environment
}
}

View File

@@ -0,0 +1,321 @@
//
// BuildPropertyGroup.cs: Represents a group of properties
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2005 Marek Sieradzki
//
// 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;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Xml;
namespace Microsoft.Build.BuildEngine {
public class BuildPropertyGroup : IEnumerable {
bool read_only;
ImportedProject importedProject;
XmlElement propertyGroup;
GroupingCollection parentCollection;
Project parentProject;
List <BuildProperty> properties;
Dictionary <string, BuildProperty> propertiesByName;
bool evaluated;
bool isDynamic;
public BuildPropertyGroup ()
: this (null, null, null, false)
{
}
internal BuildPropertyGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly)
: this (xmlElement, project, importedProject, readOnly, false)
{
}
internal BuildPropertyGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly, bool isDynamic)
{
this.importedProject = importedProject;
this.parentCollection = null;
this.parentProject = project;
this.propertyGroup = xmlElement;
this.read_only = readOnly;
this.isDynamic = isDynamic;
if (FromXml) {
this.properties = new List <BuildProperty> ();
foreach (XmlNode xn in propertyGroup.ChildNodes) {
if (!(xn is XmlElement))
continue;
XmlElement xe = (XmlElement) xn;
BuildProperty bp = new BuildProperty (parentProject, xe);
AddProperty (bp);
}
} else
this.propertiesByName = new Dictionary <string, BuildProperty> (StringComparer.OrdinalIgnoreCase);
DefinedInFileName = importedProject != null ? importedProject.FullFileName :
(project != null ? project.FullFileName : null);
}
public BuildProperty AddNewProperty (string propertyName,
string propertyValue)
{
return AddNewProperty (propertyName, propertyValue, false);
}
public BuildProperty AddNewProperty (string propertyName,
string propertyValue,
bool treatPropertyValueAsLiteral)
{
if (!FromXml)
throw new InvalidOperationException ("This method is only valid for persisted property groups.");
if (treatPropertyValueAsLiteral)
propertyValue = Utilities.Escape (propertyValue);
XmlElement element = propertyGroup.OwnerDocument.CreateElement (propertyName, Project.XmlNamespace);
propertyGroup.AppendChild (element);
BuildProperty property = new BuildProperty (parentProject, element);
property.Value = propertyValue;
AddProperty (property);
parentProject.MarkProjectAsDirty ();
parentProject.NeedToReevaluate ();
return property;
}
internal void AddProperty (BuildProperty property)
{
if (FromXml)
properties.Add (property);
else {
if (propertiesByName.ContainsKey (property.Name)) {
BuildProperty existing = propertiesByName [property.Name];
if (property.PropertyType <= existing.PropertyType) {
propertiesByName.Remove (property.Name);
propertiesByName.Add (property.Name, property);
}
} else
propertiesByName.Add (property.Name, property);
}
}
public void Clear ()
{
if (FromXml) {
propertyGroup.RemoveAll ();
properties = new List <BuildProperty> ();
} else
propertiesByName = new Dictionary <string, BuildProperty> ();
}
[MonoTODO]
public BuildPropertyGroup Clone (bool deepClone)
{
BuildPropertyGroup bpg = new BuildPropertyGroup (propertyGroup, parentProject, importedProject, read_only);
if (FromXml) {
foreach (BuildProperty bp in properties) {
if (deepClone)
bpg.AddProperty (bp.Clone (true));
else
bpg.AddNewProperty (bp.Name, bp.FinalValue);
}
} else {
foreach (BuildProperty bp in propertiesByName.Values) {
if (deepClone)
bpg.AddProperty (bp.Clone (true));
else
bpg.AddNewProperty (bp.Name, bp.FinalValue);
}
}
return bpg;
}
public IEnumerator GetEnumerator ()
{
if (FromXml)
foreach (BuildProperty bp in properties)
yield return bp;
else
foreach (KeyValuePair <string, BuildProperty> kvp in propertiesByName)
yield return kvp.Value;
}
public void RemoveProperty (BuildProperty propertyToRemove)
{
if (propertyToRemove == null)
throw new ArgumentNullException ("propertyToRemove");
if (FromXml) {
if (!propertyToRemove.FromXml)
throw new InvalidOperationException ("The specified property does not belong to the current property group.");
propertyToRemove.XmlElement.ParentNode.RemoveChild (propertyToRemove.XmlElement);
properties.Remove (propertyToRemove);
} else
propertiesByName.Remove (propertyToRemove.Name);
}
public void RemoveProperty (string propertyName)
{
if (FromXml) {
foreach (BuildProperty bp in properties)
if (bp.Name == propertyName) {
RemoveProperty (bp);
break;
}
} else
propertiesByName.Remove (propertyName);
}
public void SetProperty (string propertyName,
string propertyValue)
{
SetProperty (propertyName, propertyValue, false);
}
public void SetProperty (string propertyName,
string propertyValue,
bool treatPropertyValueAsLiteral)
{
if (read_only)
return;
if (FromXml)
throw new InvalidOperationException (
"This method is only valid for virtual property groups, not <PropertyGroup> elements.");
if (treatPropertyValueAsLiteral)
propertyValue = Utilities.Escape (propertyValue);
if (propertiesByName.ContainsKey (propertyName))
propertiesByName.Remove (propertyName);
BuildProperty bp = new BuildProperty (propertyName, propertyValue);
if (Char.IsDigit (propertyName [0]))
throw new ArgumentException (String.Format (
"The name \"{0}\" contains an invalid character \"{1}\".", propertyName, propertyName [0]));
AddProperty (bp);
if (IsGlobal)
parentProject.NeedToReevaluate ();
}
internal void Evaluate ()
{
if (!isDynamic && evaluated)
return;
foreach (BuildProperty bp in properties)
if (ConditionParser.ParseAndEvaluate (bp.Condition, parentProject))
bp.Evaluate ();
evaluated = true;
}
public string Condition {
get {
if (!FromXml)
return String.Empty;
return propertyGroup.GetAttribute ("Condition");
}
set {
if (!FromXml)
throw new InvalidOperationException (
"Cannot set a condition on an object not represented by an XML element in the project file.");
propertyGroup.SetAttribute ("Condition", value);
}
}
public int Count {
get {
if (FromXml)
return properties.Count;
else
return propertiesByName.Count;
}
}
public bool IsImported {
get {
return importedProject != null;
}
}
internal bool FromXml {
get {
return propertyGroup != null;
}
}
bool IsGlobal {
get {
return parentProject != null && propertyGroup == null;
}
}
public BuildProperty this [string propertyName] {
get {
if (FromXml)
throw new InvalidOperationException ("Properties in persisted property groups cannot be accessed by name.");
if (propertiesByName.ContainsKey (propertyName))
return propertiesByName [propertyName];
else
return null;
}
set {
propertiesByName [propertyName] = value;
}
}
internal string DefinedInFileName { get; private set; }
internal GroupingCollection GroupingCollection {
get { return parentCollection; }
set { parentCollection = value; }
}
internal XmlElement XmlElement {
get { return propertyGroup; }
}
internal IEnumerable<string> GetAttributes ()
{
foreach (XmlAttribute attrib in XmlElement.Attributes)
yield return attrib.Value;
foreach (BuildProperty bp in properties) {
foreach (string attr in bp.GetAttributes ())
yield return attr;
}
}
}
}

View File

@@ -0,0 +1,95 @@
//
// BuildPropertyGroupCollection.cs: Collection for group of properties
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2005 Marek Sieradzki
//
// 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;
namespace Microsoft.Build.BuildEngine {
public class BuildPropertyGroupCollection : ICollection, IEnumerable {
GroupingCollection groupingCollection;
BuildPropertyGroupCollection ()
{
groupingCollection = new GroupingCollection (null);
}
internal BuildPropertyGroupCollection (GroupingCollection groupingCollection)
{
this.groupingCollection = groupingCollection;
}
public void CopyTo (Array array, int index)
{
if (array == null)
throw new ArgumentNullException ("array");
if (index < 0)
throw new IndexOutOfRangeException ("Index was outside the bounds of the array.");
if (array.Rank > 1)
throw new ArgumentException ("array is multidimensional");
if ((array.Length > 0) && (index >= array.Length))
throw new IndexOutOfRangeException ("Index was outside the bounds of the array.");
if (index + this.Count > array.Length)
throw new IndexOutOfRangeException ("Index was outside the bounds of the array.");
IEnumerator it = GetEnumerator ();
int i = index;
while (it.MoveNext ()) {
array.SetValue (it.Current, i++);
}
}
public IEnumerator GetEnumerator ()
{
return groupingCollection.GetPropertyGroupEnumerator ();
}
internal void Add (BuildPropertyGroup bpg)
{
bpg.GroupingCollection = groupingCollection;
groupingCollection.Add (bpg);
}
public int Count {
get {
return groupingCollection.PropertyGroups;
}
}
public bool IsSynchronized {
get {
return false;
}
}
public object SyncRoot {
get {
return this;
}
}
}
}

View File

@@ -0,0 +1,36 @@
//
// BuildSettings.cs: Enum for build settings
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2005 Marek Sieradzki
//
// 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;
namespace Microsoft.Build.BuildEngine {
[Flags]
public enum BuildSettings {
None,
DoNotResetPreviouslyBuiltTargets
}
}

View File

@@ -0,0 +1,294 @@
//
// BuildTask.cs: Represents a Task element in a project.
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// 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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Reflection;
using System.Xml;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.Build.BuildEngine {
public class BuildTask : IBuildTask {
ITaskHost hostObject;
Target parentTarget;
XmlElement taskElement;
TaskLoggingHelper task_logger;
internal BuildTask (XmlElement taskElement, Target parentTarget)
{
if (taskElement == null)
throw new ArgumentNullException ("taskElement");
if (parentTarget == null)
throw new ArgumentNullException ("parentTarget");
this.taskElement = taskElement;
this.parentTarget = parentTarget;
}
[MonoTODO]
public void AddOutputItem (string taskParameter,
string itemName)
{
XmlElement element = parentTarget.Project.XmlDocument.CreateElement ("Output", Project.XmlNamespace);
taskElement.AppendChild (element);
if (taskParameter != null)
element.SetAttribute ("TaskParameter", taskParameter);
if (itemName != null)
element.SetAttribute ("ItemName", itemName);
}
[MonoTODO]
public void AddOutputProperty (string taskParameter,
string propertyName)
{
XmlElement element = parentTarget.Project.XmlDocument.CreateElement ("Output", Project.XmlNamespace);
taskElement.AppendChild (element);
if (taskParameter != null)
element.SetAttribute ("TaskParameter", taskParameter);
if (propertyName != null)
element.SetAttribute ("PropertyName", propertyName);
}
[MonoTODO]
public bool Execute ()
{
bool result = false;
TaskEngine taskEngine;
LogTaskStarted ();
ITask task = null;
try {
try {
task = InitializeTask ();
} catch (Exception e) {
LogError ("Error initializing task {0}: {1}", taskElement.LocalName, e.Message);
LogMessage (MessageImportance.Low, "Error initializing task {0}: {1}",
taskElement.LocalName, e.ToString ());
return false;
}
try {
taskEngine = new TaskEngine (parentTarget.Project);
taskEngine.Prepare (task, this.taskElement, GetParameters (), this.Type);
result = taskEngine.Execute ();
if (result)
taskEngine.PublishOutput ();
} catch (Exception e) {
task_logger.LogError ("Error executing task {0}: {1}", taskElement.LocalName, e.Message);
task_logger.LogMessage (MessageImportance.Low,
"Error executing task {0}: {1}", taskElement.LocalName, e.ToString ());
result = false;
}
} finally {
LogTaskFinished (result);
}
return result;
}
public string[] GetParameterNames ()
{
List <string> tempNames = new List <string> ();
foreach (XmlAttribute xmlAttribute in taskElement.Attributes) {
if (xmlAttribute.Name == "Condition" || xmlAttribute.Name == "ContinueOnError")
continue;
tempNames.Add (xmlAttribute.Name);
}
return tempNames.ToArray ();
}
public string GetParameterValue (string attributeName)
{
if (attributeName == "Condition")
throw new ArgumentException ("Condition attribute cannot be accessed using this method.");
if (attributeName == "ContinueOnError")
throw new ArgumentException ("ContinueOnError attribute cannot be accessed using this method.");
return taskElement.GetAttribute (attributeName);
}
public void SetParameterValue (string parameterName,
string parameterValue)
{
SetParameterValue (parameterName, parameterValue, false);
}
public void SetParameterValue (string parameterName,
string parameterValue,
bool treatParameterValueAsLiteral)
{
if (treatParameterValueAsLiteral)
taskElement.SetAttribute (parameterName, Utilities.Escape (parameterValue));
else
taskElement.SetAttribute (parameterName, parameterValue);
}
void LogTaskStarted ()
{
TaskStartedEventArgs tsea = new TaskStartedEventArgs ("Task started.", null,
parentTarget.Project.FullFileName,
parentTarget.TargetFile, taskElement.Name);
parentTarget.Project.ParentEngine.EventSource.FireTaskStarted (this, tsea);
}
void LogTaskFinished (bool succeeded)
{
TaskFinishedEventArgs tfea = new TaskFinishedEventArgs ("Task finished.", null,
parentTarget.Project.FullFileName,
parentTarget.TargetFile, taskElement.Name, succeeded);
parentTarget.Project.ParentEngine.EventSource.FireTaskFinished (this, tfea);
}
void LogError (string message,
params object[] messageArgs)
{
parentTarget.Project.ParentEngine.LogError (message, messageArgs);
}
void LogMessage (MessageImportance importance,
string message,
params object[] messageArgs)
{
parentTarget.Project.ParentEngine.LogMessage (importance, message, messageArgs);
}
ITask InitializeTask ()
{
ITask task;
try {
task = (ITask)Activator.CreateInstance (this.Type);
} catch (InvalidCastException) {
LogMessage (MessageImportance.Low, "InvalidCastException, ITask: {0} Task type: {1}",
typeof (ITask).AssemblyQualifiedName, this.Type.AssemblyQualifiedName);
throw;
}
parentTarget.Project.ParentEngine.LogMessage (
MessageImportance.Low,
"Using task {0} from {1}", Name, this.Type.AssemblyQualifiedName);
task.BuildEngine = new BuildEngine (parentTarget.Project.ParentEngine, parentTarget.Project,
parentTarget.TargetFile, 0, 0, ContinueOnError);
task_logger = new TaskLoggingHelper (task);
return task;
}
IDictionary <string, string> GetParameters ()
{
Dictionary <string, string> parameters = new Dictionary <string, string> ();
string[] parameterNames = GetParameterNames ();
foreach (string s in parameterNames)
parameters.Add (s, GetParameterValue (s));
return parameters;
}
public string Condition {
get {
return taskElement.GetAttribute ("Condition");
}
set {
taskElement.SetAttribute ("Condition", value);
}
}
[MonoTODO]
public bool ContinueOnError {
get {
string str = taskElement.GetAttribute ("ContinueOnError");
if (str == String.Empty)
return false;
else {
Expression exp = new Expression ();
exp.Parse (str, ParseOptions.AllowItemsNoMetadataAndSplit);
return (bool) exp.ConvertTo (parentTarget.Project, typeof (bool),
ExpressionOptions.ExpandItemRefs);
}
}
set {
taskElement.SetAttribute ("ContinueOnError", value.ToString ());
}
}
[MonoTODO]
public ITaskHost HostObject {
get { return hostObject; }
set { hostObject = value; }
}
public string Name {
get { return taskElement.Name; }
}
internal Target ParentTarget {
get { return parentTarget; }
set { parentTarget = value; }
}
internal XmlElement TaskElement {
get { return taskElement; }
set { taskElement = value; }
}
[MonoTODO]
public Type Type {
get { return parentTarget.Project.TaskDatabase.GetTypeFromClassName (Name); }
}
public IEnumerable<string> GetAttributes ()
{
foreach (XmlAttribute attrib in TaskElement.Attributes)
yield return attrib.Value;
foreach (XmlNode xn in TaskElement.ChildNodes) {
XmlElement xe = xn as XmlElement;
if (xe == null)
continue;
//FIXME: error on any other child
if (String.Compare (xe.LocalName, "Output", StringComparison.Ordinal) == 0) {
foreach (XmlAttribute attrib in xe.Attributes)
yield return attrib.Value;
}
}
}
}
}

View File

@@ -0,0 +1,78 @@
//
// BuildTaskItem.cs
//
// Author:
// Martin Baulig <martin.baulig@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com)
//
// 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.BuildEngine
{
internal class BuildTaskItem : BuildItem, IBuildTask
{
BuildTaskItemGroup parent;
Project project;
public bool ContinueOnError {
get; set;
}
internal BuildTaskItem (Project project, XmlElement itemElement, BuildTaskItemGroup parentItemGroup)
: base (itemElement, parentItemGroup)
{
this.parent = parentItemGroup;
this.project = project;
}
bool CheckCondition (string condition)
{
if (string.IsNullOrEmpty (condition))
return true;
var ce = ConditionParser.ParseCondition (condition);
return ce.BoolEvaluate (project);
}
bool CheckCondition ()
{
return CheckCondition (parent.Condition) && CheckCondition (Condition);
}
public bool Execute ()
{
var condition = CheckCondition ();
Evaluate (project, condition);
return true;
}
public IEnumerable<string> GetAttributes ()
{
foreach (XmlAttribute attrib in parent.XmlElement.Attributes)
yield return attrib.Value;
foreach (XmlAttribute attrib in XmlElement.Attributes)
yield return attrib.Value;
}
}
}

View File

@@ -0,0 +1,54 @@
//
// BuildTaskItemGroup.cs
//
// Author:
// Martin Baulig <martin.baulig@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com)
//
// 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.BuildEngine {
internal class BuildTaskItemGroup : BuildItemGroup {
List<IBuildTask> items = new List<IBuildTask> ();
internal BuildTaskItemGroup (XmlElement element, Target target)
: base (element, target.Project, null, false, true)
{
}
internal override BuildItem CreateItem (Project project, XmlElement xe)
{
var item = new BuildTaskItem (project, xe, this);
items.Add (item);
return item;
}
public List<IBuildTask> Items {
get { return items; }
}
}
}

View File

@@ -0,0 +1,58 @@
//
// BuildTaskPropertyGroup.cs
//
// Author:
// Martin Baulig <martin.baulig@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com)
//
// 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.BuildEngine {
internal class BuildTaskPropertyGroup : BuildPropertyGroup, IBuildTask {
public bool ContinueOnError {
get; set;
}
internal BuildTaskPropertyGroup (XmlElement element, Target target)
: base (element, target.Project, null, false, true)
{
}
public bool Execute ()
{
Evaluate ();
return true;
}
IEnumerable<string> IBuildTask.GetAttributes ()
{
return GetAttributes ();
}
}
}

View File

@@ -0,0 +1,82 @@
//
// BuildWhen.cs: Represents <When>.
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2005 Marek Sieradzki
//
// 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;
using System.Xml;
namespace Microsoft.Build.BuildEngine {
internal class BuildWhen {
//Project parentProject;
GroupingCollection groupingCollection;
XmlElement whenElement;
public BuildWhen (XmlElement whenElement, Project parentProject)
{
//this.parentProject = parentProject;
this.groupingCollection = new GroupingCollection (parentProject);
if (whenElement == null)
throw new ArgumentNullException ("whenElement");
this.whenElement = whenElement;
foreach (XmlElement xe in whenElement.ChildNodes) {
switch (xe.Name) {
case "ItemGroup":
BuildItemGroup big = new BuildItemGroup (xe, parentProject, null, true);
//big.BindToXml (xe);
groupingCollection.Add (big);
break;
case "PropertyGroup":
BuildPropertyGroup bpg = new BuildPropertyGroup (xe, parentProject, null, true);
//bpg.BindToXml (xe);
groupingCollection.Add (bpg);
break;
case "Choose":
BuildChoose bc = new BuildChoose (xe, parentProject);
groupingCollection.Add (bc);
break;
default:
throw new InvalidProjectFileException ( string.Format ("Invalid element '{0}' in When.", xe.Name));
}
}
}
public void Evaluate()
{
groupingCollection.Evaluate ();
}
public string Condition {
get { return whenElement.GetAttribute ("Condition"); }
set { whenElement.SetAttribute ("Condition", value); }
}
public GroupingCollection GroupingCollection {
get { return groupingCollection; }
set { groupingCollection = value; }
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,147 @@
//
// ChangeType.cs: Changes types for output properties or items.
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2005 Marek Sieradzki
//
// 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;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.Build.BuildEngine {
internal class ChangeType {
//removed Type type
// FIXME throw exception here
static string ToString (object o)
{
string output = null;
Type type = o.GetType ();
// FIXME: there are more types
if (type == typeof (string))
output = (string) o;
else if (type == typeof (bool) ||
type == typeof (int) ||
type == typeof (uint) ||
type == typeof (float) ||
type == typeof (double) ||
type == typeof (DateTime) ||
type.IsEnum)
output = o.ToString ();
else
throw new Exception (String.Format ("Unsupported type : {0}", type));
return output;
}
static string ToString (object [] o, Type type)
{
/*
ArrayList al = new ArrayList ();
foreach (object obj in o ) {
if (type == typeof (bool[])) {
al.Add (TemporaryTransform (obj, typeof (bool)));
} else if (type == typeof (string[])) {
al.Add (TemporaryTransform (obj, typeof (string)));
} else if (type == typeof (DateTime[])) {
al.Add (TemporaryTransform (obj, typeof (DateTime)));
} else if (type == typeof (int[])) {
al.Add (TemporaryTransform (obj, typeof (int)));
} else if (type == typeof (uint[])) {
al.Add (TemporaryTransform (obj, typeof (uint)));
} else
throw new Exception (String.Format ("Invalid type: {0}", type.ToString ()));
}
string[] output = new string [al.Count];
int i = 0;
foreach (string s in al)
output [i++] = s;
return String.Join (";", output);
*/
List <string> list = new List <string> ();
foreach (object obj in o)
list.Add (ToString (obj));
return String.Join (";", list.ToArray ());
}
public static BuildProperty ToBuildProperty (object o, Type t, string name)
{
if (t == typeof (ITaskItem)) {
return new BuildProperty (name, ((ITaskItem) o).ItemSpec);
} else if (t == typeof (ITaskItem [])) {
// FIXME move Tostring here
return new BuildProperty (name, ToString ((ITaskItem []) o));
} else if (t.IsArray) {
return new BuildProperty (name, ToString ((object []) o, t));
} else {
return new BuildProperty (name, ToString (o));
}
}
public static BuildItemGroup ToBuildItemGroup (object o, Type t, string name)
{
BuildItemGroup big = new BuildItemGroup ();
if (t == typeof (ITaskItem)) {
big.AddItem (name, (ITaskItem) o);
} else if (t == typeof (ITaskItem [])) {
foreach (ITaskItem i in (ITaskItem []) o)
big.AddItem (name, i);
} else if (t.IsArray) {
return ToBuildItemGroup (name, ToString ((object []) o, t), true);
} else {
return ToBuildItemGroup (name, ToString (o), false);
}
return big;
}
static BuildItemGroup ToBuildItemGroup (string name, string items, bool split)
{
BuildItemGroup big = new BuildItemGroup ();
if (split) {
string [] splitItems = items.Split (';');
foreach (string item in splitItems)
big.AddItem (name, new TaskItem (item));
} else {
big.AddItem (name, new TaskItem (items));
}
return big;
}
static string ToString (ITaskItem [] items)
{
string [] text = new string [items.Length];
int i = 0;
foreach (ITaskItem item in items)
text [i++] = item.ItemSpec;
return String.Join (";", text);
}
}
}

View File

@@ -0,0 +1,38 @@
//
// ColorResetter.cs: Defines the type of delegate used to reset the console
// color.
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// 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;
#if MICROSOFT_BUILD_DLL
namespace Microsoft.Build.Logging
#else
namespace Microsoft.Build.BuildEngine
#endif
{
public delegate void ColorResetter ();
}

View File

@@ -0,0 +1,37 @@
//
// ColorSetter.cs: Defines the type of delegate used to set the console color.
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// 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;
#if MICROSOFT_BUILD_DLL
namespace Microsoft.Build.Logging
#else
namespace Microsoft.Build.BuildEngine
#endif
{
public delegate void ColorSetter (ConsoleColor color);
}

View File

@@ -0,0 +1,88 @@
//
// ConditionAndExpression.cs
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// 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.BuildEngine {
internal sealed class ConditionAndExpression : ConditionExpression {
readonly ConditionExpression left;
readonly ConditionExpression right;
public ConditionAndExpression (ConditionExpression left, ConditionExpression right)
{
this.left = left;
this.right = right;
}
public ConditionExpression Left {
get { return left; }
}
public ConditionExpression Right {
get { return right; }
}
public override bool BoolEvaluate (Project context)
{
if (!left.BoolEvaluate (context))
return false;
if (!right.BoolEvaluate (context))
return false;
return true;
}
public override float NumberEvaluate (Project context)
{
throw new NotSupportedException ();
}
public override string StringEvaluate (Project context)
{
throw new NotSupportedException ();
}
public override bool CanEvaluateToBool (Project context)
{
// Short-circuiting, check only left expr, right
// would be required only if left == true
return left.CanEvaluateToBool (context);
}
public override bool CanEvaluateToNumber (Project context)
{
return false;
}
public override bool CanEvaluateToString (Project context)
{
return false;
}
}
}

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