/Microsoft.Build/Microsoft.Build/Microsoft/Build/Evaluation/Expander!2.cs
C# | 3960 lines | 3951 code | 9 blank | 0 comment | 31 complexity | 76d716ef0e206723446b06fb2f45bbf0 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0
- namespace Microsoft.Build.Evaluation
- {
- using Microsoft.Build;
- using Microsoft.Build.Collections;
- using Microsoft.Build.Execution;
- using Microsoft.Build.Internal;
- using Microsoft.Build.Shared;
- using Microsoft.Win32;
- using System;
- using System.Collections;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Globalization;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Runtime;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading;
-
- internal class Expander<P, I> where P: class, IProperty where I: class, IItem
- {
- private static readonly bool defaultWarnForUninitializedProperties;
- private static char[] expandableChars;
- private static CompareInfo invariantCompareInfo;
- private IItemProvider<I> items;
- private IMetadataTable metadata;
- private IPropertyProvider<P> properties;
- private Microsoft.Build.Evaluation.UsedUninitializedProperties usedUninitializedProperties;
-
- static Expander()
- {
- Expander<P, I>.defaultWarnForUninitializedProperties = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MSBUILDWARNONUNINITIALIZEDPROPERTY"));
- Expander<P, I>.expandableChars = new char[] { '$', '%', '@' };
- Expander<P, I>.invariantCompareInfo = CultureInfo.InvariantCulture.CompareInfo;
- }
-
- internal Expander(IPropertyProvider<P> properties)
- {
- this.properties = properties;
- this.usedUninitializedProperties = new Microsoft.Build.Evaluation.UsedUninitializedProperties();
- }
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- internal Expander(IPropertyProvider<P> properties, IItemProvider<I> items) : this(properties)
- {
- this.items = items;
- }
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- internal Expander(IPropertyProvider<P> properties, IItemProvider<I> items, IMetadataTable metadata) : this(properties, items)
- {
- this.metadata = metadata;
- }
-
- private static void AddArgument(List<string> arguments, StringBuilder argumentBuilder)
- {
- ErrorUtilities.VerifyThrowArgumentNull(argumentBuilder, "argumentBuilder");
- string strB = OpportunisticIntern.StringBuilderToString(argumentBuilder).Trim();
- if (string.Compare("null", strB, StringComparison.OrdinalIgnoreCase) == 0)
- {
- arguments.Add(null);
- }
- else if (strB.Length > 0)
- {
- if ((strB[0] == '\'') && (strB[strB.Length - 1] == '\''))
- {
- arguments.Add(strB.Trim(new char[] { '\'' }));
- }
- else if ((strB[0] == '`') && (strB[strB.Length - 1] == '`'))
- {
- arguments.Add(strB.Trim(new char[] { '`' }));
- }
- else if ((strB[0] == '"') && (strB[strB.Length - 1] == '"'))
- {
- arguments.Add(strB.Trim(new char[] { '"' }));
- }
- else
- {
- arguments.Add(strB);
- }
- }
- else
- {
- arguments.Add(strB);
- }
- }
-
- internal IList<T> ExpandIntoItemsLeaveEscaped<T>(string expression, IItemFactory<I, T> itemFactory, ExpanderOptions options, IElementLocation elementLocation) where T: class, IItem
- {
- if (expression.Length == 0)
- {
- return ReadOnlyEmptyList<T>.Instance;
- }
- ErrorUtilities.VerifyThrowInternalNull(elementLocation, "elementLocation");
- expression = MetadataExpander<P, I>.ExpandMetadataLeaveEscaped(expression, this.metadata, options);
- expression = PropertyExpander<P, I, P>.ExpandPropertiesLeaveEscaped(expression, this.properties, options, elementLocation, this.usedUninitializedProperties);
- List<T> list = new List<T>();
- if (expression.Length != 0)
- {
- foreach (string str in ExpressionShredder.SplitSemiColonSeparatedList(expression))
- {
- bool flag;
- IList<T> collection = ItemExpander<P, I>.ExpandSingleItemVectorExpressionIntoItems<I, T>((Expander<P, I>) this, str, this.items, itemFactory, options, false, out flag, elementLocation);
- if (((collection == null) || (collection.Count > 0)) && ((options & ExpanderOptions.BreakOnNotEmpty) != ExpanderOptions.Invalid))
- {
- return null;
- }
- if (collection != null)
- {
- list.AddRange(collection);
- }
- else
- {
- T item = itemFactory.CreateItem(str);
- list.Add(item);
- }
- }
- }
- return list;
- }
-
- internal string ExpandIntoStringAndUnescape(string expression, ExpanderOptions options, IElementLocation elementLocation)
- {
- string escapedString = this.ExpandIntoStringLeaveEscaped(expression, options, elementLocation);
- return ((escapedString == null) ? null : EscapingUtilities.UnescapeAll(escapedString));
- }
-
- internal string ExpandIntoStringLeaveEscaped(string expression, ExpanderOptions options, IElementLocation elementLocation)
- {
- if (expression.Length == 0)
- {
- return string.Empty;
- }
- ErrorUtilities.VerifyThrowInternalNull(elementLocation, "elementLocation");
- string str = PropertyExpander<P, I, P>.ExpandPropertiesLeaveEscaped(MetadataExpander<P, I>.ExpandMetadataLeaveEscaped(expression, this.metadata, options), this.properties, options, elementLocation, this.usedUninitializedProperties);
- return ItemExpander<P, I>.ExpandItemVectorsIntoString<I>((Expander<P, I>) this, str, this.items, options, elementLocation);
- }
-
- internal IList<string> ExpandIntoStringListLeaveEscaped(string expression, ExpanderOptions options, IElementLocation elementLocation)
- {
- ErrorUtilities.VerifyThrow((options & ExpanderOptions.BreakOnNotEmpty) == ExpanderOptions.Invalid, "not supported");
- return ExpressionShredder.SplitSemiColonSeparatedList(this.ExpandIntoStringLeaveEscaped(expression, options, elementLocation));
- }
-
- internal IList<ProjectItemInstance.TaskItem> ExpandIntoTaskItemsLeaveEscaped(string expression, ExpanderOptions options, IElementLocation elementLocation)
- {
- return this.ExpandIntoItemsLeaveEscaped<ProjectItemInstance.TaskItem>(expression, (IItemFactory<I, ProjectItemInstance.TaskItem>) ProjectItemInstance.TaskItem.TaskItemFactory.Instance, options, elementLocation);
- }
-
- internal object ExpandPropertiesLeaveTypedAndEscaped(string expression, ExpanderOptions options, IElementLocation elementLocation)
- {
- if (expression.Length == 0)
- {
- return string.Empty;
- }
- ErrorUtilities.VerifyThrowInternalNull(elementLocation, "elementLocation");
- return PropertyExpander<P, I, P>.ExpandPropertiesLeaveTypedAndEscaped(MetadataExpander<P, I>.ExpandMetadataLeaveEscaped(expression, this.metadata, options), this.properties, options, elementLocation, this.usedUninitializedProperties);
- }
-
- internal IList<T> ExpandSingleItemVectorExpressionIntoItems<T>(string expression, IItemFactory<I, T> itemFactory, ExpanderOptions options, bool includeNullItems, out bool isTransformExpression, IElementLocation elementLocation) where T: class, IItem
- {
- if (expression.Length == 0)
- {
- isTransformExpression = false;
- return ReadOnlyEmptyList<T>.Instance;
- }
- ErrorUtilities.VerifyThrowInternalNull(elementLocation, "elementLocation");
- return ItemExpander<P, I>.ExpandSingleItemVectorExpressionIntoItems<I, T>((Expander<P, I>) this, expression, this.items, itemFactory, options, includeNullItems, out isTransformExpression, elementLocation);
- }
-
- internal static bool ExpressionContainsItemVector(string expression)
- {
- return (ExpressionShredder.GetReferencedItemExpressions(expression) != null);
- }
-
- internal static bool ExpressionMayContainExpandableExpressions(string expression)
- {
- return (expression.IndexOfAny(Expander<P, I>.expandableChars) > -1);
- }
-
- private static unsafe string[] ExtractFunctionArguments(IElementLocation elementLocation, string expressionFunction, string argumentsString)
- {
- int length = argumentsString.Length;
- List<string> arguments = new List<string>();
- StringBuilder argumentBuilder = new StringBuilder(length);
- fixed (char* str = ((char*) argumentsString))
- {
- char* chPtr = str;
- for (int i = 0; i < length; i++)
- {
- if (((i < (length - 1)) && (chPtr[i] == '$')) && (chPtr[i + 1] == '('))
- {
- int startIndex = i;
- i += 2;
- i = Expander<P, I>.ScanForClosingParenthesis(argumentsString, i);
- if (i == -1)
- {
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionPropertyExpression", expressionFunction, AssemblyResources.GetString("InvalidFunctionPropertyExpressionDetailMismatchedParenthesis"));
- }
- argumentBuilder.Append(argumentsString.Substring(startIndex, (i - startIndex) + 1));
- }
- else if (((chPtr[i] == '`') || (chPtr[i] == '"')) || (chPtr[i] == '\''))
- {
- int num4 = i;
- i++;
- i = Expander<P, I>.ScanForClosingQuote(argumentsString[num4], argumentsString, i);
- if (i == -1)
- {
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionPropertyExpression", expressionFunction, AssemblyResources.GetString("InvalidFunctionPropertyExpressionDetailMismatchedQuote"));
- }
- argumentBuilder.Append(argumentsString.Substring(num4, (i - num4) + 1));
- }
- else if (chPtr[i] == ',')
- {
- Expander<P, I>.AddArgument(arguments, argumentBuilder);
- argumentBuilder.Remove(0, argumentBuilder.Length);
- }
- else
- {
- argumentBuilder.Append(chPtr[i]);
- }
- }
- }
- Expander<P, I>.AddArgument(arguments, argumentBuilder);
- return arguments.ToArray();
- }
-
- private static bool IsValidPropertyName(string propertyName)
- {
- if ((propertyName.Length == 0) || !XmlUtilities.IsValidInitialElementNameCharacter(propertyName[0]))
- {
- return false;
- }
- for (int i = 1; i < propertyName.Length; i++)
- {
- if (!XmlUtilities.IsValidSubsequentElementNameCharacter(propertyName[i]))
- {
- return false;
- }
- }
- return true;
- }
-
- private static int ScanForClosingParenthesis(string expression, int index)
- {
- bool potentialPropertyFunction = false;
- bool potentialRegistryFunction = false;
- return Expander<P, I>.ScanForClosingParenthesis(expression, index, out potentialPropertyFunction, out potentialRegistryFunction);
- }
-
- private static unsafe int ScanForClosingParenthesis(string expression, int index, out bool potentialPropertyFunction, out bool potentialRegistryFunction)
- {
- int num = 1;
- int length = expression.Length;
- potentialPropertyFunction = false;
- potentialRegistryFunction = false;
- fixed (char* str = ((char*) expression))
- {
- char* chPtr = str;
- while ((index < length) && (num > 0))
- {
- char quoteChar = chPtr[index];
- switch (quoteChar)
- {
- case '\'':
- case '`':
- case '"':
- index++;
- index = Expander<P, I>.ScanForClosingQuote(quoteChar, expression, index);
- if (index < 0)
- {
- return -1;
- }
- break;
-
- case '(':
- num++;
- break;
-
- case ')':
- num--;
- break;
-
- case '.':
- case '[':
- case '$':
- potentialPropertyFunction = true;
- break;
-
- default:
- if (quoteChar == ':')
- {
- potentialRegistryFunction = true;
- }
- break;
- }
- index++;
- }
- }
- index--;
- if (num != 0)
- {
- return -1;
- }
- return index;
- }
-
- private static unsafe int ScanForClosingQuote(char quoteChar, string expression, int index)
- {
- fixed (char* str = ((char*) expression))
- {
- char* chPtr = str;
- while (index < expression.Length)
- {
- if (chPtr[index] == quoteChar)
- {
- return index;
- }
- index++;
- }
- }
- return -1;
- }
-
- internal IMetadataTable Metadata
- {
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.metadata;
- }
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- set
- {
- this.metadata = value;
- }
- }
-
- internal Microsoft.Build.Evaluation.UsedUninitializedProperties UsedUninitializedProperties
- {
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.usedUninitializedProperties;
- }
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- set
- {
- this.usedUninitializedProperties = value;
- }
- }
-
- internal bool WarnForUninitializedProperties
- {
- get
- {
- return this.usedUninitializedProperties.Warn;
- }
- set
- {
- this.usedUninitializedProperties.Warn = value;
- }
- }
-
- private class Function<T> where T: class, IProperty
- {
- private string[] arguments;
- private BindingFlags bindingFlags;
- private string expression;
- private string expressionRootName;
- private string name;
- private Type objectType;
- private string remainder;
- private UsedUninitializedProperties usedUninitializedProperties;
-
- internal Function(Type objectType, string expression, string expressionRootName, string name, string[] arguments, BindingFlags bindingFlags, string remainder, UsedUninitializedProperties usedUninitializedProperties)
- {
- this.name = name;
- if (arguments == null)
- {
- this.arguments = new string[0];
- }
- else
- {
- this.arguments = arguments;
- }
- this.expressionRootName = expressionRootName;
- this.expression = expression;
- this.objectType = objectType;
- this.bindingFlags = bindingFlags;
- this.remainder = remainder;
- this.usedUninitializedProperties = usedUninitializedProperties;
- }
-
- private static object[] CoerceArguments(object[] args, ParameterInfo[] parameters)
- {
- object[] objArray = new object[args.Length];
- try
- {
- for (int i = 0; i < parameters.Length; i++)
- {
- if (args[i] != null)
- {
- if (parameters[i].ParameterType == typeof(char[]))
- {
- objArray[i] = args[i].ToString().ToCharArray();
- }
- else if ((parameters[i].ParameterType.IsEnum && (args[i] is string)) && ((string) args[i]).Contains("."))
- {
- Type parameterType = parameters[i].ParameterType;
- string oldValue = parameterType.Name + ".";
- string str2 = parameterType.FullName + ".";
- string str3 = args[i].ToString().Replace('|', ',').Replace(str2, "").Replace(oldValue, "");
- objArray[i] = Enum.Parse(parameterType, str3);
- }
- else
- {
- objArray[i] = Convert.ChangeType(args[i], parameters[i].ParameterType, CultureInfo.InvariantCulture);
- }
- }
- }
- }
- catch (InvalidCastException)
- {
- return null;
- }
- return objArray;
- }
-
- private static Expander<P, I>.Function<T> ConstructFunction(IElementLocation elementLocation, string expressionFunction, string expressionRootName, Type objectType, int argumentStartIndex, int methodStartIndex, UsedUninitializedProperties usedUninitializedProperties)
- {
- string[] strArray;
- string str;
- string str2 = string.Empty;
- BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.IgnoreCase;
- if ((argumentStartIndex > -1) && !expressionFunction.Substring(methodStartIndex, argumentStartIndex - methodStartIndex).Contains("."))
- {
- string str3;
- str = expressionFunction.Substring(methodStartIndex, argumentStartIndex - methodStartIndex).Trim();
- argumentStartIndex++;
- int num = Expander<P, I>.ScanForClosingParenthesis(expressionFunction, argumentStartIndex);
- ErrorUtilities.VerifyThrow(num != -1, "Unmatched braces when constructing function.", "$(" + expressionFunction + ")");
- bindingFlags |= BindingFlags.InvokeMethod;
- if (argumentStartIndex == (expressionFunction.Length - 1))
- {
- str3 = string.Empty;
- strArray = new string[0];
- }
- else
- {
- str3 = expressionFunction.Substring(argumentStartIndex, num - argumentStartIndex);
- if (string.IsNullOrEmpty(str3))
- {
- strArray = new string[0];
- }
- else
- {
- strArray = Expander<P, I>.ExtractFunctionArguments(elementLocation, expressionFunction, str3);
- }
- str2 = expressionFunction.Substring(num + 1);
- }
- }
- else
- {
- int index = expressionFunction.IndexOf('.', methodStartIndex);
- int length = expressionFunction.Length - methodStartIndex;
- int num4 = expressionFunction.IndexOf('[', methodStartIndex);
- if ((num4 >= 0) && (num4 < index))
- {
- index = num4;
- }
- strArray = new string[0];
- if (index > 0)
- {
- length = index - methodStartIndex;
- str2 = expressionFunction.Substring(index);
- }
- string str4 = expressionFunction.Substring(methodStartIndex, length).Trim();
- ProjectErrorUtilities.VerifyThrowInvalidProject(str4.Length > 0, elementLocation, "InvalidFunctionPropertyExpression", expressionFunction, string.Empty);
- bindingFlags |= BindingFlags.GetProperty | BindingFlags.GetField;
- str = str4;
- }
- if ((string.IsNullOrEmpty(str2) || (str2[0] == '.')) || (str2[0] == '['))
- {
- return new Expander<P, I>.Function<T>(objectType, expressionFunction, expressionRootName, str, strArray, bindingFlags, str2, usedUninitializedProperties);
- }
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionPropertyExpression", expressionFunction, string.Empty);
- return null;
- }
-
- private static Expander<P, I>.Function<T> ConstructIndexerFunction(string expressionFunction, IElementLocation elementLocation, object propertyValue, string propertyName, Type objectType, int methodStartIndex, string argumentsContent, UsedUninitializedProperties usedUnInitializedProperties)
- {
- string str2;
- string[] strArray;
- string remainder = expressionFunction.Substring(methodStartIndex);
- if (string.IsNullOrEmpty(argumentsContent))
- {
- strArray = new string[0];
- }
- else
- {
- strArray = Expander<P, I>.ExtractFunctionArguments(elementLocation, expressionFunction, argumentsContent);
- }
- if (propertyValue is Array)
- {
- str2 = "GetValue";
- }
- else if (propertyValue is string)
- {
- str2 = "get_Chars";
- }
- else
- {
- str2 = "get_Item";
- }
- return new Expander<P, I>.Function<T>(objectType, expressionFunction, propertyName, str2, strArray, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.IgnoreCase, remainder, usedUnInitializedProperties);
- }
-
- internal object Execute(object objectInstance, IPropertyProvider<T> properties, ExpanderOptions options, IElementLocation elementLocation)
- {
- object propertyValue = string.Empty;
- object[] args = null;
- try
- {
- if (objectInstance == null)
- {
- if (!this.IsStaticMethodAvailable(this.objectType, this.name))
- {
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionMethodUnavailable", this.name, this.objectType.FullName);
- }
- this.bindingFlags |= BindingFlags.Static;
- if (this.objectType == typeof(IntrinsicFunctions))
- {
- this.bindingFlags |= BindingFlags.NonPublic;
- }
- }
- else
- {
- this.bindingFlags |= BindingFlags.Instance;
- if (objectInstance is string)
- {
- objectInstance = EscapingUtilities.UnescapeAll((string) objectInstance);
- }
- }
- args = new object[this.arguments.Length];
- for (int i = 0; i < this.arguments.Length; i++)
- {
- object obj3 = Expander<P, I>.PropertyExpander<T>.ExpandPropertiesLeaveTypedAndEscaped(this.arguments[i], properties, options, elementLocation, this.usedUninitializedProperties);
- string escapedString = obj3 as string;
- if (escapedString != null)
- {
- args[i] = EscapingUtilities.UnescapeAll(escapedString);
- }
- else
- {
- args[i] = obj3;
- }
- }
- if (((objectInstance != null) && (args.Length == 1)) && (string.Equals("Equals", this.name, StringComparison.OrdinalIgnoreCase) || string.Equals("CompareTo", this.name, StringComparison.OrdinalIgnoreCase)))
- {
- args[0] = Convert.ChangeType(args[0], objectInstance.GetType(), CultureInfo.InvariantCulture);
- }
- if (string.Equals("new", this.name, StringComparison.OrdinalIgnoreCase))
- {
- propertyValue = this.LateBindExecute(null, BindingFlags.Public | BindingFlags.Instance, null, args, true);
- }
- else
- {
- try
- {
- propertyValue = this.objectType.InvokeMember(this.name, this.bindingFlags, Type.DefaultBinder, objectInstance, args, CultureInfo.InvariantCulture);
- }
- catch (MissingMethodException exception)
- {
- if ((this.bindingFlags & BindingFlags.InvokeMethod) != BindingFlags.InvokeMethod)
- {
- throw;
- }
- propertyValue = this.LateBindExecute(exception, this.bindingFlags, objectInstance, args, false);
- }
- }
- if (((propertyValue is string) && !string.Equals("Unescape", this.name, StringComparison.OrdinalIgnoreCase)) && !string.Equals("Escape", this.name, StringComparison.OrdinalIgnoreCase))
- {
- propertyValue = EscapingUtilities.Escape((string) propertyValue);
- }
- if (string.IsNullOrEmpty(this.remainder))
- {
- return propertyValue;
- }
- return Expander<P, I>.PropertyExpander<T>.ExpandPropertyBody(this.remainder, propertyValue, properties, options, elementLocation, this.usedUninitializedProperties);
- }
- catch (TargetInvocationException exception2)
- {
- string str2 = this.GenerateStringOfMethodExecuted(this.expression, objectInstance, this.name, args);
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionPropertyExpression", str2, exception2.InnerException.Message.Replace("\r\n", " "));
- return null;
- }
- catch (Exception exception3)
- {
- if (ExceptionHandling.NotExpectedFunctionException(exception3))
- {
- throw;
- }
- if (Expander<P, I>.invariantCompareInfo.IndexOf(this.expression, "::", CompareOptions.OrdinalIgnoreCase) > -1)
- {
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionStaticMethodSyntax", this.expression, exception3.Message.Replace("Microsoft.Build.Evaluation.IntrinsicFunctions.", "[MSBuild]::"));
- }
- else
- {
- string str3 = this.GenerateStringOfMethodExecuted(this.expression, objectInstance, this.name, args);
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionPropertyExpression", str3, exception3.Message);
- }
- return null;
- }
- }
-
- internal static Expander<P, I>.Function<T> ExtractPropertyFunction(string expressionFunction, IElementLocation elementLocation, object propertyValue, UsedUninitializedProperties usedUnInitializedProperties)
- {
- string propertyName = null;
- Type objectType = null;
- string str2 = expressionFunction;
- int index = expressionFunction.IndexOf('(');
- if (index > -1)
- {
- str2 = expressionFunction.Substring(0, index);
- }
- ProjectErrorUtilities.VerifyThrowInvalidProject(!string.IsNullOrEmpty(str2), elementLocation, "InvalidFunctionPropertyExpression", expressionFunction, string.Empty);
- int methodStartIndex = -1;
- if ((propertyValue == null) && (str2[0] == '['))
- {
- int num3 = str2.IndexOf(']', 1);
- if (num3 < 1)
- {
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionStaticMethodSyntax", expressionFunction, string.Empty);
- }
- string typeName = str2.Substring(1, num3 - 1);
- methodStartIndex = num3 + 1;
- objectType = Expander<P, I>.Function<T>.GetTypeForStaticMethod(typeName);
- if (objectType == null)
- {
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionTypeUnavailable", expressionFunction, typeName);
- }
- if (((str2.Length > (methodStartIndex + 2)) && (str2[methodStartIndex] == ':')) && (str2[methodStartIndex + 1] == ':'))
- {
- methodStartIndex += 2;
- }
- else
- {
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionStaticMethodSyntax", expressionFunction, string.Empty);
- }
- }
- else
- {
- if (expressionFunction[0] == '[')
- {
- objectType = propertyValue.GetType();
- int num4 = expressionFunction.IndexOf(']', 1);
- if (num4 < 1)
- {
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionPropertyExpression", expressionFunction, AssemblyResources.GetString("InvalidFunctionPropertyExpressionDetailMismatchedSquareBrackets"));
- }
- string argumentsContent = expressionFunction.Substring(1, num4 - 1);
- methodStartIndex = num4 + 1;
- return Expander<P, I>.Function<T>.ConstructIndexerFunction(expressionFunction, elementLocation, propertyValue, propertyName, objectType, methodStartIndex, argumentsContent, usedUnInitializedProperties);
- }
- methodStartIndex = str2.IndexOf('.');
- if (methodStartIndex == -1)
- {
- return null;
- }
- methodStartIndex++;
- }
- if (objectType == null)
- {
- int length = str2.IndexOf('.');
- propertyName = str2.Substring(0, length);
- if ((propertyValue == null) && !Expander<P, I>.IsValidPropertyName(propertyName))
- {
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionPropertyExpression", expressionFunction, string.Empty);
- }
- objectType = typeof(string);
- }
- if (propertyValue != null)
- {
- objectType = propertyValue.GetType();
- }
- return Expander<P, I>.Function<T>.ConstructFunction(elementLocation, expressionFunction, propertyName, objectType, index, methodStartIndex, usedUnInitializedProperties);
- }
-
- private string GenerateStringOfMethodExecuted(string expression, object objectInstance, string name, object[] args)
- {
- string str = string.Empty;
- if (args != null)
- {
- foreach (object obj2 in args)
- {
- if (obj2 == null)
- {
- str = str + "null";
- }
- else
- {
- string str2 = obj2.ToString();
- if ((obj2 is string) && (str2.Length == 0))
- {
- str = str + "''";
- }
- else
- {
- str = str + obj2.ToString();
- }
- }
- str = str + ", ";
- }
- if (str.Length > 2)
- {
- str = str.Substring(0, str.Length - 2);
- }
- }
- if (objectInstance == null)
- {
- string fullName = this.objectType.FullName;
- if (this.objectType == typeof(IntrinsicFunctions))
- {
- fullName = "MSBuild";
- }
- if ((this.bindingFlags & BindingFlags.InvokeMethod) == BindingFlags.InvokeMethod)
- {
- return ("[" + fullName + "]::" + name + "(" + str + ")");
- }
- return ("[" + fullName + "]::" + name);
- }
- string str4 = "\"" + objectInstance + "\"";
- if ((this.bindingFlags & BindingFlags.InvokeMethod) == BindingFlags.InvokeMethod)
- {
- return (str4 + "." + name + "(" + str + ")");
- }
- return (str4 + "." + name);
- }
-
- private static Type GetTypeForStaticMethod(string typeName)
- {
- Type typeFromAssembly;
- Tuple<string, Type> tuple;
- if (FunctionConstants.AvailableStaticMethods.TryGetValue(typeName, out tuple) && (tuple != null))
- {
- ErrorUtilities.VerifyThrow((tuple.Item1 != null) || (tuple.Item2 != null), "Function type information needs either string or type represented.");
- if (tuple.Item2 != null)
- {
- return tuple.Item2;
- }
- if (tuple.Item1 != null)
- {
- typeName = tuple.Item1;
- typeFromAssembly = Type.GetType(typeName, false, true);
- FunctionConstants.AvailableStaticMethods[typeName] = new Tuple<string, Type>(typeName, typeFromAssembly);
- return typeFromAssembly;
- }
- }
- typeFromAssembly = Type.GetType(typeName, false, true);
- if (typeFromAssembly == null)
- {
- if (!(Environment.GetEnvironmentVariable("MSBUILDENABLEALLPROPERTYFUNCTIONS") == "1"))
- {
- return typeFromAssembly;
- }
- if (typeFromAssembly == null)
- {
- typeFromAssembly = Expander<P, I>.Function<T>.GetTypeFromAssembly(typeName, "System");
- }
- if (typeFromAssembly == null)
- {
- typeFromAssembly = Expander<P, I>.Function<T>.GetTypeFromAssembly(typeName, "System.Core");
- }
- if (typeFromAssembly == null)
- {
- typeFromAssembly = Expander<P, I>.Function<T>.GetTypeFromAssemblyUsingNamespace(typeName);
- }
- if (typeFromAssembly != null)
- {
- FunctionConstants.AvailableStaticMethods[typeName] = new Tuple<string, Type>(typeName, typeFromAssembly);
- }
- }
- return typeFromAssembly;
- }
-
- private static Type GetTypeFromAssembly(string typeName, string candidateAssemblyName)
- {
- Type type = null;
- Assembly assembly = Assembly.LoadWithPartialName(candidateAssemblyName);
- if (assembly != null)
- {
- type = assembly.GetType(typeName, false, true);
- }
- return type;
- }
-
- private static Type GetTypeFromAssemblyUsingNamespace(string typeName)
- {
- string str = typeName;
- int length = str.LastIndexOf('.');
- Type typeFromAssembly = null;
- ErrorUtilities.VerifyThrow(length > 0, "Invalid typename: {0}", typeName);
- while (length > 0)
- {
- string candidateAssemblyName = null;
- candidateAssemblyName = str.Substring(0, length);
- typeFromAssembly = Expander<P, I>.Function<T>.GetTypeFromAssembly(typeName, candidateAssemblyName);
- if (typeFromAssembly != null)
- {
- return typeFromAssembly;
- }
- length = candidateAssemblyName.LastIndexOf('.');
- }
- return null;
- }
-
- private bool IsStaticMethodAvailable(Type objectType, string methodName)
- {
- if (objectType == typeof(IntrinsicFunctions))
- {
- return true;
- }
- string key = objectType.FullName + "::" + methodName;
- return (FunctionConstants.AvailableStaticMethods.ContainsKey(objectType.FullName) || (FunctionConstants.AvailableStaticMethods.ContainsKey(key) || (Environment.GetEnvironmentVariable("MSBUILDENABLEALLPROPERTYFUNCTIONS") == "1")));
- }
-
- private object LateBindExecute(Exception ex, BindingFlags bindingFlags, object objectInstance, object[] args, bool isConstructor)
- {
- ParameterInfo[] parameters = null;
- MethodBase[] constructors = null;
- MethodBase base2 = null;
- Type[] types = new Type[this.arguments.Length];
- for (int i = 0; i < this.arguments.Length; i++)
- {
- types[i] = typeof(string);
- }
- if (isConstructor)
- {
- base2 = this.objectType.GetConstructor(bindingFlags, null, types, null);
- }
- else
- {
- base2 = this.objectType.GetMethod(this.name, bindingFlags, null, types, null);
- }
- if (base2 == null)
- {
- if (isConstructor)
- {
- constructors = this.objectType.GetConstructors(bindingFlags);
- }
- else
- {
- constructors = this.objectType.GetMethods(bindingFlags);
- }
- object[] objArray = null;
- foreach (MethodBase base3 in constructors)
- {
- parameters = base3.GetParameters();
- if ((parameters.Length == this.arguments.Length) && (isConstructor || string.Equals(base3.Name, this.name, StringComparison.OrdinalIgnoreCase)))
- {
- objArray = Expander<P, I>.Function<T>.CoerceArguments(args, parameters);
- if (objArray != null)
- {
- base2 = base3;
- args = objArray;
- break;
- }
- }
- }
- }
- object obj2 = null;
- if ((base2 != null) && (args != null))
- {
- if (isConstructor)
- {
- obj2 = ((ConstructorInfo) base2).Invoke(args);
- }
- else
- {
- obj2 = ((MethodInfo) base2).Invoke(objectInstance, args);
- }
- }
- else if (!isConstructor)
- {
- throw ex;
- }
- if ((obj2 == null) && isConstructor)
- {
- throw new TargetInvocationException(new MissingMethodException());
- }
- return obj2;
- }
-
- internal string ExpressionRootName
- {
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.expressionRootName;
- }
- }
- }
-
- private static class ItemExpander
- {
- private static bool ExpandItemVectorMatchIntoStringBuilder<S>(Expander<P, I> expander, ExpressionShredder.ItemExpressionCapture match, IItemProvider<S> items, IElementLocation elementLocation, StringBuilder builder, ExpanderOptions options) where S: class, IItem
- {
- string itemType = match.ItemType;
- string str2 = (match.Separator != null) ? match.Separator : ";";
- ProjectErrorUtilities.VerifyThrowInvalidProject(!string.IsNullOrEmpty(itemType), elementLocation, "InvalidFunctionPropertyExpression");
- ICollection<S> itemsOfType = items.GetItems(itemType);
- if (itemsOfType.Count != 0)
- {
- if (match.Captures == null)
- {
- foreach (S local in itemsOfType)
- {
- if ((local.EvaluatedIncludeEscaped.Length > 0) && ((options & ExpanderOptions.BreakOnNotEmpty) != ExpanderOptions.Invalid))
- {
- return true;
- }
- builder.Append(local.EvaluatedIncludeEscaped);
- builder.Append(str2);
- }
- }
- else
- {
- Stack<TransformFunction<P, I, S>> transformFunctionStack = Expander<P, I>.ItemExpander.PrepareTransformStackFromMatch<S>(elementLocation, match);
- foreach (Tuple<string, S> tuple in Expander<P, I>.ItemExpander.Transform<S>(expander, true, transformFunctionStack, IntrinsicItemFunctions<P, I, S>.GetItemTupleEnumerator(itemsOfType)))
- {
- if (((tuple.Item1 != null) && (tuple.Item1.Length > 0)) && ((options & ExpanderOptions.BreakOnNotEmpty) != ExpanderOptions.Invalid))
- {
- return true;
- }
- if (tuple.Item1 != null)
- {
- builder.Append(tuple.Item1);
- }
- builder.Append(str2);
- }
- }
- if (builder.Length > 0)
- {
- builder.Remove(builder.Length - str2.Length, str2.Length);
- }
- }
- return false;
- }
-
- internal static string ExpandItemVectorsIntoString<T>(Expander<P, I> expander, string expression, IItemProvider<T> items, ExpanderOptions options, IElementLocation elementLocation) where T: class, IItem
- {
- if (((options & ExpanderOptions.ExpandItems) == ExpanderOptions.Invalid) || (expression.Length == 0))
- {
- return expression;
- }
- ErrorUtilities.VerifyThrow(items != null, "Cannot expand items without providing items");
- List<ExpressionShredder.ItemExpressionCapture> referencedItemExpressions = ExpressionShredder.GetReferencedItemExpressions(expression);
- if (referencedItemExpressions == null)
- {
- return expression;
- }
- StringBuilder builder = new StringBuilder();
- int startIndex = 0;
- for (int i = 0; i < referencedItemExpressions.Count; i++)
- {
- if (referencedItemExpressions[i].Index > startIndex)
- {
- if ((options & ExpanderOptions.BreakOnNotEmpty) != ExpanderOptions.Invalid)
- {
- return null;
- }
- builder.Append(expression, startIndex, referencedItemExpressions[i].Index - startIndex);
- }
- if (Expander<P, I>.ItemExpander.ExpandItemVectorMatchIntoStringBuilder<T>(expander, referencedItemExpressions[i], items, elementLocation, builder, options))
- {
- return null;
- }
- startIndex = referencedItemExpressions[i].Index + referencedItemExpressions[i].Length;
- }
- builder.Append(expression, startIndex, expression.Length - startIndex);
- return OpportunisticIntern.StringBuilderToString(builder);
- }
-
- internal static IList<T> ExpandSingleItemVectorExpressionIntoItems<S, T>(Expander<P, I> expander, string expression, IItemProvider<S> items, IItemFactory<S, T> itemFactory, ExpanderOptions options, bool includeNullEntries, out bool isTransformExpression, IElementLocation elementLocation) where S: class, IItem where T: class, IItem
- {
- isTransformExpression = false;
- if (((options & ExpanderOptions.ExpandItems) == ExpanderOptions.Invalid) || (expression.Length == 0))
- {
- return null;
- }
- ErrorUtilities.VerifyThrow(items != null, "Cannot expand items without providing items");
- List<ExpressionShredder.ItemExpressionCapture> referencedItemExpressions = null;
- if (Expander<P, I>.invariantCompareInfo.IndexOf(expression, '@') == -1)
- {
- return null;
- }
- referencedItemExpressions = ExpressionShredder.GetReferencedItemExpressions(expression);
- if (referencedItemExpressions == null)
- {
- return null;
- }
- ExpressionShredder.ItemExpressionCapture match = referencedItemExpressions[0];
- ProjectErrorUtilities.VerifyThrowInvalidProject(match.Value == expression, elementLocation, "EmbeddedItemVectorCannotBeItemized", expression);
- ErrorUtilities.VerifyThrow(referencedItemExpressions.Count == 1, "Expected just one item vector");
- if (itemFactory.ItemType == null)
- {
- itemFactory.ItemType = match.ItemType;
- }
- IList<T> list2 = null;
- if (match.Separator != null)
- {
- StringBuilder builder = new StringBuilder();
- if (Expander<P, I>.ItemExpander.ExpandItemVectorMatchIntoStringBuilder<S>(expander, match, items, elementLocation, builder, options))
- {
- return null;
- }
- string include = OpportunisticIntern.StringBuilderToString(builder);
- list2 = new List<T>(1);
- if (include.Length > 0)
- {
- T item = itemFactory.CreateItem(include);
- list2.Add(item);
- }
- return list2;
- }
- if (match.Captures != null)
- {
- isTransformExpression = true;
- }
- ICollection<S> itemsOfType = items.GetItems(match.ItemType);
- if (itemsOfType.Count == 0)
- {
- return new List<T>();
- }
- list2 = new List<T>(itemsOfType.Count);
- if (!isTransformExpression)
- {
- foreach (S local2 in itemsOfType)
- {
- if ((options & ExpanderOptions.BreakOnNotEmpty) != ExpanderOptions.Invalid)
- {
- return null;
- }
- T local3 = itemFactory.CreateItem(local2);
- list2.Add(local3);
- }
- return list2;
- }
- Stack<TransformFunction<P, I, S>> transformFunctionStack = Expander<P, I>.ItemExpander.PrepareTransformStackFromMatch<S>(elementLocation, match);
- foreach (Tuple<string, S> tuple in Expander<P, I>.ItemExpander.Transform<S>(expander, includeNullEntries, transformFunctionStack, IntrinsicItemFunctions<P, I, S>.GetItemTupleEnumerator(itemsOfType)))
- {
- if ((tuple.Item1 != null) && (tuple.Item2 == null))
- {
- list2.Add(itemFactory.CreateItem(tuple.Item1));
- }
- else
- {
- if ((tuple.Item1 != null) && (tuple.Item2 != null))
- {
- list2.Add(itemFactory.CreateItem(tuple.Item1, tuple.Item2));
- continue;
- }
- if (includeNullEntries)
- {
- T local4 = default(T);
- list2.Add(local4);
- }
- }
- }
- return list2;
- }
-
- private static Stack<TransformFunction<P, I, S>> PrepareTransformStackFromMatch<S>(IElementLocation elementLocation, ExpressionShredder.ItemExpressionCapture match) where S: class, IItem
- {
- ProjectErrorUtilities.VerifyThrowInvalidProject(match.Captures.Count > 0, elementLocation, "InvalidFunctionPropertyExpression");
- Stack<TransformFunction<P, I, S>> stack = new Stack<TransformFunction<P, I, S>>(match.Captures.Count);
- for (int i = match.Captures.Count - 1; i >= 0; i--)
- {
- string str = match.Captures[i].Value;
- string functionName = match.Captures[i].FunctionName;
- string functionArguments = match.Captures[i].FunctionArguments;
- string[] arguments = null;
- if (functionName == null)
- {
- functionName = "ExpandQuotedExpressionFunction";
- arguments = new string[] { str };
- }
- else if (functionArguments != null)
- {
- arguments = Expander<P, I>.ExtractFunctionArguments(elementLocation, functionArguments, functionArguments);
- }
- IntrinsicItemFunctions<P, I, S>.ItemTransformFunction transform = IntrinsicItemFunctions<P, I, S>.GetItemTransformFunction(elementLocation, functionName, typeof(S));
- stack.Push(new TransformFunction<P, I, S>(elementLocation, functionName, transform, arguments));
- }
- return stack;
- }
-
- internal static IEnumerable<Tuple<string, S>> Transform<S>(Expander<P, I> expander, bool includeNullEntries, Stack<TransformFunction<P, I, S>> transformFunctionStack, IEnumerable<Tuple<string, S>> itemsOfType) where S: class, IItem
- {
- if (this.transformFunctionStack.Count > 0)
- {
- TransformFunction<P, I, S> iteratorVariable0 = this.transformFunctionStack.Pop();
- IEnumerator<Tuple<string, S>> enumerator = Expander<P, I>.ItemExpander.Transform<S>(this.expander, this.includeNullEntries, this.transformFunctionStack, iteratorVariable0.Execute(this.expander, this.includeNullEntries, this.itemsOfType)).GetEnumerator();
- while (enumerator.MoveNext())
- {
- Tuple<string, S> current = enumerator.Current;
- yield return current;
- }
- this.<>m__Finally5();
- }
- else
- {
- IEnumerator<Tuple<string, S>> iteratorVariable4 = this.itemsOfType.GetEnumerator();
- while (iteratorVariable4.MoveNext())
- {
- Tuple<string, S> iteratorVariable2 = iteratorVariable4.Current;
- yield return iteratorVariable2;
- }
- this.<>m__Finally7();
- }
- }
-
- [CompilerGenerated]
- private sealed class <Transform>d__0<S> : IEnumerable<Tuple<string, S>>, IEnumerable, IEnumerator<Tuple<string, S>>, IEnumerator, IDisposable where S: class, IItem
- {
- private int <>1__state;
- private Tuple<string, S> <>2__current;
- public Expander<P, I> <>3__expander;
- public bool <>3__includeNullEntries;
- public IEnumerable<Tuple<string, S>> <>3__itemsOfType;
- public Stack<Expander<P, I>.ItemExpander.TransformFunction<S>> <>3__transformFunctionStack;
- public IEnumerator<Tuple<string, S>> <>7__wrap4;
- public IEnumerator<Tuple<string, S>> <>7__wrap6;
- private int <>l__initialThreadId;
- public Expander<P, I>.ItemExpander.TransformFunction<S> <function>5__1;
- public Tuple<string, S> <item>5__2;
- public Tuple<string, S> <item>5__3;
- public Expander<P, I> expander;
- public bool includeNullEntries;
- public IEnumerable<Tuple<string, S>> itemsOfType;
- public Stack<Expander<P, I>.ItemExpander.TransformFunction<S>> transformFunctionStack;
-
- [DebuggerHidden]
- public <Transform>d__0(int <>1__state)
- {
- this.<>1__state = <>1__state;
- this.<>l__initialThreadId = Thread.CurrentThread.ManagedThreadId;
- }
-
- private void <>m__Finally5()
- {
- this.<>1__state = -1;
- if (this.<>7__wrap4 != null)
- {
- this.<>7__wrap4.Dispose();
- }
- }
-
- private void <>m__Finally7()
- {
- this.<>1__state = -1;
- if (this.<>7__wrap6 != null)
- {
- this.<>7__wrap6.Dispose();
- }
- }
-
- private bool MoveNext()
- {
- bool flag;
- try
- {
- switch (this.<>1__state)
- {
- case 0:
- this.<>1__state = -1;
- if (this.transformFunctionStack.Count <= 0)
- {
- goto Label_00DE;
- }
- this.<function>5__1 = this.transformFunctionStack.Pop();
- this.<>7__wrap4 = Expander<P, I>.ItemExpander.Transform<S>(this.expander, this.includeNullEntries, this.transformFunctionStack, this.<function>5__1.Execute(this.expander, this.includeNullEntries, this.itemsOfType)).GetEnumerator();
- this.<>1__state = 1;
- goto Label_00C9;
-
- case 2:
- this.<>1__state = 1;
- goto Label_00C9;
-
- case 4:
- goto Label_0120;
-
- default:
- goto Label_013A;
- }
- Label_0097:
- this.<item>5__2 = this.<>7__wrap4.Current;
- this.<>2__current = this.<item>5__2;
- this.<>1__state = 2;
- return true;
- Label_00C9:
- if (this.<>7__wrap4.MoveNext())
- {
- goto Label_0097;
- }
- this.<>m__Finally5();
- goto Label_013A;
- Label_00DE:
- this.<>7__wrap6 = this.itemsOfType.GetEnumerator();
- this.<>1__state = 3;
- while (this.<>7__wrap6.MoveNext())
- {
- this.<item>5__3 = this.<>7__wrap6.Current;
- this.<>2__current = this.<item>5__3;
- this.<>1__state = 4;
- return true;
- Label_0120:
- this.<>1__state = 3;
- }
- this.<>m__Finally7();
- Label_013A:
- flag = false;
- }
- fault
- {
- this.System.IDisposable.Dispose();
- }
- return flag;
- }
-
- [DebuggerHidden]
- IEnumerator<Tuple<string, S>> IEnumerable<Tuple<string, S>>.GetEnumerator()
- {
- Expander<P, I>.ItemExpander.<Transform>d__0<S> d__;
- if ((Thread.CurrentThread.ManagedThreadId == this.<>l__initialThreadId) && (this.<>1__state == -2))
- {
- this.<>1__state = 0;
- d__ = (Expander<P, I>.ItemExpander.<Transform>d__0<S>) this;
- }
- else
- {
- d__ = new Expander<P, I>.ItemExpander.<Transform>d__0<S>(0);
- }
- d__.expander = this.<>3__expander;
- d__.includeNullEntries = this.<>3__includeNullEntries;
- d__.transformFunctionStack = this.<>3__transformFunctionStack;
- d__.itemsOfType = this.<>3__itemsOfType;
- return d__;
- }
-
- [DebuggerHidden]
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.System.Collections.Generic.IEnumerable<System.Tuple<System.String,S>>.GetEnumerator();
- }
-
- [DebuggerHidden]
- void IEnumerator.Reset()
- {
- throw new NotSupportedException();
- }
-
- void IDisposable.Dispose()
- {
- switch (this.<>1__state)
- {
- case 1:
- case 2:
- try
- {
- }
- finally
- {
- this.<>m__Finally5();
- }
- break;
-
- case 3:
- case 4:
- try
- {
- }
- finally
- {
- this.<>m__Finally7();
- }
- return;
- }
- }
-
- Tuple<string, S> IEnumerator<Tuple<string, S>>.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
-
- object IEnumerator.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
- }
-
- internal static class IntrinsicItemFunctions<S> where S: class, IItem
- {
- private static ConcurrentDictionary<string, ItemTransformFunction<P, I, S>> transformFunctionDelegateCache;
-
- static IntrinsicItemFunctions()
- {
- Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.transformFunctionDelegateCache = new ConcurrentDictionary<string, ItemTransformFunction<P, I, S>>(StringComparer.OrdinalIgnoreCase);
- }
-
- internal static IEnumerable<Tuple<string, S>> AnyHaveMetadataValue(Expander<P, I> expander, IElementLocation elementLocation, bool includeNullEntries, string functionName, IEnumerable<Tuple<string, S>> itemsOfType, string[] arguments)
- {
- ProjectErrorUtilities.VerifyThrowInvalidProject((arguments != null) && (arguments.Length == 2), elementLocation, "InvalidItemFunctionSyntax", functionName);
- string name = arguments[0];
- string b = arguments[1];
- bool iteratorVariable2 = false;
- foreach (Tuple<string, S> iteratorVariable3 in itemsOfType)
- {
- if (iteratorVariable3.Item2 != null)
- {
- string metadataValue = iteratorVariable3.Item2.GetMetadataValue(name);
- if ((metadataValue != null) && string.Equals(metadataValue, b, StringComparison.OrdinalIgnoreCase))
- {
- iteratorVariable2 = true;
- yield return new Tuple<string, S>("true", iteratorVariable3.Item2);
- goto Label_017E;
- }
- }
- }
- if (!iteratorVariable2)
- {
- yield return new Tuple<string, S>("false", default(S));
- }
- Label_017E:
- yield break;
- }
-
- internal static IEnumerable<Tuple<string, S>> ClearMetadata(Expander<P, I> expander, IElementLocation elementLocation, bool includeNullEntries, string functionName, IEnumerable<Tuple<string, S>> itemsOfType, string[] arguments)
- {
- ProjectErrorUtilities.VerifyThrowInvalidProject((arguments == null) || (arguments.Length == 0), elementLocation, "InvalidItemFunctionSyntax", functionName);
- foreach (Tuple<string, S> iteratorVariable0 in itemsOfType)
- {
- if (includeNullEntries || (iteratorVariable0.Item1 != null))
- {
- yield return new Tuple<string, S>(iteratorVariable0.Item1, default(S));
- }
- }
- }
-
- internal static IEnumerable<Tuple<string, S>> DirectoryName(Expander<P, I> expander, IElementLocation elementLocation, bool includeNullEntries, string functionName, IEnumerable<Tuple<string, S>> itemsOfType, string[] arguments)
- {
- ProjectErrorUtilities.VerifyThrowInvalidProject((arguments == null) || (arguments.Length == 0), elementLocation, "InvalidItemFunctionSyntax", functionName);
- Dictionary<string, string> iteratorVariable0 = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
- foreach (Tuple<string, S> iteratorVariable1 in itemsOfType)
- {
- if (!string.IsNullOrEmpty(iteratorVariable1.Item1))
- {
- string directoryName = null;
- if (!iteratorVariable0.TryGetValue(iteratorVariable1.Item1, out directoryName))
- {
- string path = EscapingUtilities.UnescapeAll(iteratorVariable1.Item1);
- try
- {
- string str2;
- if (Path.IsPathRooted(path))
- {
- str2 = path;
- }
- else
- {
- string str3 = iteratorVariable1.Item2.ProjectDirectory ?? string.Empty;
- str2 = Path.Combine(str3, path);
- }
- directoryName = Path.GetDirectoryName(str2);
- }
- catch (Exception exception)
- {
- if (ExceptionHandling.NotExpectedException(exception))
- {
- throw;
- }
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidItemFunctionExpression", functionName, iteratorVariable1.Item1, exception.Message);
- }
- directoryName = EscapingUtilities.Escape(directoryName);
- iteratorVariable0[path] = directoryName;
- }
- if (!string.IsNullOrEmpty(directoryName))
- {
- yield return new Tuple<string, S>(directoryName, iteratorVariable1.Item2);
- }
- else if (includeNullEntries)
- {
- yield return new Tuple<string, S>(null, iteratorVariable1.Item2);
- }
- }
- }
- }
-
- internal static IEnumerable<Tuple<string, S>> Distinct(Expander<P, I> expander, IElementLocation elementLocation, bool includeNullEntries, string functionName, IEnumerable<Tuple<string, S>> itemsOfType, string[] arguments)
- {
- return Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.DistinctWithComparer(expander, elementLocation, includeNullEntries, functionName, itemsOfType, arguments, StringComparer.OrdinalIgnoreCase);
- }
-
- internal static IEnumerable<Tuple<string, S>> DistinctWithCase(Expander<P, I> expander, IElementLocation elementLocation, bool includeNullEntries, string functionName, IEnumerable<Tuple<string, S>> itemsOfType, string[] arguments)
- {
- return Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.DistinctWithComparer(expander, elementLocation, includeNullEntries, functionName, itemsOfType, arguments, StringComparer.Ordinal);
- }
-
- internal static IEnumerable<Tuple<string, S>> DistinctWithComparer(Expander<P, I> expander, IElementLocation elementLocation, bool includeNullEntries, string functionName, IEnumerable<Tuple<string, S>> itemsOfType, string[] arguments, StringComparer comparer)
- {
- ProjectErrorUtilities.VerifyThrowInvalidProject((arguments == null) || (arguments.Length == 0), elementLocation, "InvalidItemFunctionSyntax", functionName);
- Dictionary<string, S> iteratorVariable0 = new Dictionary<string, S>(comparer);
- foreach (Tuple<string, S> iteratorVariable1 in itemsOfType)
- {
- if ((iteratorVariable1.Item1 != null) && !iteratorVariable0.ContainsKey(iteratorVariable1.Item1))
- {
- iteratorVariable0[iteratorVariable1.Item1] = iteratorVariable1.Item2;
- yield return new Tuple<string, S>(iteratorVariable1.Item1, iteratorVariable1.Item2);
- }
- }
- }
-
- internal static IEnumerable<Tuple<string, S>> ExecuteStringFunction(Expander<P, I> expander, IElementLocation elementLocation, bool includeNullEntries, string functionName, IEnumerable<Tuple<string, S>> itemsOfType, string[] arguments)
- {
- foreach (Tuple<string, S> iteratorVariable0 in itemsOfType)
- {
- object valueToConvert = new Expander<P, I>.Function<P>(typeof(string), iteratorVariable0.Item1, iteratorVariable0.Item1, functionName, arguments, BindingFlags.InvokeMethod | BindingFlags.Public, string.Empty, expander.UsedUninitializedProperties).Execute(iteratorVariable0.Item1, expander.properties, ExpanderOptions.ExpandAll, elementLocation);
- string iteratorVariable3 = Expander<P, I>.PropertyExpander<P>.ConvertToString(valueToConvert);
- if (iteratorVariable3.Length > 0)
- {
- yield return new Tuple<string, S>(iteratorVariable3, iteratorVariable0.Item2);
- }
- else if (includeNullEntries)
- {
- yield return new Tuple<string, S>(null, iteratorVariable0.Item2);
- }
- }
- }
-
- internal static IEnumerable<Tuple<string, S>> ExpandQuotedExpressionFunction(Expander<P, I> expander, IElementLocation elementLocation, bool includeNullEntries, string functionName, IEnumerable<Tuple<string, S>> itemsOfType, string[] arguments)
- {
- ProjectErrorUtilities.VerifyThrowInvalidProject((arguments != null) && (arguments.Length == 1), elementLocation, "InvalidItemFunctionSyntax", functionName);
- foreach (Tuple<string, S> iteratorVariable0 in itemsOfType)
- {
- string iteratorVariable2 = null;
- if (iteratorVariable0.Item1 != null)
- {
- Expander<P, I>.ItemExpander.MetadataMatchEvaluator iteratorVariable1 = new Expander<P, I>.ItemExpander.MetadataMatchEvaluator(iteratorVariable0.Item1, iteratorVariable0.Item2, elementLocation);
- iteratorVariable2 = Expander<P, I>.RegularExpressions.ItemMetadataPattern.Replace(arguments[0], new MatchEvaluator(iteratorVariable1.GetMetadataValueFromMatch));
- }
- if ((iteratorVariable2 != null) && (iteratorVariable2.Length > 0))
- {
- yield return new Tuple<string, S>(iteratorVariable2, iteratorVariable0.Item2);
- }
- else if (includeNullEntries)
- {
- yield return new Tuple<string, S>(null, iteratorVariable0.Item2);
- }
- }
- }
-
- internal static ItemTransformFunction<P, I, S> GetItemTransformFunction(IElementLocation elementLocation, string functionName, Type itemType)
- {
- ItemTransformFunction<P, I, S> function = null;
- string key = itemType.FullName + "::" + functionName;
- if (!Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.transformFunctionDelegateCache.TryGetValue(key, out function))
- {
- if (FileUtilities.ItemSpecModifiers.IsDerivableItemSpecModifier(functionName))
- {
- function = new ItemTransformFunction<P, I, S>(Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.ItemSpecModifierFunction);
- }
- else
- {
- MethodInfo method = typeof(Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>).GetMethod(functionName, BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase);
- if (method == null)
- {
- functionName = "ExecuteStringFunction";
- method = typeof(Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>).GetMethod(functionName, BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase);
- if (method == null)
- {
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "UnknownItemFunction", functionName);
- return null;
- }
- function = (ItemTransformFunction<P, I, S>) Delegate.CreateDelegate(typeof(ItemTransformFunction<P, I, S>), method, false);
- }
- else
- {
- function = (ItemTransformFunction<P, I, S>) Delegate.CreateDelegate(typeof(ItemTransformFunction<P, I, S>), method, false);
- }
- }
- if (function == null)
- {
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "UnknownItemFunction", functionName);
- return null;
- }
- Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.transformFunctionDelegateCache[key] = function;
- }
- return function;
- }
-
- internal static IEnumerable<Tuple<string, S>> GetItemTupleEnumerator(IEnumerable<S> itemsOfType)
- {
- foreach (S iteratorVariable0 in itemsOfType)
- {
- yield return new Tuple<string, S>(iteratorVariable0.EvaluatedIncludeEscaped, iteratorVariable0);
- }
- }
-
- internal static IEnumerable<Tuple<string, S>> ItemSpecModifierFunction(Expander<P, I> expander, IElementLocation elementLocation, bool includeNullEntries, string functionName, IEnumerable<Tuple<string, S>> itemsOfType, string[] arguments)
- {
- ProjectErrorUtilities.VerifyThrowInvalidProject((arguments == null) || (arguments.Length == 0), elementLocation, "InvalidItemFunctionSyntax", functionName);
- CopyOnWriteDictionary<string, string> cachedModifiers = new CopyOnWriteDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
- foreach (Tuple<string, S> iteratorVariable1 in itemsOfType)
- {
- if (!string.IsNullOrEmpty(iteratorVariable1.Item1))
- {
- string iteratorVariable2 = null;
- try
- {
- string currentDirectory = iteratorVariable1.Item2.ProjectDirectory ?? Directory.GetCurrentDirectory();
- iteratorVariable2 = FileUtilities.ItemSpecModifiers.GetItemSpecModifier(currentDirectory, iteratorVariable1.Item1, functionName, ref cachedModifiers);
- }
- catch (Exception exception)
- {
- if (ExceptionHandling.NotExpectedException(exception))
- {
- throw;
- }
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidItemFunctionExpression", functionName, iteratorVariable1.Item1, exception.Message);
- }
- if (!string.IsNullOrEmpty(iteratorVariable2))
- {
- yield return new Tuple<string, S>(iteratorVariable2, iteratorVariable1.Item2);
- }
- else if (includeNullEntries)
- {
- yield return new Tuple<string, S>(null, iteratorVariable1.Item2);
- }
- }
- }
- }
-
- internal static IEnumerable<Tuple<string, S>> Metadata(Expander<P, I> expander, IElementLocation elementLocation, bool includeNullEntries, string functionName, IEnumerable<Tuple<string, S>> itemsOfType, string[] arguments)
- {
- ProjectErrorUtilities.VerifyThrowInvalidProject((arguments != null) && (arguments.Length == 1), elementLocation, "InvalidItemFunctionSyntax", functionName);
- string name = arguments[0];
- foreach (Tuple<string, S> iteratorVariable1 in itemsOfType)
- {
- if (iteratorVariable1.Item2 != null)
- {
- string metadataValueEscaped = iteratorVariable1.Item2.GetMetadataValueEscaped(name);
- if (!string.IsNullOrEmpty(metadataValueEscaped))
- {
- if (Expander<P, I>.invariantCompareInfo.IndexOf(metadataValueEscaped, ';') < 0)
- {
- yield return new Tuple<string, S>(metadataValueEscaped, iteratorVariable1.Item2);
- }
- else
- {
- IList<string> iteratorVariable3 = ExpressionShredder.SplitSemiColonSeparatedList(metadataValueEscaped);
- foreach (string iteratorVariable4 in iteratorVariable3)
- {
- yield return new Tuple<string, S>(iteratorVariable4, iteratorVariable1.Item2);
- }
- }
- }
- else if ((metadataValueEscaped != string.Empty) && includeNullEntries)
- {
- yield return new Tuple<string, S>(metadataValueEscaped, iteratorVariable1.Item2);
- }
- }
- }
- }
-
- internal static IEnumerable<Tuple<string, S>> Reverse(Expander<P, I> expander, IElementLocation elementLocation, bool includeNullEntries, string functionName, IEnumerable<Tuple<string, S>> itemsOfType, string[] arguments)
- {
- ProjectErrorUtilities.VerifyThrowInvalidProject((arguments == null) || (arguments.Length == 0), elementLocation, "InvalidItemFunctionSyntax", functionName);
- foreach (Tuple<string, S> iteratorVariable0 in itemsOfType.Reverse<Tuple<string, S>>())
- {
- yield return new Tuple<string, S>(iteratorVariable0.Item1, iteratorVariable0.Item2);
- }
- }
-
- internal static IEnumerable<Tuple<string, S>> WithMetadataValue(Expander<P, I> expander, IElementLocation elementLocation, bool includeNullEntries, string functionName, IEnumerable<Tuple<string, S>> itemsOfType, string[] arguments)
- {
- ProjectErrorUtilities.VerifyThrowInvalidProject((arguments != null) && (arguments.Length == 2), elementLocation, "InvalidItemFunctionSyntax", functionName);
- string name = arguments[0];
- string b = arguments[1];
- foreach (Tuple<string, S> iteratorVariable2 in itemsOfType)
- {
- string metadataValue = iteratorVariable2.Item2.GetMetadataValue(name);
- if ((metadataValue != null) && string.Equals(metadataValue, b, StringComparison.OrdinalIgnoreCase))
- {
- yield return new Tuple<string, S>(iteratorVariable2.Item1, iteratorVariable2.Item2);
- }
- }
- }
-
- [CompilerGenerated]
- private sealed class <AnyHaveMetadataValue>d__59 : IEnumerable<Tuple<string, S>>, IEnumerable, IEnumerator<Tuple<string, S>>, IEnumerator, IDisposable
- {
- private int <>1__state;
- private Tuple<string, S> <>2__current;
- public string[] <>3__arguments;
- public IElementLocation <>3__elementLocation;
- public string <>3__functionName;
- public IEnumerable<Tuple<string, S>> <>3__itemsOfType;
- public IEnumerator<Tuple<string, S>> <>7__wrap5f;
- private int <>l__initialThreadId;
- public Tuple<string, S> <item>5__5d;
- public bool <metadataFound>5__5c;
- public string <metadataName>5__5a;
- public string <metadataValue>5__5e;
- public string <metadataValueToFind>5__5b;
- public string[] arguments;
- public IElementLocation elementLocation;
- public string functionName;
- public IEnumerable<Tuple<string, S>> itemsOfType;
-
- [DebuggerHidden]
- public <AnyHaveMetadataValue>d__59(int <>1__state)
- {
- this.<>1__state = <>1__state;
- this.<>l__initialThreadId = Thread.CurrentThread.ManagedThreadId;
- }
-
- private void <>m__Finally60()
- {
- this.<>1__state = -1;
- if (this.<>7__wrap5f != null)
- {
- this.<>7__wrap5f.Dispose();
- }
- }
-
- private bool MoveNext()
- {
- bool flag;
- try
- {
- switch (this.<>1__state)
- {
- case 0:
- this.<>1__state = -1;
- ProjectErrorUtilities.VerifyThrowInvalidProject((this.arguments != null) && (this.arguments.Length == 2), this.elementLocation, "InvalidItemFunctionSyntax", this.functionName);
- this.<metadataName>5__5a = this.arguments[0];
- this.<metadataValueToFind>5__5b = this.arguments[1];
- this.<metadataFound>5__5c = false;
- this.<>7__wrap5f = this.itemsOfType.GetEnumerator();
- this.<>1__state = 1;
- goto Label_0135;
-
- case 2:
- this.<>1__state = 1;
- this.System.IDisposable.Dispose();
- goto Label_017E;
-
- case 3:
- this.<>1__state = -1;
- goto Label_017E;
-
- default:
- goto Label_017E;
- }
- Label_0095:
- this.<item>5__5d = this.<>7__wrap5f.Current;
- if (this.<item>5__5d.Item2 != null)
- {
- this.<metadataValue>5__5e = this.<item>5__5d.Item2.GetMetadataValue(this.<metadataName>5__5a);
- if ((this.<metadataValue>5__5e != null) && string.Equals(this.<metadataValue>5__5e, this.<metadataValueToFind>5__5b, StringComparison.OrdinalIgnoreCase))
- {
- this.<metadataFound>5__5c = true;
- this.<>2__current = new Tuple<string, S>("true", this.<item>5__5d.Item2);
- this.<>1__state = 2;
- return true;
- }
- }
- Label_0135:
- if (this.<>7__wrap5f.MoveNext())
- {
- goto Label_0095;
- }
- this.<>m__Finally60();
- if (!this.<metadataFound>5__5c)
- {
- this.<>2__current = new Tuple<string, S>("false", default(S));
- this.<>1__state = 3;
- return true;
- }
- Label_017E:
- flag = false;
- }
- fault
- {
- this.System.IDisposable.Dispose();
- }
- return flag;
- }
-
- [DebuggerHidden]
- IEnumerator<Tuple<string, S>> IEnumerable<Tuple<string, S>>.GetEnumerator()
- {
- Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<AnyHaveMetadataValue>d__59 d__;
- if ((Thread.CurrentThread.ManagedThreadId == this.<>l__initialThreadId) && (this.<>1__state == -2))
- {
- this.<>1__state = 0;
- d__ = (Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<AnyHaveMetadataValue>d__59) this;
- }
- else
- {
- d__ = new Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<AnyHaveMetadataValue>d__59(0);
- }
- d__.elementLocation = this.<>3__elementLocation;
- d__.functionName = this.<>3__functionName;
- d__.itemsOfType = this.<>3__itemsOfType;
- d__.arguments = this.<>3__arguments;
- return d__;
- }
-
- [DebuggerHidden]
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.System.Collections.Generic.IEnumerable<System.Tuple<System.String,S>>.GetEnumerator();
- }
-
- [DebuggerHidden]
- void IEnumerator.Reset()
- {
- throw new NotSupportedException();
- }
-
- void IDisposable.Dispose()
- {
- switch (this.<>1__state)
- {
- case 1:
- case 2:
- try
- {
- }
- finally
- {
- this.<>m__Finally60();
- }
- return;
- }
- }
-
- Tuple<string, S> IEnumerator<Tuple<string, S>>.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
-
- object IEnumerator.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
- }
-
- [CompilerGenerated]
- private sealed class <ClearMetadata>d__4a : IEnumerable<Tuple<string, S>>, IEnumerable, IEnumerator<Tuple<string, S>>, IEnumerator, IDisposable
- {
- private int <>1__state;
- private Tuple<string, S> <>2__current;
- public string[] <>3__arguments;
- public IElementLocation <>3__elementLocation;
- public string <>3__functionName;
- public bool <>3__includeNullEntries;
- public IEnumerable<Tuple<string, S>> <>3__itemsOfType;
- public IEnumerator<Tuple<string, S>> <>7__wrap4c;
- private int <>l__initialThreadId;
- public Tuple<string, S> <item>5__4b;
- public string[] arguments;
- public IElementLocation elementLocation;
- public string functionName;
- public bool includeNullEntries;
- public IEnumerable<Tuple<string, S>> itemsOfType;
-
- [DebuggerHidden]
- public <ClearMetadata>d__4a(int <>1__state)
- {
- this.<>1__state = <>1__state;
- this.<>l__initialThreadId = Thread.CurrentThread.ManagedThreadId;
- }
-
- private void <>m__Finally4d()
- {
- this.<>1__state = -1;
- if (this.<>7__wrap4c != null)
- {
- this.<>7__wrap4c.Dispose();
- }
- }
-
- private bool MoveNext()
- {
- bool flag;
- try
- {
- switch (this.<>1__state)
- {
- case 0:
- this.<>1__state = -1;
- ProjectErrorUtilities.VerifyThrowInvalidProject((this.arguments == null) || (this.arguments.Length == 0), this.elementLocation, "InvalidItemFunctionSyntax", this.functionName);
- this.<>7__wrap4c = this.itemsOfType.GetEnumerator();
- this.<>1__state = 1;
- goto Label_00C2;
-
- case 2:
- this.<>1__state = 1;
- goto Label_00C2;
-
- default:
- goto Label_00D5;
- }
- Label_006B:
- this.<item>5__4b = this.<>7__wrap4c.Current;
- if (this.includeNullEntries || (this.<item>5__4b.Item1 != null))
- {
- this.<>2__current = new Tuple<string, S>(this.<item>5__4b.Item1, default(S));
- this.<>1__state = 2;
- return true;
- }
- Label_00C2:
- if (this.<>7__wrap4c.MoveNext())
- {
- goto Label_006B;
- }
- this.<>m__Finally4d();
- Label_00D5:
- flag = false;
- }
- fault
- {
- this.System.IDisposable.Dispose();
- }
- return flag;
- }
-
- [DebuggerHidden]
- IEnumerator<Tuple<string, S>> IEnumerable<Tuple<string, S>>.GetEnumerator()
- {
- Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<ClearMetadata>d__4a d__a;
- if ((Thread.CurrentThread.ManagedThreadId == this.<>l__initialThreadId) && (this.<>1__state == -2))
- {
- this.<>1__state = 0;
- d__a = (Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<ClearMetadata>d__4a) this;
- }
- else
- {
- d__a = new Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<ClearMetadata>d__4a(0);
- }
- d__a.elementLocation = this.<>3__elementLocation;
- d__a.includeNullEntries = this.<>3__includeNullEntries;
- d__a.functionName = this.<>3__functionName;
- d__a.itemsOfType = this.<>3__itemsOfType;
- d__a.arguments = this.<>3__arguments;
- return d__a;
- }
-
- [DebuggerHidden]
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.System.Collections.Generic.IEnumerable<System.Tuple<System.String,S>>.GetEnumerator();
- }
-
- [DebuggerHidden]
- void IEnumerator.Reset()
- {
- throw new NotSupportedException();
- }
-
- void IDisposable.Dispose()
- {
- switch (this.<>1__state)
- {
- case 1:
- case 2:
- try
- {
- }
- finally
- {
- this.<>m__Finally4d();
- }
- return;
- }
- }
-
- Tuple<string, S> IEnumerator<Tuple<string, S>>.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
-
- object IEnumerator.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
- }
-
- [CompilerGenerated]
- private sealed class <DirectoryName>d__18 : IEnumerable<Tuple<string, S>>, IEnumerable, IEnumerator<Tuple<string, S>>, IEnumerator, IDisposable
- {
- private int <>1__state;
- private Tuple<string, S> <>2__current;
- public string[] <>3__arguments;
- public IElementLocation <>3__elementLocation;
- public string <>3__functionName;
- public bool <>3__includeNullEntries;
- public IEnumerable<Tuple<string, S>> <>3__itemsOfType;
- public IEnumerator<Tuple<string, S>> <>7__wrap1c;
- private int <>l__initialThreadId;
- public string <directoryName>5__1b;
- public Dictionary<string, string> <directoryNameTable>5__19;
- public Tuple<string, S> <item>5__1a;
- public string[] arguments;
- public IElementLocation elementLocation;
- public string functionName;
- public bool includeNullEntries;
- public IEnumerable<Tuple<string, S>> itemsOfType;
-
- [DebuggerHidden]
- public <DirectoryName>d__18(int <>1__state)
- {
- this.<>1__state = <>1__state;
- this.<>l__initialThreadId = Thread.CurrentThread.ManagedThreadId;
- }
-
- private void <>m__Finally1d()
- {
- this.<>1__state = -1;
- if (this.<>7__wrap1c != null)
- {
- this.<>7__wrap1c.Dispose();
- }
- }
-
- private bool MoveNext()
- {
- bool flag;
- try
- {
- switch (this.<>1__state)
- {
- case 0:
- this.<>1__state = -1;
- ProjectErrorUtilities.VerifyThrowInvalidProject((this.arguments == null) || (this.arguments.Length == 0), this.elementLocation, "InvalidItemFunctionSyntax", this.functionName);
- this.<directoryNameTable>5__19 = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
- this.<>7__wrap1c = this.itemsOfType.GetEnumerator();
- this.<>1__state = 1;
- goto Label_01F4;
-
- case 3:
- this.<>1__state = 1;
- goto Label_01F4;
-
- case 4:
- this.<>1__state = 1;
- goto Label_01F4;
-
- default:
- goto Label_020A;
- }
- Label_0088:
- this.<item>5__1a = this.<>7__wrap1c.Current;
- if (!string.IsNullOrEmpty(this.<item>5__1a.Item1))
- {
- this.<directoryName>5__1b = null;
- if (!this.<directoryNameTable>5__19.TryGetValue(this.<item>5__1a.Item1, out this.<directoryName>5__1b))
- {
- string path = EscapingUtilities.UnescapeAll(this.<item>5__1a.Item1);
- try
- {
- string str2;
- if (Path.IsPathRooted(path))
- {
- str2 = path;
- }
- else
- {
- string str3 = this.<item>5__1a.Item2.ProjectDirectory ?? string.Empty;
- str2 = Path.Combine(str3, path);
- }
- this.<directoryName>5__1b = Path.GetDirectoryName(str2);
- }
- catch (Exception exception)
- {
- if (ExceptionHandling.NotExpectedException(exception))
- {
- throw;
- }
- ProjectErrorUtilities.ThrowInvalidProject(this.elementLocation, "InvalidItemFunctionExpression", this.functionName, this.<item>5__1a.Item1, exception.Message);
- }
- this.<directoryName>5__1b = EscapingUtilities.Escape(this.<directoryName>5__1b);
- this.<directoryNameTable>5__19[path] = this.<directoryName>5__1b;
- }
- if (!string.IsNullOrEmpty(this.<directoryName>5__1b))
- {
- this.<>2__current = new Tuple<string, S>(this.<directoryName>5__1b, this.<item>5__1a.Item2);
- this.<>1__state = 3;
- return true;
- }
- if (this.includeNullEntries)
- {
- this.<>2__current = new Tuple<string, S>(null, this.<item>5__1a.Item2);
- this.<>1__state = 4;
- return true;
- }
- }
- Label_01F4:
- if (this.<>7__wrap1c.MoveNext())
- {
- goto Label_0088;
- }
- this.<>m__Finally1d();
- Label_020A:
- flag = false;
- }
- fault
- {
- this.System.IDisposable.Dispose();
- }
- return flag;
- }
-
- [DebuggerHidden]
- IEnumerator<Tuple<string, S>> IEnumerable<Tuple<string, S>>.GetEnumerator()
- {
- Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<DirectoryName>d__18 d__;
- if ((Thread.CurrentThread.ManagedThreadId == this.<>l__initialThreadId) && (this.<>1__state == -2))
- {
- this.<>1__state = 0;
- d__ = (Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<DirectoryName>d__18) this;
- }
- else
- {
- d__ = new Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<DirectoryName>d__18(0);
- }
- d__.elementLocation = this.<>3__elementLocation;
- d__.includeNullEntries = this.<>3__includeNullEntries;
- d__.functionName = this.<>3__functionName;
- d__.itemsOfType = this.<>3__itemsOfType;
- d__.arguments = this.<>3__arguments;
- return d__;
- }
-
- [DebuggerHidden]
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.System.Collections.Generic.IEnumerable<System.Tuple<System.String,S>>.GetEnumerator();
- }
-
- [DebuggerHidden]
- void IEnumerator.Reset()
- {
- throw new NotSupportedException();
- }
-
- void IDisposable.Dispose()
- {
- switch (this.<>1__state)
- {
- case 1:
- case 3:
- case 4:
- try
- {
- }
- finally
- {
- this.<>m__Finally1d();
- }
- break;
-
- case 2:
- break;
-
- default:
- return;
- }
- }
-
- Tuple<string, S> IEnumerator<Tuple<string, S>>.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
-
- object IEnumerator.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
- }
-
- [CompilerGenerated]
- private sealed class <DistinctWithComparer>d__2c : IEnumerable<Tuple<string, S>>, IEnumerable, IEnumerator<Tuple<string, S>>, IEnumerator, IDisposable
- {
- private int <>1__state;
- private Tuple<string, S> <>2__current;
- public string[] <>3__arguments;
- public StringComparer <>3__comparer;
- public IElementLocation <>3__elementLocation;
- public string <>3__functionName;
- public IEnumerable<Tuple<string, S>> <>3__itemsOfType;
- public IEnumerator<Tuple<string, S>> <>7__wrap2f;
- private int <>l__initialThreadId;
- public Tuple<string, S> <item>5__2e;
- public Dictionary<string, S> <seenItems>5__2d;
- public string[] arguments;
- public StringComparer comparer;
- public IElementLocation elementLocation;
- public string functionName;
- public IEnumerable<Tuple<string, S>> itemsOfType;
-
- [DebuggerHidden]
- public <DistinctWithComparer>d__2c(int <>1__state)
- {
- this.<>1__state = <>1__state;
- this.<>l__initialThreadId = Thread.CurrentThread.ManagedThreadId;
- }
-
- private void <>m__Finally30()
- {
- this.<>1__state = -1;
- if (this.<>7__wrap2f != null)
- {
- this.<>7__wrap2f.Dispose();
- }
- }
-
- private bool MoveNext()
- {
- bool flag;
- try
- {
- switch (this.<>1__state)
- {
- case 0:
- this.<>1__state = -1;
- ProjectErrorUtilities.VerifyThrowInvalidProject((this.arguments == null) || (this.arguments.Length == 0), this.elementLocation, "InvalidItemFunctionSyntax", this.functionName);
- this.<seenItems>5__2d = new Dictionary<string, S>(this.comparer);
- this.<>7__wrap2f = this.itemsOfType.GetEnumerator();
- this.<>1__state = 1;
- goto Label_0109;
-
- case 2:
- this.<>1__state = 1;
- goto Label_0109;
-
- default:
- goto Label_011F;
- }
- Label_007F:
- this.<item>5__2e = this.<>7__wrap2f.Current;
- if ((this.<item>5__2e.Item1 != null) && !this.<seenItems>5__2d.ContainsKey(this.<item>5__2e.Item1))
- {
- this.<seenItems>5__2d[this.<item>5__2e.Item1] = this.<item>5__2e.Item2;
- this.<>2__current = new Tuple<string, S>(this.<item>5__2e.Item1, this.<item>5__2e.Item2);
- this.<>1__state = 2;
- return true;
- }
- Label_0109:
- if (this.<>7__wrap2f.MoveNext())
- {
- goto Label_007F;
- }
- this.<>m__Finally30();
- Label_011F:
- flag = false;
- }
- fault
- {
- this.System.IDisposable.Dispose();
- }
- return flag;
- }
-
- [DebuggerHidden]
- IEnumerator<Tuple<string, S>> IEnumerable<Tuple<string, S>>.GetEnumerator()
- {
- Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<DistinctWithComparer>d__2c d__c;
- if ((Thread.CurrentThread.ManagedThreadId == this.<>l__initialThreadId) && (this.<>1__state == -2))
- {
- this.<>1__state = 0;
- d__c = (Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<DistinctWithComparer>d__2c) this;
- }
- else
- {
- d__c = new Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<DistinctWithComparer>d__2c(0);
- }
- d__c.elementLocation = this.<>3__elementLocation;
- d__c.functionName = this.<>3__functionName;
- d__c.itemsOfType = this.<>3__itemsOfType;
- d__c.arguments = this.<>3__arguments;
- d__c.comparer = this.<>3__comparer;
- return d__c;
- }
-
- [DebuggerHidden]
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.System.Collections.Generic.IEnumerable<System.Tuple<System.String,S>>.GetEnumerator();
- }
-
- [DebuggerHidden]
- void IEnumerator.Reset()
- {
- throw new NotSupportedException();
- }
-
- void IDisposable.Dispose()
- {
- switch (this.<>1__state)
- {
- case 1:
- case 2:
- try
- {
- }
- finally
- {
- this.<>m__Finally30();
- }
- return;
- }
- }
-
- Tuple<string, S> IEnumerator<Tuple<string, S>>.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
-
- object IEnumerator.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
- }
-
- [CompilerGenerated]
- private sealed class <ExecuteStringFunction>d__41 : IEnumerable<Tuple<string, S>>, IEnumerable, IEnumerator<Tuple<string, S>>, IEnumerator, IDisposable
- {
- private int <>1__state;
- private Tuple<string, S> <>2__current;
- public string[] <>3__arguments;
- public IElementLocation <>3__elementLocation;
- public Expander<P, I> <>3__expander;
- public string <>3__functionName;
- public bool <>3__includeNullEntries;
- public IEnumerable<Tuple<string, S>> <>3__itemsOfType;
- public IEnumerator<Tuple<string, S>> <>7__wrap46;
- private int <>l__initialThreadId;
- public Expander<P, I>.Function<P> <function>5__43;
- public string <include>5__45;
- public Tuple<string, S> <item>5__42;
- public object <result>5__44;
- public string[] arguments;
- public IElementLocation elementLocation;
- public Expander<P, I> expander;
- public string functionName;
- public bool includeNullEntries;
- public IEnumerable<Tuple<string, S>> itemsOfType;
-
- [DebuggerHidden]
- public <ExecuteStringFunction>d__41(int <>1__state)
- {
- this.<>1__state = <>1__state;
- this.<>l__initialThreadId = Thread.CurrentThread.ManagedThreadId;
- }
-
- private void <>m__Finally47()
- {
- this.<>1__state = -1;
- if (this.<>7__wrap46 != null)
- {
- this.<>7__wrap46.Dispose();
- }
- }
-
- private bool MoveNext()
- {
- bool flag;
- try
- {
- switch (this.<>1__state)
- {
- case 0:
- this.<>1__state = -1;
- this.<>7__wrap46 = this.itemsOfType.GetEnumerator();
- this.<>1__state = 1;
- goto Label_0152;
-
- case 2:
- this.<>1__state = 1;
- goto Label_0152;
-
- case 3:
- this.<>1__state = 1;
- goto Label_0152;
-
- default:
- goto Label_0168;
- }
- Label_0046:
- this.<item>5__42 = this.<>7__wrap46.Current;
- this.<function>5__43 = new Expander<P, I>.Function<P>(typeof(string), this.<item>5__42.Item1, this.<item>5__42.Item1, this.functionName, this.arguments, BindingFlags.InvokeMethod | BindingFlags.Public, string.Empty, this.expander.UsedUninitializedProperties);
- this.<result>5__44 = this.<function>5__43.Execute(this.<item>5__42.Item1, this.expander.properties, ExpanderOptions.ExpandAll, this.elementLocation);
- this.<include>5__45 = Expander<P, I>.PropertyExpander<P>.ConvertToString(this.<result>5__44);
- if (this.<include>5__45.Length > 0)
- {
- this.<>2__current = new Tuple<string, S>(this.<include>5__45, this.<item>5__42.Item2);
- this.<>1__state = 2;
- return true;
- }
- if (this.includeNullEntries)
- {
- this.<>2__current = new Tuple<string, S>(null, this.<item>5__42.Item2);
- this.<>1__state = 3;
- return true;
- }
- Label_0152:
- if (this.<>7__wrap46.MoveNext())
- {
- goto Label_0046;
- }
- this.<>m__Finally47();
- Label_0168:
- flag = false;
- }
- fault
- {
- this.System.IDisposable.Dispose();
- }
- return flag;
- }
-
- [DebuggerHidden]
- IEnumerator<Tuple<string, S>> IEnumerable<Tuple<string, S>>.GetEnumerator()
- {
- Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<ExecuteStringFunction>d__41 d__;
- if ((Thread.CurrentThread.ManagedThreadId == this.<>l__initialThreadId) && (this.<>1__state == -2))
- {
- this.<>1__state = 0;
- d__ = (Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<ExecuteStringFunction>d__41) this;
- }
- else
- {
- d__ = new Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<ExecuteStringFunction>d__41(0);
- }
- d__.expander = this.<>3__expander;
- d__.elementLocation = this.<>3__elementLocation;
- d__.includeNullEntries = this.<>3__includeNullEntries;
- d__.functionName = this.<>3__functionName;
- d__.itemsOfType = this.<>3__itemsOfType;
- d__.arguments = this.<>3__arguments;
- return d__;
- }
-
- [DebuggerHidden]
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.System.Collections.Generic.IEnumerable<System.Tuple<System.String,S>>.GetEnumerator();
- }
-
- [DebuggerHidden]
- void IEnumerator.Reset()
- {
- throw new NotSupportedException();
- }
-
- void IDisposable.Dispose()
- {
- switch (this.<>1__state)
- {
- case 1:
- case 2:
- case 3:
- try
- {
- }
- finally
- {
- this.<>m__Finally47();
- }
- return;
- }
- }
-
- Tuple<string, S> IEnumerator<Tuple<string, S>>.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
-
- object IEnumerator.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
- }
-
- [CompilerGenerated]
- private sealed class <ExpandQuotedExpressionFunction>d__39 : IEnumerable<Tuple<string, S>>, IEnumerable, IEnumerator<Tuple<string, S>>, IEnumerator, IDisposable
- {
- private int <>1__state;
- private Tuple<string, S> <>2__current;
- public string[] <>3__arguments;
- public IElementLocation <>3__elementLocation;
- public string <>3__functionName;
- public bool <>3__includeNullEntries;
- public IEnumerable<Tuple<string, S>> <>3__itemsOfType;
- public IEnumerator<Tuple<string, S>> <>7__wrap3d;
- private int <>l__initialThreadId;
- public string <include>5__3c;
- public Tuple<string, S> <item>5__3a;
- public Expander<P, I>.ItemExpander.MetadataMatchEvaluator <matchEvaluator>5__3b;
- public string[] arguments;
- public IElementLocation elementLocation;
- public string functionName;
- public bool includeNullEntries;
- public IEnumerable<Tuple<string, S>> itemsOfType;
-
- [DebuggerHidden]
- public <ExpandQuotedExpressionFunction>d__39(int <>1__state)
- {
- this.<>1__state = <>1__state;
- this.<>l__initialThreadId = Thread.CurrentThread.ManagedThreadId;
- }
-
- private void <>m__Finally3e()
- {
- this.<>1__state = -1;
- if (this.<>7__wrap3d != null)
- {
- this.<>7__wrap3d.Dispose();
- }
- }
-
- private bool MoveNext()
- {
- bool flag;
- try
- {
- switch (this.<>1__state)
- {
- case 0:
- this.<>1__state = -1;
- ProjectErrorUtilities.VerifyThrowInvalidProject((this.arguments != null) && (this.arguments.Length == 1), this.elementLocation, "InvalidItemFunctionSyntax", this.functionName);
- this.<>7__wrap3d = this.itemsOfType.GetEnumerator();
- this.<>1__state = 1;
- goto Label_0163;
-
- case 2:
- this.<>1__state = 1;
- goto Label_0163;
-
- case 3:
- this.<>1__state = 1;
- goto Label_0163;
-
- default:
- goto Label_0179;
- }
- Label_0072:
- this.<item>5__3a = this.<>7__wrap3d.Current;
- this.<include>5__3c = null;
- if (this.<item>5__3a.Item1 != null)
- {
- this.<matchEvaluator>5__3b = new Expander<P, I>.ItemExpander.MetadataMatchEvaluator(this.<item>5__3a.Item1, this.<item>5__3a.Item2, this.elementLocation);
- this.<include>5__3c = Expander<P, I>.RegularExpressions.ItemMetadataPattern.Replace(this.arguments[0], new MatchEvaluator(this.<matchEvaluator>5__3b.GetMetadataValueFromMatch));
- }
- if ((this.<include>5__3c != null) && (this.<include>5__3c.Length > 0))
- {
- this.<>2__current = new Tuple<string, S>(this.<include>5__3c, this.<item>5__3a.Item2);
- this.<>1__state = 2;
- return true;
- }
- if (this.includeNullEntries)
- {
- this.<>2__current = new Tuple<string, S>(null, this.<item>5__3a.Item2);
- this.<>1__state = 3;
- return true;
- }
- Label_0163:
- if (this.<>7__wrap3d.MoveNext())
- {
- goto Label_0072;
- }
- this.<>m__Finally3e();
- Label_0179:
- flag = false;
- }
- fault
- {
- this.System.IDisposable.Dispose();
- }
- return flag;
- }
-
- [DebuggerHidden]
- IEnumerator<Tuple<string, S>> IEnumerable<Tuple<string, S>>.GetEnumerator()
- {
- Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<ExpandQuotedExpressionFunction>d__39 d__;
- if ((Thread.CurrentThread.ManagedThreadId == this.<>l__initialThreadId) && (this.<>1__state == -2))
- {
- this.<>1__state = 0;
- d__ = (Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<ExpandQuotedExpressionFunction>d__39) this;
- }
- else
- {
- d__ = new Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<ExpandQuotedExpressionFunction>d__39(0);
- }
- d__.elementLocation = this.<>3__elementLocation;
- d__.includeNullEntries = this.<>3__includeNullEntries;
- d__.functionName = this.<>3__functionName;
- d__.itemsOfType = this.<>3__itemsOfType;
- d__.arguments = this.<>3__arguments;
- return d__;
- }
-
- [DebuggerHidden]
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.System.Collections.Generic.IEnumerable<System.Tuple<System.String,S>>.GetEnumerator();
- }
-
- [DebuggerHidden]
- void IEnumerator.Reset()
- {
- throw new NotSupportedException();
- }
-
- void IDisposable.Dispose()
- {
- switch (this.<>1__state)
- {
- case 1:
- case 2:
- case 3:
- try
- {
- }
- finally
- {
- this.<>m__Finally3e();
- }
- return;
- }
- }
-
- Tuple<string, S> IEnumerator<Tuple<string, S>>.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
-
- object IEnumerator.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
- }
-
- [CompilerGenerated]
- private sealed class <GetItemTupleEnumerator>d__a : IEnumerable<Tuple<string, S>>, IEnumerable, IEnumerator<Tuple<string, S>>, IEnumerator, IDisposable
- {
- private int <>1__state;
- private Tuple<string, S> <>2__current;
- public IEnumerable<S> <>3__itemsOfType;
- public IEnumerator<S> <>7__wrapc;
- private int <>l__initialThreadId;
- public S <item>5__b;
- public IEnumerable<S> itemsOfType;
-
- [DebuggerHidden]
- public <GetItemTupleEnumerator>d__a(int <>1__state)
- {
- this.<>1__state = <>1__state;
- this.<>l__initialThreadId = Thread.CurrentThread.ManagedThreadId;
- }
-
- private void <>m__Finallyd()
- {
- this.<>1__state = -1;
- if (this.<>7__wrapc != null)
- {
- this.<>7__wrapc.Dispose();
- }
- }
-
- private bool MoveNext()
- {
- bool flag;
- try
- {
- switch (this.<>1__state)
- {
- case 0:
- this.<>1__state = -1;
- this.<>7__wrapc = this.itemsOfType.GetEnumerator();
- this.<>1__state = 1;
- goto Label_0084;
-
- case 2:
- this.<>1__state = 1;
- goto Label_0084;
-
- default:
- goto Label_0097;
- }
- Label_003C:
- this.<item>5__b = this.<>7__wrapc.Current;
- this.<>2__current = new Tuple<string, S>(this.<item>5__b.EvaluatedIncludeEscaped, this.<item>5__b);
- this.<>1__state = 2;
- return true;
- Label_0084:
- if (this.<>7__wrapc.MoveNext())
- {
- goto Label_003C;
- }
- this.<>m__Finallyd();
- Label_0097:
- flag = false;
- }
- fault
- {
- this.System.IDisposable.Dispose();
- }
- return flag;
- }
-
- [DebuggerHidden]
- IEnumerator<Tuple<string, S>> IEnumerable<Tuple<string, S>>.GetEnumerator()
- {
- Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<GetItemTupleEnumerator>d__a _a;
- if ((Thread.CurrentThread.ManagedThreadId == this.<>l__initialThreadId) && (this.<>1__state == -2))
- {
- this.<>1__state = 0;
- _a = (Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<GetItemTupleEnumerator>d__a) this;
- }
- else
- {
- _a = new Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<GetItemTupleEnumerator>d__a(0);
- }
- _a.itemsOfType = this.<>3__itemsOfType;
- return _a;
- }
-
- [DebuggerHidden]
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.System.Collections.Generic.IEnumerable<System.Tuple<System.String,S>>.GetEnumerator();
- }
-
- [DebuggerHidden]
- void IEnumerator.Reset()
- {
- throw new NotSupportedException();
- }
-
- void IDisposable.Dispose()
- {
- switch (this.<>1__state)
- {
- case 1:
- case 2:
- try
- {
- }
- finally
- {
- this.<>m__Finallyd();
- }
- return;
- }
- }
-
- Tuple<string, S> IEnumerator<Tuple<string, S>>.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
-
- object IEnumerator.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
- }
-
- [CompilerGenerated]
- private sealed class <ItemSpecModifierFunction>d__10 : IEnumerable<Tuple<string, S>>, IEnumerable, IEnumerator<Tuple<string, S>>, IEnumerator, IDisposable
- {
- private int <>1__state;
- private Tuple<string, S> <>2__current;
- public string[] <>3__arguments;
- public IElementLocation <>3__elementLocation;
- public string <>3__functionName;
- public bool <>3__includeNullEntries;
- public IEnumerable<Tuple<string, S>> <>3__itemsOfType;
- public IEnumerator<Tuple<string, S>> <>7__wrap14;
- private int <>l__initialThreadId;
- public Tuple<string, S> <item>5__12;
- public CopyOnWriteDictionary<string, string> <itemSpecModifierTable>5__11;
- public string <result>5__13;
- public string[] arguments;
- public IElementLocation elementLocation;
- public string functionName;
- public bool includeNullEntries;
- public IEnumerable<Tuple<string, S>> itemsOfType;
-
- [DebuggerHidden]
- public <ItemSpecModifierFunction>d__10(int <>1__state)
- {
- this.<>1__state = <>1__state;
- this.<>l__initialThreadId = Thread.CurrentThread.ManagedThreadId;
- }
-
- private void <>m__Finally15()
- {
- this.<>1__state = -1;
- if (this.<>7__wrap14 != null)
- {
- this.<>7__wrap14.Dispose();
- }
- }
-
- private bool MoveNext()
- {
- bool flag;
- try
- {
- switch (this.<>1__state)
- {
- case 0:
- this.<>1__state = -1;
- ProjectErrorUtilities.VerifyThrowInvalidProject((this.arguments == null) || (this.arguments.Length == 0), this.elementLocation, "InvalidItemFunctionSyntax", this.functionName);
- this.<itemSpecModifierTable>5__11 = new CopyOnWriteDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
- this.<>7__wrap14 = this.itemsOfType.GetEnumerator();
- this.<>1__state = 1;
- goto Label_019E;
-
- case 3:
- this.<>1__state = 1;
- goto Label_019E;
-
- case 4:
- this.<>1__state = 1;
- goto Label_019E;
-
- default:
- goto Label_01B4;
- }
- Label_0086:
- this.<item>5__12 = this.<>7__wrap14.Current;
- if (!string.IsNullOrEmpty(this.<item>5__12.Item1))
- {
- this.<result>5__13 = null;
- try
- {
- string currentDirectory = this.<item>5__12.Item2.ProjectDirectory ?? Directory.GetCurrentDirectory();
- this.<result>5__13 = FileUtilities.ItemSpecModifiers.GetItemSpecModifier(currentDirectory, this.<item>5__12.Item1, this.functionName, ref this.<itemSpecModifierTable>5__11);
- }
- catch (Exception exception)
- {
- if (ExceptionHandling.NotExpectedException(exception))
- {
- throw;
- }
- ProjectErrorUtilities.ThrowInvalidProject(this.elementLocation, "InvalidItemFunctionExpression", this.functionName, this.<item>5__12.Item1, exception.Message);
- }
- if (!string.IsNullOrEmpty(this.<result>5__13))
- {
- this.<>2__current = new Tuple<string, S>(this.<result>5__13, this.<item>5__12.Item2);
- this.<>1__state = 3;
- return true;
- }
- if (this.includeNullEntries)
- {
- this.<>2__current = new Tuple<string, S>(null, this.<item>5__12.Item2);
- this.<>1__state = 4;
- return true;
- }
- }
- Label_019E:
- if (this.<>7__wrap14.MoveNext())
- {
- goto Label_0086;
- }
- this.<>m__Finally15();
- Label_01B4:
- flag = false;
- }
- fault
- {
- this.System.IDisposable.Dispose();
- }
- return flag;
- }
-
- [DebuggerHidden]
- IEnumerator<Tuple<string, S>> IEnumerable<Tuple<string, S>>.GetEnumerator()
- {
- Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<ItemSpecModifierFunction>d__10 d__;
- if ((Thread.CurrentThread.ManagedThreadId == this.<>l__initialThreadId) && (this.<>1__state == -2))
- {
- this.<>1__state = 0;
- d__ = (Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<ItemSpecModifierFunction>d__10) this;
- }
- else
- {
- d__ = new Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<ItemSpecModifierFunction>d__10(0);
- }
- d__.elementLocation = this.<>3__elementLocation;
- d__.includeNullEntries = this.<>3__includeNullEntries;
- d__.functionName = this.<>3__functionName;
- d__.itemsOfType = this.<>3__itemsOfType;
- d__.arguments = this.<>3__arguments;
- return d__;
- }
-
- [DebuggerHidden]
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.System.Collections.Generic.IEnumerable<System.Tuple<System.String,S>>.GetEnumerator();
- }
-
- [DebuggerHidden]
- void IEnumerator.Reset()
- {
- throw new NotSupportedException();
- }
-
- void IDisposable.Dispose()
- {
- switch (this.<>1__state)
- {
- case 1:
- case 3:
- case 4:
- try
- {
- }
- finally
- {
- this.<>m__Finally15();
- }
- break;
-
- case 2:
- break;
-
- default:
- return;
- }
- }
-
- Tuple<string, S> IEnumerator<Tuple<string, S>>.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
-
- object IEnumerator.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
- }
-
- [CompilerGenerated]
- private sealed class <Metadata>d__20 : IEnumerable<Tuple<string, S>>, IEnumerable, IEnumerator<Tuple<string, S>>, IEnumerator, IDisposable
- {
- private int <>1__state;
- private Tuple<string, S> <>2__current;
- public string[] <>3__arguments;
- public IElementLocation <>3__elementLocation;
- public string <>3__functionName;
- public bool <>3__includeNullEntries;
- public IEnumerable<Tuple<string, S>> <>3__itemsOfType;
- public IEnumerator<Tuple<string, S>> <>7__wrap26;
- public IEnumerator<string> <>7__wrap28;
- private int <>l__initialThreadId;
- public Tuple<string, S> <item>5__22;
- public string <itemSpec>5__25;
- public string <metadataName>5__21;
- public string <metadataValue>5__23;
- public IList<string> <splits>5__24;
- public string[] arguments;
- public IElementLocation elementLocation;
- public string functionName;
- public bool includeNullEntries;
- public IEnumerable<Tuple<string, S>> itemsOfType;
-
- [DebuggerHidden]
- public <Metadata>d__20(int <>1__state)
- {
- this.<>1__state = <>1__state;
- this.<>l__initialThreadId = Thread.CurrentThread.ManagedThreadId;
- }
-
- private void <>m__Finally27()
- {
- this.<>1__state = -1;
- if (this.<>7__wrap26 != null)
- {
- this.<>7__wrap26.Dispose();
- }
- }
-
- private void <>m__Finally29()
- {
- this.<>1__state = 1;
- if (this.<>7__wrap28 != null)
- {
- this.<>7__wrap28.Dispose();
- }
- }
-
- private bool MoveNext()
- {
- bool flag;
- try
- {
- switch (this.<>1__state)
- {
- case 0:
- this.<>1__state = -1;
- ProjectErrorUtilities.VerifyThrowInvalidProject((this.arguments != null) && (this.arguments.Length == 1), this.elementLocation, "InvalidItemFunctionSyntax", this.functionName);
- this.<metadataName>5__21 = this.arguments[0];
- this.<>7__wrap26 = this.itemsOfType.GetEnumerator();
- this.<>1__state = 1;
- goto Label_01F5;
-
- case 3:
- goto Label_0161;
-
- case 4:
- this.<>1__state = 1;
- goto Label_01F5;
-
- case 5:
- this.<>1__state = 1;
- goto Label_01F5;
-
- default:
- goto Label_020B;
- }
- Label_0088:
- this.<item>5__22 = this.<>7__wrap26.Current;
- if (this.<item>5__22.Item2 != null)
- {
- this.<metadataValue>5__23 = this.<item>5__22.Item2.GetMetadataValueEscaped(this.<metadataName>5__21);
- if (!string.IsNullOrEmpty(this.<metadataValue>5__23))
- {
- if (Expander<P, I>.invariantCompareInfo.IndexOf(this.<metadataValue>5__23, ';') < 0)
- {
- this.<>2__current = new Tuple<string, S>(this.<metadataValue>5__23, this.<item>5__22.Item2);
- this.<>1__state = 4;
- return true;
- }
- this.<splits>5__24 = ExpressionShredder.SplitSemiColonSeparatedList(this.<metadataValue>5__23);
- this.<>7__wrap28 = this.<splits>5__24.GetEnumerator();
- this.<>1__state = 2;
- while (this.<>7__wrap28.MoveNext())
- {
- this.<itemSpec>5__25 = this.<>7__wrap28.Current;
- this.<>2__current = new Tuple<string, S>(this.<itemSpec>5__25, this.<item>5__22.Item2);
- this.<>1__state = 3;
- return true;
- Label_0161:
- this.<>1__state = 2;
- }
- this.<>m__Finally29();
- }
- else if ((this.<metadataValue>5__23 != string.Empty) && this.includeNullEntries)
- {
- this.<>2__current = new Tuple<string, S>(this.<metadataValue>5__23, this.<item>5__22.Item2);
- this.<>1__state = 5;
- return true;
- }
- }
- Label_01F5:
- if (this.<>7__wrap26.MoveNext())
- {
- goto Label_0088;
- }
- this.<>m__Finally27();
- Label_020B:
- flag = false;
- }
- fault
- {
- this.System.IDisposable.Dispose();
- }
- return flag;
- }
-
- [DebuggerHidden]
- IEnumerator<Tuple<string, S>> IEnumerable<Tuple<string, S>>.GetEnumerator()
- {
- Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<Metadata>d__20 d__;
- if ((Thread.CurrentThread.ManagedThreadId == this.<>l__initialThreadId) && (this.<>1__state == -2))
- {
- this.<>1__state = 0;
- d__ = (Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<Metadata>d__20) this;
- }
- else
- {
- d__ = new Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<Metadata>d__20(0);
- }
- d__.elementLocation = this.<>3__elementLocation;
- d__.includeNullEntries = this.<>3__includeNullEntries;
- d__.functionName = this.<>3__functionName;
- d__.itemsOfType = this.<>3__itemsOfType;
- d__.arguments = this.<>3__arguments;
- return d__;
- }
-
- [DebuggerHidden]
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.System.Collections.Generic.IEnumerable<System.Tuple<System.String,S>>.GetEnumerator();
- }
-
- [DebuggerHidden]
- void IEnumerator.Reset()
- {
- throw new NotSupportedException();
- }
-
- void IDisposable.Dispose()
- {
- switch (this.<>1__state)
- {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- try
- {
- switch (this.<>1__state)
- {
- case 2:
- case 3:
- try
- {
- }
- finally
- {
- this.<>m__Finally29();
- }
- break;
- }
- }
- finally
- {
- this.<>m__Finally27();
- }
- break;
-
- default:
- return;
- }
- }
-
- Tuple<string, S> IEnumerator<Tuple<string, S>>.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
-
- object IEnumerator.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
- }
-
- [CompilerGenerated]
- private sealed class <Reverse>d__33 : IEnumerable<Tuple<string, S>>, IEnumerable, IEnumerator<Tuple<string, S>>, IEnumerator, IDisposable
- {
- private int <>1__state;
- private Tuple<string, S> <>2__current;
- public string[] <>3__arguments;
- public IElementLocation <>3__elementLocation;
- public string <>3__functionName;
- public IEnumerable<Tuple<string, S>> <>3__itemsOfType;
- public IEnumerator<Tuple<string, S>> <>7__wrap35;
- private int <>l__initialThreadId;
- public Tuple<string, S> <item>5__34;
- public string[] arguments;
- public IElementLocation elementLocation;
- public string functionName;
- public IEnumerable<Tuple<string, S>> itemsOfType;
-
- [DebuggerHidden]
- public <Reverse>d__33(int <>1__state)
- {
- this.<>1__state = <>1__state;
- this.<>l__initialThreadId = Thread.CurrentThread.ManagedThreadId;
- }
-
- private void <>m__Finally36()
- {
- this.<>1__state = -1;
- if (this.<>7__wrap35 != null)
- {
- this.<>7__wrap35.Dispose();
- }
- }
-
- private bool MoveNext()
- {
- bool flag;
- try
- {
- switch (this.<>1__state)
- {
- case 0:
- this.<>1__state = -1;
- ProjectErrorUtilities.VerifyThrowInvalidProject((this.arguments == null) || (this.arguments.Length == 0), this.elementLocation, "InvalidItemFunctionSyntax", this.functionName);
- this.<>7__wrap35 = this.itemsOfType.Reverse<Tuple<string, S>>().GetEnumerator();
- this.<>1__state = 1;
- goto Label_00B4;
-
- case 2:
- this.<>1__state = 1;
- goto Label_00B4;
-
- default:
- goto Label_00C7;
- }
- Label_0070:
- this.<item>5__34 = this.<>7__wrap35.Current;
- this.<>2__current = new Tuple<string, S>(this.<item>5__34.Item1, this.<item>5__34.Item2);
- this.<>1__state = 2;
- return true;
- Label_00B4:
- if (this.<>7__wrap35.MoveNext())
- {
- goto Label_0070;
- }
- this.<>m__Finally36();
- Label_00C7:
- flag = false;
- }
- fault
- {
- this.System.IDisposable.Dispose();
- }
- return flag;
- }
-
- [DebuggerHidden]
- IEnumerator<Tuple<string, S>> IEnumerable<Tuple<string, S>>.GetEnumerator()
- {
- Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<Reverse>d__33 d__;
- if ((Thread.CurrentThread.ManagedThreadId == this.<>l__initialThreadId) && (this.<>1__state == -2))
- {
- this.<>1__state = 0;
- d__ = (Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<Reverse>d__33) this;
- }
- else
- {
- d__ = new Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<Reverse>d__33(0);
- }
- d__.elementLocation = this.<>3__elementLocation;
- d__.functionName = this.<>3__functionName;
- d__.itemsOfType = this.<>3__itemsOfType;
- d__.arguments = this.<>3__arguments;
- return d__;
- }
-
- [DebuggerHidden]
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.System.Collections.Generic.IEnumerable<System.Tuple<System.String,S>>.GetEnumerator();
- }
-
- [DebuggerHidden]
- void IEnumerator.Reset()
- {
- throw new NotSupportedException();
- }
-
- void IDisposable.Dispose()
- {
- switch (this.<>1__state)
- {
- case 1:
- case 2:
- try
- {
- }
- finally
- {
- this.<>m__Finally36();
- }
- return;
- }
- }
-
- Tuple<string, S> IEnumerator<Tuple<string, S>>.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
-
- object IEnumerator.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
- }
-
- [CompilerGenerated]
- private sealed class <WithMetadataValue>d__50 : IEnumerable<Tuple<string, S>>, IEnumerable, IEnumerator<Tuple<string, S>>, IEnumerator, IDisposable
- {
- private int <>1__state;
- private Tuple<string, S> <>2__current;
- public string[] <>3__arguments;
- public IElementLocation <>3__elementLocation;
- public string <>3__functionName;
- public IEnumerable<Tuple<string, S>> <>3__itemsOfType;
- public IEnumerator<Tuple<string, S>> <>7__wrap55;
- private int <>l__initialThreadId;
- public Tuple<string, S> <item>5__53;
- public string <metadataName>5__51;
- public string <metadataValue>5__54;
- public string <metadataValueToFind>5__52;
- public string[] arguments;
- public IElementLocation elementLocation;
- public string functionName;
- public IEnumerable<Tuple<string, S>> itemsOfType;
-
- [DebuggerHidden]
- public <WithMetadataValue>d__50(int <>1__state)
- {
- this.<>1__state = <>1__state;
- this.<>l__initialThreadId = Thread.CurrentThread.ManagedThreadId;
- }
-
- private void <>m__Finally56()
- {
- this.<>1__state = -1;
- if (this.<>7__wrap55 != null)
- {
- this.<>7__wrap55.Dispose();
- }
- }
-
- private bool MoveNext()
- {
- bool flag;
- try
- {
- switch (this.<>1__state)
- {
- case 0:
- this.<>1__state = -1;
- ProjectErrorUtilities.VerifyThrowInvalidProject((this.arguments != null) && (this.arguments.Length == 2), this.elementLocation, "InvalidItemFunctionSyntax", this.functionName);
- this.<metadataName>5__51 = this.arguments[0];
- this.<metadataValueToFind>5__52 = this.arguments[1];
- this.<>7__wrap55 = this.itemsOfType.GetEnumerator();
- this.<>1__state = 1;
- goto Label_010F;
-
- case 2:
- this.<>1__state = 1;
- goto Label_010F;
-
- default:
- goto Label_0125;
- }
- Label_008A:
- this.<item>5__53 = this.<>7__wrap55.Current;
- this.<metadataValue>5__54 = this.<item>5__53.Item2.GetMetadataValue(this.<metadataName>5__51);
- if ((this.<metadataValue>5__54 != null) && string.Equals(this.<metadataValue>5__54, this.<metadataValueToFind>5__52, StringComparison.OrdinalIgnoreCase))
- {
- this.<>2__current = new Tuple<string, S>(this.<item>5__53.Item1, this.<item>5__53.Item2);
- this.<>1__state = 2;
- return true;
- }
- Label_010F:
- if (this.<>7__wrap55.MoveNext())
- {
- goto Label_008A;
- }
- this.<>m__Finally56();
- Label_0125:
- flag = false;
- }
- fault
- {
- this.System.IDisposable.Dispose();
- }
- return flag;
- }
-
- [DebuggerHidden]
- IEnumerator<Tuple<string, S>> IEnumerable<Tuple<string, S>>.GetEnumerator()
- {
- Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<WithMetadataValue>d__50 d__;
- if ((Thread.CurrentThread.ManagedThreadId == this.<>l__initialThreadId) && (this.<>1__state == -2))
- {
- this.<>1__state = 0;
- d__ = (Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<WithMetadataValue>d__50) this;
- }
- else
- {
- d__ = new Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.<WithMetadataValue>d__50(0);
- }
- d__.elementLocation = this.<>3__elementLocation;
- d__.functionName = this.<>3__functionName;
- d__.itemsOfType = this.<>3__itemsOfType;
- d__.arguments = this.<>3__arguments;
- return d__;
- }
-
- [DebuggerHidden]
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.System.Collections.Generic.IEnumerable<System.Tuple<System.String,S>>.GetEnumerator();
- }
-
- [DebuggerHidden]
- void IEnumerator.Reset()
- {
- throw new NotSupportedException();
- }
-
- void IDisposable.Dispose()
- {
- switch (this.<>1__state)
- {
- case 1:
- case 2:
- try
- {
- }
- finally
- {
- this.<>m__Finally56();
- }
- return;
- }
- }
-
- Tuple<string, S> IEnumerator<Tuple<string, S>>.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
-
- object IEnumerator.Current
- {
- [DebuggerHidden]
- get
- {
- return this.<>2__current;
- }
- }
- }
-
- public delegate IEnumerable<Tuple<string, S>> ItemTransformFunction(Expander<P, I> expander, IElementLocation elementLocation, bool includeNullEntries, string functionName, IEnumerable<Tuple<string, S>> itemsOfType, string[] arguments);
- }
-
- private class MetadataMatchEvaluator
- {
- private IElementLocation elementLocation;
- private string itemSpec;
- private IItem sourceOfMetadata;
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- internal MetadataMatchEvaluator(string itemSpec, IItem sourceOfMetadata, IElementLocation elementLocation)
- {
- this.itemSpec = itemSpec;
- this.sourceOfMetadata = sourceOfMetadata;
- this.elementLocation = elementLocation;
- }
-
- internal string GetMetadataValueFromMatch(Match match)
- {
- string str = match.Groups["NAME"].Value;
- ProjectErrorUtilities.VerifyThrowInvalidProject(match.Groups["ITEM_SPECIFICATION"].Length == 0, this.elementLocation, "QualifiedMetadataInTransformNotAllowed", match.Value, str);
- CopyOnWriteDictionary<string, string> cachedModifiers = new CopyOnWriteDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
- string metadataValueEscaped = null;
- try
- {
- if (FileUtilities.ItemSpecModifiers.IsDerivableItemSpecModifier(str))
- {
- string currentDirectory = this.sourceOfMetadata.ProjectDirectory ?? Directory.GetCurrentDirectory();
- return FileUtilities.ItemSpecModifiers.GetItemSpecModifier(currentDirectory, this.itemSpec, str, ref cachedModifiers);
- }
- metadataValueEscaped = this.sourceOfMetadata.GetMetadataValueEscaped(str);
- }
- catch (InvalidOperationException exception)
- {
- ProjectErrorUtilities.ThrowInvalidProject(this.elementLocation, "CannotEvaluateItemMetadata", str, exception.Message);
- }
- return metadataValueEscaped;
- }
- }
-
- internal class TransformFunction<S> where S: class, IItem
- {
- private string[] arguments;
- private IElementLocation elementLocation;
- private string functionName;
- private Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.ItemTransformFunction transform;
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- public TransformFunction(IElementLocation elementLocation, string functionName, Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.ItemTransformFunction transform, string[] arguments)
- {
- this.elementLocation = elementLocation;
- this.functionName = functionName;
- this.transform = transform;
- this.arguments = arguments;
- }
-
- public IEnumerable<Tuple<string, S>> Execute(Expander<P, I> expander, bool includeNullEntries, IEnumerable<Tuple<string, S>> itemsOfType)
- {
- return this.transform(expander, this.elementLocation, includeNullEntries, this.functionName, itemsOfType, this.arguments);
- }
-
- public string[] Arguments
- {
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.arguments;
- }
- }
-
- public IElementLocation ElementLocation
- {
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.elementLocation;
- }
- }
- }
- }
-
- private static class MetadataExpander
- {
- internal static string ExpandMetadataLeaveEscaped(string expression, IMetadataTable metadata, ExpanderOptions options)
- {
- if ((options & ExpanderOptions.ExpandMetadata) == ExpanderOptions.Invalid)
- {
- return expression;
- }
- if (expression.Length == 0)
- {
- return expression;
- }
- ErrorUtilities.VerifyThrow(metadata != null, "Cannot expand metadata without providing metadata");
- if (Expander<P, I>.invariantCompareInfo.IndexOf(expression, "%(", CompareOptions.Ordinal) == -1)
- {
- return expression;
- }
- string a = null;
- if (Expander<P, I>.invariantCompareInfo.IndexOf(expression, "@(", CompareOptions.Ordinal) == -1)
- {
- MetadataMatchEvaluator<P, I> evaluator = new MetadataMatchEvaluator<P, I>(metadata, options);
- a = Expander<P, I>.RegularExpressions.ItemMetadataPattern.Replace(expression, new MatchEvaluator(evaluator.ExpandSingleMetadata));
- }
- else
- {
- List<ExpressionShredder.ItemExpressionCapture> referencedItemExpressions = ExpressionShredder.GetReferencedItemExpressions(expression);
- if (((referencedItemExpressions != null) && (referencedItemExpressions.Count == 1)) && ((referencedItemExpressions[0].Value == expression) && (referencedItemExpressions[0].Separator == null)))
- {
- return expression;
- }
- StringBuilder candidate = new StringBuilder(expression.Length);
- int startIndex = 0;
- MetadataMatchEvaluator<P, I> evaluator2 = new MetadataMatchEvaluator<P, I>(metadata, options);
- if (referencedItemExpressions != null)
- {
- for (int i = 0; i < referencedItemExpressions.Count; i++)
- {
- string str2 = referencedItemExpressions[i].Value;
- string input = expression.Substring(startIndex, referencedItemExpressions[i].Index - startIndex);
- string str4 = Expander<P, I>.RegularExpressions.NonTransformItemMetadataPattern.Replace(input, new MatchEvaluator(evaluator2.ExpandSingleMetadata));
- candidate.Append(str4);
- if (referencedItemExpressions[i].Separator != null)
- {
- str2 = Expander<P, I>.RegularExpressions.NonTransformItemMetadataPattern.Replace(referencedItemExpressions[i].Value, new MatchEvaluator(evaluator2.ExpandSingleMetadata), -1, referencedItemExpressions[i].SeparatorStart);
- }
- candidate.Append(str2);
- startIndex = referencedItemExpressions[i].Index + referencedItemExpressions[i].Length;
- }
- }
- if (startIndex < expression.Length)
- {
- string str5 = expression.Substring(startIndex);
- string str6 = Expander<P, I>.RegularExpressions.NonTransformItemMetadataPattern.Replace(str5, new MatchEvaluator(evaluator2.ExpandSingleMetadata));
- candidate.Append(str6);
- }
- a = OpportunisticIntern.StringBuilderToString(candidate);
- }
- if (string.Equals(a, expression, StringComparison.Ordinal))
- {
- a = expression;
- }
- return a;
- }
-
- private class MetadataMatchEvaluator
- {
- private IMetadataTable metadata;
- private ExpanderOptions options;
-
- internal MetadataMatchEvaluator(IMetadataTable metadata, ExpanderOptions options)
- {
- this.metadata = metadata;
- this.options = options & ExpanderOptions.ExpandMetadata;
- ErrorUtilities.VerifyThrow(options != ExpanderOptions.Invalid, "Must be expanding metadata of some kind");
- }
-
- internal string ExpandSingleMetadata(Match itemMetadataMatch)
- {
- ErrorUtilities.VerifyThrow(itemMetadataMatch.Success, "Need a valid item metadata.");
- string name = itemMetadataMatch.Groups["NAME"].Value;
- string itemType = null;
- if (itemMetadataMatch.Groups["ITEM_SPECIFICATION"].Length > 0)
- {
- itemType = itemMetadataMatch.Groups["ITEM_TYPE"].Value;
- }
- string str3 = itemMetadataMatch.Value;
- bool flag = FileUtilities.ItemSpecModifiers.IsItemSpecModifier(name);
- if ((!flag || ((this.options & ExpanderOptions.ExpandBuiltInMetadata) == ExpanderOptions.Invalid)) && (flag || ((this.options & ExpanderOptions.ExpandCustomMetadata) == ExpanderOptions.Invalid)))
- {
- return str3;
- }
- return this.metadata.GetEscapedValue(itemType, name);
- }
- }
- }
-
- private static class PropertyExpander<T> where T: class, IProperty
- {
- internal static string ConvertToString(object valueToConvert)
- {
- if (valueToConvert == null)
- {
- return string.Empty;
- }
- if (valueToConvert.GetType() == typeof(string))
- {
- return (string) valueToConvert;
- }
- if (valueToConvert is IDictionary)
- {
- IDictionary dictionary = valueToConvert as IDictionary;
- StringBuilder candidate = new StringBuilder();
- foreach (DictionaryEntry entry in dictionary)
- {
- if (candidate.Length > 0)
- {
- candidate.Append(';');
- }
- candidate.Append(EscapingUtilities.Escape(Expander<P, I>.PropertyExpander<T>.ConvertToString(entry.Key)));
- candidate.Append('=');
- candidate.Append(EscapingUtilities.Escape(Expander<P, I>.PropertyExpander<T>.ConvertToString(entry.Value)));
- }
- return OpportunisticIntern.StringBuilderToString(candidate);
- }
- if (valueToConvert is IEnumerable)
- {
- StringBuilder builder2 = new StringBuilder();
- IEnumerable enumerable = (IEnumerable) valueToConvert;
- foreach (object obj2 in enumerable)
- {
- if (builder2.Length > 0)
- {
- builder2.Append(';');
- }
- builder2.Append(EscapingUtilities.Escape(Expander<P, I>.PropertyExpander<T>.ConvertToString(obj2)));
- }
- return OpportunisticIntern.StringBuilderToString(builder2);
- }
- return valueToConvert.ToString();
- }
-
- private static object ExpandMSBuildThisFileProperty(string propertyName, IElementLocation elementLocation)
- {
- if (!ReservedPropertyNames.IsReservedProperty(propertyName))
- {
- return string.Empty;
- }
- if (elementLocation.File.Length == 0)
- {
- return string.Empty;
- }
- string str = string.Empty;
- if (string.Equals(propertyName, "MSBuildThisFile", StringComparison.OrdinalIgnoreCase))
- {
- return Path.GetFileName(elementLocation.File);
- }
- if (string.Equals(propertyName, "MSBuildThisFileName", StringComparison.OrdinalIgnoreCase))
- {
- return Path.GetFileNameWithoutExtension(elementLocation.File);
- }
- if (string.Equals(propertyName, "MSBuildThisFileFullPath", StringComparison.OrdinalIgnoreCase))
- {
- return FileUtilities.NormalizePath(elementLocation.File);
- }
- if (string.Equals(propertyName, "MSBuildThisFileExtension", StringComparison.OrdinalIgnoreCase))
- {
- return Path.GetExtension(elementLocation.File);
- }
- if (string.Equals(propertyName, "MSBuildThisFileDirectory", StringComparison.OrdinalIgnoreCase))
- {
- return FileUtilities.EnsureTrailingSlash(Path.GetDirectoryName(elementLocation.File));
- }
- if (string.Equals(propertyName, "MSBuildThisFileDirectoryNoRoot", StringComparison.OrdinalIgnoreCase))
- {
- string directoryName = Path.GetDirectoryName(elementLocation.File);
- int length = Path.GetPathRoot(directoryName).Length;
- str = FileUtilities.EnsureNoLeadingSlash(FileUtilities.EnsureTrailingSlash(directoryName.Substring(length)));
- }
- return str;
- }
-
- internal static string ExpandPropertiesLeaveEscaped(string expression, IPropertyProvider<T> properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties)
- {
- return Expander<P, I>.PropertyExpander<T>.ConvertToString(Expander<P, I>.PropertyExpander<T>.ExpandPropertiesLeaveTypedAndEscaped(expression, properties, options, elementLocation, usedUninitializedProperties));
- }
-
- internal static object ExpandPropertiesLeaveTypedAndEscaped(string expression, IPropertyProvider<T> properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties)
- {
- if (((options & ExpanderOptions.ExpandProperties) == ExpanderOptions.Invalid) || string.IsNullOrEmpty(expression))
- {
- return expression;
- }
- ErrorUtilities.VerifyThrow(properties != null, "Cannot expand properties without providing properties");
- int startIndex = Expander<P, I>.invariantCompareInfo.IndexOf(expression, "$(", CompareOptions.Ordinal);
- if (startIndex == -1)
- {
- return expression;
- }
- List<object> list = null;
- object item = null;
- int num3 = 0;
- int length = expression.Length;
- while (startIndex != -1)
- {
- if (item != null)
- {
- if (list == null)
- {
- list = new List<object>(4);
- }
- list.Add(item);
- }
- bool potentialPropertyFunction = false;
- bool potentialRegistryFunction = false;
- if ((startIndex - num3) > 0)
- {
- if (list == null)
- {
- list = new List<object>(4);
- }
- list.Add(expression.Substring(num3, startIndex - num3));
- }
- num3 = startIndex;
- int num2 = Expander<P, I>.ScanForClosingParenthesis(expression, startIndex + 2, out potentialPropertyFunction, out potentialRegistryFunction);
- if (num2 == -1)
- {
- item = expression.Substring(startIndex, expression.Length - startIndex);
- num3 = expression.Length;
- }
- else
- {
- object propertyValue = null;
- if ((startIndex + 2) == num2)
- {
- propertyValue = string.Empty;
- }
- else if ((((expression.Length - (startIndex + 2)) > 9) && potentialRegistryFunction) && (Expander<P, I>.invariantCompareInfo.IndexOf(expression, "Registry:", startIndex + 2, 9, CompareOptions.OrdinalIgnoreCase) == (startIndex + 2)))
- {
- propertyValue = Expander<P, I>.PropertyExpander<T>.ExpandRegistryValue(expression.Substring(startIndex + 2, (num2 - startIndex) - 2), elementLocation);
- }
- else if (((num2 - (startIndex + 2)) == 0x4d) && (Expander<P, I>.invariantCompareInfo.IndexOf(expression, @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\VSTSDB@VSTSDBDirectory", startIndex + 2, 0x4d, CompareOptions.OrdinalIgnoreCase) == (startIndex + 2)))
- {
- propertyValue = string.Empty;
- }
- else if (((num2 - (startIndex + 2)) == 0x13) && string.Equals(expression, "$(Solutions.VSVersion)", StringComparison.Ordinal))
- {
- propertyValue = string.Empty;
- }
- else if (potentialPropertyFunction)
- {
- propertyValue = Expander<P, I>.PropertyExpander<T>.ExpandPropertyBody(expression.Substring(startIndex + 2, (num2 - startIndex) - 2), propertyValue, properties, options, elementLocation, usedUninitializedProperties);
- }
- else
- {
- propertyValue = Expander<P, I>.PropertyExpander<T>.LookupProperty(properties, expression, startIndex + 2, num2 - 1, elementLocation, usedUninitializedProperties);
- }
- item = propertyValue;
- num3 = num2 + 1;
- }
- startIndex = Expander<P, I>.invariantCompareInfo.IndexOf(expression, "$(", num3, CompareOptions.Ordinal);
- }
- if ((list == null) && (expression.Length == num3))
- {
- return item;
- }
- if (num3 == 0)
- {
- return expression;
- }
- StringBuilder candidate = new StringBuilder(expression.Length * 2);
- if (list != null)
- {
- foreach (object obj4 in list)
- {
- candidate.Append(obj4.ToString());
- }
- }
- if (item != null)
- {
- candidate.Append(item.ToString());
- }
- if ((expression.Length - num3) > 0)
- {
- candidate.Append(expression, num3, expression.Length - num3);
- }
- return OpportunisticIntern.StringBuilderToString(candidate);
- }
-
- internal static object ExpandPropertyBody(string propertyBody, object propertyValue, IPropertyProvider<T> properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties)
- {
- Expander<P, I>.Function<T> function = null;
- string expressionRootName = propertyBody;
- if (char.IsWhiteSpace(propertyBody[0]) || char.IsWhiteSpace(propertyBody[propertyBody.Length - 1]))
- {
- propertyBody = propertyBody.Trim();
- }
- if (!Expander<P, I>.IsValidPropertyName(propertyBody))
- {
- if (!propertyBody.Contains(".") && (propertyBody[0] != '['))
- {
- if ((propertyValue != null) || !propertyBody.Contains("["))
- {
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionPropertyExpression", propertyBody, string.Empty);
- return null;
- }
- int index = propertyBody.IndexOf('[');
- int num2 = propertyBody.IndexOf(']');
- if ((index >= 0) && (num2 >= 0))
- {
- propertyValue = Expander<P, I>.PropertyExpander<T>.LookupProperty(properties, propertyBody, 0, index - 1, elementLocation, usedUninitializedProperties);
- propertyBody = propertyBody.Substring(index);
- return Expander<P, I>.PropertyExpander<T>.ExpandPropertyBody(propertyBody, propertyValue, properties, options, elementLocation, usedUninitializedProperties);
- }
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionPropertyExpression", propertyBody, AssemblyResources.GetString("InvalidFunctionPropertyExpressionDetailMismatchedSquareBrackets"));
- }
- else
- {
- if (Environment.GetEnvironmentVariable("MSBUILDDEBUGEXPANSION") == "1")
- {
- Console.WriteLine("Expanding: {0}", propertyBody);
- }
- function = Expander<P, I>.Function<T>.ExtractPropertyFunction(propertyBody, elementLocation, propertyValue, usedUninitializedProperties);
- if (function == null)
- {
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionPropertyExpression", propertyBody, string.Empty);
- return null;
- }
- expressionRootName = function.ExpressionRootName;
- }
- }
- if (!string.IsNullOrEmpty(expressionRootName))
- {
- propertyValue = Expander<P, I>.PropertyExpander<T>.LookupProperty(properties, expressionRootName, elementLocation, usedUninitializedProperties);
- }
- if (function != null)
- {
- propertyValue = function.Execute(propertyValue, properties, options, elementLocation);
- }
- return propertyValue;
- }
-
- private static string ExpandRegistryValue(string registryExpression, IElementLocation elementLocation)
- {
- string str = registryExpression.Substring(9);
- int index = str.IndexOf('@');
- int length = str.LastIndexOf('@');
- ProjectErrorUtilities.VerifyThrowInvalidProject(index == length, elementLocation, "InvalidRegistryPropertyExpression", "$(" + registryExpression + ")", string.Empty);
- string escapedString = ((length == -1) || (length == (str.Length - 1))) ? null : str.Substring(length + 1);
- string str3 = (length != -1) ? str.Substring(0, length) : str;
- string str4 = string.Empty;
- if (str3 != null)
- {
- str3 = EscapingUtilities.UnescapeAll(str3);
- if (escapedString != null)
- {
- escapedString = EscapingUtilities.UnescapeAll(escapedString);
- }
- try
- {
- object valueToConvert = Registry.GetValue(str3, escapedString, null);
- if (valueToConvert != null)
- {
- return Expander<P, I>.PropertyExpander<T>.ConvertToString(valueToConvert);
- }
- str4 = string.Empty;
- }
- catch (Exception exception)
- {
- if (ExceptionHandling.NotExpectedRegistryException(exception))
- {
- throw;
- }
- ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidRegistryPropertyExpression", "$(" + registryExpression + ")", exception.Message);
- }
- }
- return str4;
- }
-
- private static object LookupProperty(IPropertyProvider<T> properties, string propertyName, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties)
- {
- return Expander<P, I>.PropertyExpander<T>.LookupProperty(properties, propertyName, 0, propertyName.Length - 1, elementLocation, usedUninitializedProperties);
- }
-
- private static object LookupProperty(IPropertyProvider<T> properties, string propertyName, int startIndex, int endIndex, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties)
- {
- T local = properties.GetProperty(propertyName, startIndex, endIndex);
- if ((local == null) && MSBuildNameIgnoreCaseComparer.Equals("MSBuild", propertyName, startIndex, 7))
- {
- if ((startIndex != 0) || (endIndex != propertyName.Length))
- {
- return Expander<P, I>.PropertyExpander<T>.ExpandMSBuildThisFileProperty(propertyName.Substring(startIndex, (endIndex - startIndex) + 1), elementLocation);
- }
- return Expander<P, I>.PropertyExpander<T>.ExpandMSBuildThisFileProperty(propertyName, elementLocation);
- }
- if (local == null)
- {
- if ((usedUninitializedProperties.Warn && (usedUninitializedProperties.CurrentlyEvaluatingPropertyElementName != null)) && !MSBuildNameIgnoreCaseComparer.Equals(usedUninitializedProperties.CurrentlyEvaluatingPropertyElementName, propertyName, startIndex, (endIndex - startIndex) + 1))
- {
- string key = propertyName.Substring(startIndex, (endIndex - startIndex) + 1);
- if (!usedUninitializedProperties.Properties.ContainsKey(key))
- {
- usedUninitializedProperties.Properties.Add(key, elementLocation);
- }
- }
- return string.Empty;
- }
- return local.EvaluatedValueEscaped;
- }
- }
-
- private static class RegularExpressions
- {
- internal static readonly Regex ItemMetadataPattern;
- private const string ItemMetadataSpecification = @"%\(\s* (?<ITEM_SPECIFICATION>(?<ITEM_TYPE>[A-Za-z_][A-Za-z_0-9\-]*)\s*\.\s*)? (?<NAME>[A-Za-z_][A-Za-z_0-9\-]*) \s*\)";
- internal const string ItemSpecificationGroup = "ITEM_SPECIFICATION";
- internal const string ItemTypeGroup = "ITEM_TYPE";
- private const string ItemVectorWithTransformLHS = @"@\(\s*[A-Za-z_][A-Za-z_0-9\-]*\s*->\s*'[^']*";
- private const string ItemVectorWithTransformRHS = @"[^']*'(\s*,\s*'[^']*')?\s*\)";
- internal const string NameGroup = "NAME";
- internal static readonly Regex NonTransformItemMetadataPattern;
-
- static RegularExpressions()
- {
- Expander<P, I>.RegularExpressions.ItemMetadataPattern = new Regex(@"%\(\s* (?<ITEM_SPECIFICATION>(?<ITEM_TYPE>[A-Za-z_][A-Za-z_0-9\-]*)\s*\.\s*)? (?<NAME>[A-Za-z_][A-Za-z_0-9\-]*) \s*\)", RegexOptions.IgnorePatternWhitespace | RegexOptions.ExplicitCapture);
- Expander<P, I>.RegularExpressions.NonTransformItemMetadataPattern = new Regex(@"((?<=@\(\s*[A-Za-z_][A-Za-z_0-9\-]*\s*->\s*'[^']*)%\(\s* (?<ITEM_SPECIFICATION>(?<ITEM_TYPE>[A-Za-z_][A-Za-z_0-9\-]*)\s*\.\s*)? (?<NAME>[A-Za-z_][A-Za-z_0-9\-]*) \s*\)(?![^']*'(\s*,\s*'[^']*')?\s*\))) | ((?<!@\(\s*[A-Za-z_][A-Za-z_0-9\-]*\s*->\s*'[^']*)%\(\s* (?<ITEM_SPECIFICATION>(?<ITEM_TYPE>[A-Za-z_][A-Za-z_0-9\-]*)\s*\.\s*)? (?<NAME>[A-Za-z_][A-Za-z_0-9\-]*) \s*\)(?=[^']*'(\s*,\s*'[^']*')?\s*\))) | ((?<!@\(\s*[A-Za-z_][A-Za-z_0-9\-]*\s*->\s*'[^']*)%\(\s* (?<ITEM_SPECIFICATION>(?<ITEM_TYPE>[A-Za-z_][A-Za-z_0-9\-]*)\s*\.\s*)? (?<NAME>[A-Za-z_][A-Za-z_0-9\-]*) \s*\)(?![^']*'(\s*,\s*'[^']*')?\s*\)))", RegexOptions.IgnorePatternWhitespace | RegexOptions.ExplicitCapture);
- }
- }
- }
- }
-