/// <summary> /// Overload for one string format argument. /// </summary> /// <param name="xmlNode">The invalid project node (can be null).</param> /// <param name="resourceName">The resource string for the error message.</param> /// <param name="arg0"></param> internal static void ThrowInvalidProject ( IElementLocation elementLocation, string resourceName, object arg0 ) { VerifyThrowInvalidProject(false, null, elementLocation, resourceName, arg0); }
/// <summary> /// This method is used to flag errors in the project file being processed. /// Do NOT use this method in place of ErrorUtilities.VerifyThrow(), because /// ErrorUtilities.VerifyThrow() is used to flag internal/programming errors. /// </summary> /// <param name="condition">The condition to check.</param> /// <param name="xmlNode">The invalid project node (can be null).</param> /// <param name="resourceName">The resource string for the error message.</param> internal static void VerifyThrowInvalidProject ( bool condition, IElementLocation elementLocation, string resourceName ) { VerifyThrowInvalidProject(condition, null, elementLocation, resourceName); }
/// <summary> /// Verifies that a name is valid for the name of an item, property, or piece of metadata. /// If it isn't, throws an InvalidProjectException indicating the invalid character. /// </summary> /// <remarks> /// Note that our restrictions are more stringent than the XML Standard's restrictions. /// </remarks> internal static void VerifyThrowProjectValidElementName(string name, IElementLocation location) { ErrorUtilities.VerifyThrowArgumentLength(name, "name"); int firstInvalidCharLocation = LocateFirstInvalidElementNameCharacter(name); if (-1 != firstInvalidCharLocation) { ProjectErrorUtilities.ThrowInvalidProject(location, "NameInvalid", name, name[firstInvalidCharLocation]); } }
/// <summary> /// Overload for one string format argument. /// </summary> /// <param name="condition">The condition to check.</param> /// <param name="elementLocation">The <see cref="IElementLocation"/> of the element.</param> /// <param name="resourceName">The resource string for the error message.</param> /// <param name="arg0"></param> internal static void VerifyThrowInvalidProject <T1> ( bool condition, IElementLocation elementLocation, string resourceName, T1 arg0 ) { VerifyThrowInvalidProject(condition, null, elementLocation, resourceName, arg0); }
/// <summary> /// Overload for two string format arguments. /// </summary> /// <param name="elementLocation">The <see cref="IElementLocation"/> of the element.</param> /// <param name="resourceName">The resource string for the error message.</param> /// <param name="arg0"></param> /// <param name="arg1"></param> internal static void ThrowInvalidProject <T1, T2> ( IElementLocation elementLocation, string resourceName, T1 arg0, T2 arg1 ) { VerifyThrowInvalidProject(false, null, elementLocation, resourceName, arg0, arg1); }
private static void ThrowDriveEnumerationExceptionWithLoggingService(IElementLocation includeLocation, string filespecUnescaped) { ProjectErrorUtilities.ThrowInvalidProject( includeLocation, DriveEnumeratingWildcardMessageResourceName, filespecUnescaped, XMakeAttributes.include, XMakeElements.itemGroup, includeLocation.LocationString); }
/// <summary> /// Overload for three string format arguments. /// </summary> /// <param name="xmlNode">The invalid project node (can be null).</param> /// <param name="resourceName">The resource string for the error message.</param> /// <param name="arg0"></param> /// <param name="arg1"></param> /// <param name="arg2"></param> internal static void ThrowInvalidProject ( IElementLocation elementLocation, string resourceName, object arg0, object arg1, object arg2 ) { VerifyThrowInvalidProject(false, null, elementLocation, resourceName, arg0, arg1, arg2); }
internal static void ThrowInvalidProject <T1, T2, T3> ( IElementLocation elementLocation, string resourceName, T1 arg0, T2 arg1, T3 arg2 ) { ThrowInvalidProject(null, elementLocation, resourceName, arg0, arg1, arg2); }
/// <summary> /// Overload for three string format arguments. /// </summary> /// <param name="condition">The condition to check.</param> /// <param name="xmlNode">The invalid project node (can be null).</param> /// <param name="resourceName">The resource string for the error message.</param> /// <param name="arg0"></param> /// <param name="arg1"></param> /// <param name="arg2"></param> internal static void VerifyThrowInvalidProject ( bool condition, IElementLocation elementLocation, string resourceName, object arg0, object arg1, object arg2 ) { VerifyThrowInvalidProject(condition, null, elementLocation, resourceName, arg0, arg1, arg2); }
private void ProcessItemSpec(string rootDirectory, string itemSpec, IElementLocation itemSpecLocation, OperationBuilder builder) { builder.ItemSpec = new ItemSpec <P, I>(itemSpec, _outerExpander, itemSpecLocation, rootDirectory); foreach (ItemSpecFragment fragment in builder.ItemSpec.Fragments) { if (fragment is ItemSpec <P, I> .ItemExpressionFragment itemExpression) { AddReferencedItemLists(builder, itemExpression.Capture); } } }
/// <summary> /// Creates a new property /// </summary> /// <param name="name">The property name</param> /// <param name="value">The property value</param> /// <param name="source">The property source</param> public ToolsetPropertyDefinition(string name, string value, IElementLocation source) { ErrorUtilities.VerifyThrowArgumentLength(name, "name"); ErrorUtilities.VerifyThrowArgumentNull(source, "source"); // value can be the empty string but not null ErrorUtilities.VerifyThrowArgumentNull(value, "value"); _name = name; _value = value; _source = source; }
/// <summary> /// Throws an InvalidProjectFileException using the given data. /// /// PERF WARNING: calling a method that takes a variable number of arguments /// is expensive, because memory is allocated for the array of arguments -- do /// not call this method repeatedly in performance-critical scenarios /// /// </summary> /// <param name="errorSubCategoryResourceName">The resource string for the /// error sub-category (can be null).</param> /// <param name="xmlNode">The invalid project node (can be null).</param> /// <param name="resourceName">The resource string for the error message.</param> /// <param name="args">Extra arguments for formatting the error message.</param> private static void ThrowInvalidProject ( string errorSubCategoryResourceName, IElementLocation elementLocation, string resourceName, params object[] args ) { ErrorUtilities.VerifyThrowInternalNull(elementLocation, "elementLocation"); #if DEBUG if (errorSubCategoryResourceName != null) { ResourceUtilities.VerifyResourceStringExists(errorSubCategoryResourceName); } ResourceUtilities.VerifyResourceStringExists(resourceName); #endif string errorSubCategory = null; if (errorSubCategoryResourceName != null) { errorSubCategory = AssemblyResources.GetString(errorSubCategoryResourceName); } string errorCode; string helpKeyword; string message = ResourceUtilities.FormatResourceString(out errorCode, out helpKeyword, resourceName, args); Exception exceptionToThrow = new InvalidProjectFileException(elementLocation.File, elementLocation.Line, elementLocation.Column, 0 /* Unknown end line */, 0 /* Unknown end column */, message, errorSubCategory, errorCode, helpKeyword); if (!DebuggerManager.DebuggingEnabled) { throw exceptionToThrow; } try { throw exceptionToThrow; } catch (InvalidProjectFileException ex) { // To help out the user debugging their project, break into the debugger here. // That's because otherwise, since they're debugging our optimized code with JMC on, // they may not be able to break on this exception at all themselves. // Also, dump the exception information, as it's hard to see in optimized code. // Note that we use Trace as Debug.WriteLine is not compiled in release builds, which is // what we are in here. Trace.WriteLine(ex.ToString()); Debugger.Break(); throw; } }
/// <param name="itemSpec">The string containing item syntax</param> /// <param name="expander">Expects the expander to have a default item factory set</param> /// <param name="itemSpecLocation">The xml location the itemspec comes from</param> /// <param name="projectDirectory">The directory that the project is in.</param> /// <param name="expandProperties">Expand properties before breaking down fragments. Defaults to true</param> public ItemSpec( string itemSpec, Expander <P, I> expander, IElementLocation itemSpecLocation, string projectDirectory, bool expandProperties = true) { ItemSpecString = itemSpec; Expander = expander; ItemSpecLocation = itemSpecLocation; Fragments = BuildItemFragments(itemSpecLocation, projectDirectory, expandProperties); }
/// <summary> /// Overload for four string format arguments. /// </summary> /// <param name="condition">The condition to check.</param> /// <param name="elementLocation">The <see cref="IElementLocation"/> of the element.</param> /// <param name="resourceName">The resource string for the error message.</param> /// <param name="arg0"></param> /// <param name="arg1"></param> /// <param name="arg2"></param> /// <param name="arg3"></param> internal static void VerifyThrowInvalidProject <T1, T2, T3, T4> ( bool condition, IElementLocation elementLocation, string resourceName, T1 arg0, T2 arg1, T3 arg2, T4 arg3 ) { VerifyThrowInvalidProject(condition, null, elementLocation, resourceName, arg0, arg1, arg2, arg3); }
public void SerializationTest_SmallElementLocation() { IElementLocation location = ElementLocation.Create("file", 65535, 2); TranslationHelpers.GetWriteTranslator().Translate(ref location, ElementLocation.FactoryForDeserialization); IElementLocation deserializedLocation = null; TranslationHelpers.GetReadTranslator().Translate(ref deserializedLocation, ElementLocation.FactoryForDeserialization); Assert.AreEqual(location.File, deserializedLocation.File); Assert.AreEqual(location.Line, deserializedLocation.Line); Assert.AreEqual(location.Column, deserializedLocation.Column); Assert.IsTrue(location.GetType().FullName.Contains("SmallElementLocation")); }
public void Equality() { IElementLocation location1 = ElementLocation.Create("file", 65536, 65537); IElementLocation location2 = ElementLocation.Create("file", 0, 1); IElementLocation location3 = ElementLocation.Create("file", 0, 65537); IElementLocation location4 = ElementLocation.Create("file", 65536, 1); IElementLocation location5 = ElementLocation.Create("file", 0, 1); IElementLocation location6 = ElementLocation.Create("file", 65536, 65537); Assert.AreEqual(true, location1.Equals(location6)); Assert.AreEqual(true, location2.Equals(location5)); Assert.AreEqual(false, location3.Equals(location1)); Assert.AreEqual(false, location4.Equals(location2)); Assert.AreEqual(false, location4.Equals(location6)); }
/// <summary> /// This method is used to flag errors in the project file being processed. /// Do NOT use this method in place of ErrorUtilities.VerifyThrow(), because /// ErrorUtilities.VerifyThrow() is used to flag internal/programming errors. /// </summary> /// <param name="condition">The condition to check.</param> /// <param name="errorSubCategoryResourceName">The resource string for the /// error sub-category (can be null).</param> /// <param name="xmlNode">The invalid project node (can be null).</param> /// <param name="resourceName">The resource string for the error message.</param> internal static void VerifyThrowInvalidProject ( bool condition, string errorSubCategoryResourceName, IElementLocation elementLocation, string resourceName ) { if (!condition) { // PERF NOTE: explicitly passing null for the arguments array // prevents memory allocation ThrowInvalidProject(errorSubCategoryResourceName, elementLocation, resourceName, null); } }
/// <summary> /// Overload for one string format argument. /// </summary> /// <param name="condition">The condition to check.</param> /// <param name="errorSubCategoryResourceName">The resource string for the /// error sub-category (can be null).</param> /// <param name="xmlNode">The invalid project node (can be null).</param> /// <param name="resourceName">The resource string for the error message.</param> /// <param name="arg0"></param> internal static void VerifyThrowInvalidProject ( bool condition, string errorSubCategoryResourceName, IElementLocation elementLocation, string resourceName, object arg0 ) { // PERF NOTE: check the condition here instead of pushing it into // the ThrowInvalidProject() method, because that method always // allocates memory for its variable array of arguments if (!condition) { ThrowInvalidProject(errorSubCategoryResourceName, elementLocation, resourceName, arg0); } }
internal static string[] GetFileListUnescaped ( string directoryEscaped, string filespecEscaped, object loggingMechanism = null, IElementLocation excludeLocation = null ) { return(GetFileList( directoryEscaped, filespecEscaped, returnEscaped: false, forceEvaluateWildCards: false, excludeSpecsEscaped: null, fileMatcher: FileMatcher.Default, loggingMechanism: loggingMechanism, excludeLocation: excludeLocation)); }
internal static void LogTaskParameter( LoggingContext loggingContext, TaskParameterMessageKind messageKind, string itemType, IList items, bool logItemMetadata, IElementLocation location = null) { var args = CreateTaskParameterEventArgs( loggingContext.BuildEventContext, messageKind, itemType, items, logItemMetadata, DateTime.UtcNow, location?.Line ?? 0, location?.Column ?? 0); loggingContext.LogBuildEvent(args); }
private static void ThrowInvalidProject ( string errorSubCategoryResourceName, IElementLocation elementLocation, string resourceName, params object[] args ) { ErrorUtilities.VerifyThrowInternalNull(elementLocation, nameof(elementLocation)); #if DEBUG if (errorSubCategoryResourceName != null) { ResourceUtilities.VerifyResourceStringExists(errorSubCategoryResourceName); } ResourceUtilities.VerifyResourceStringExists(resourceName); #endif string errorSubCategory = errorSubCategoryResourceName is null ? null : AssemblyResources.GetString(errorSubCategoryResourceName); string message = ResourceUtilities.FormatResourceStringStripCodeAndKeyword(out string errorCode, out string helpKeyword, resourceName, args); throw new InvalidProjectFileException(elementLocation.File, elementLocation.Line, elementLocation.Column, 0 /* Unknown end line */, 0 /* Unknown end column */, message, errorSubCategory, errorCode, helpKeyword); }
/// <summary> /// Constructor /// </summary> public TaskHostTask(IElementLocation taskLocation, TaskLoggingContext taskLoggingContext, IBuildComponentHost buildComponentHost, IDictionary <string, string> taskHostParameters, LoadedType taskType, AppDomainSetup appDomainSetup) { ErrorUtilities.VerifyThrowInternalNull(taskType, "taskType"); _taskLocation = taskLocation; _taskLoggingContext = taskLoggingContext; _buildComponentHost = buildComponentHost; _taskType = taskType; _appDomainSetup = appDomainSetup; _taskHostParameters = taskHostParameters; _packetFactory = new NodePacketFactory(); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.LogMessage, LogMessagePacket.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.TaskHostTaskComplete, TaskHostTaskComplete.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeShutdown, NodeShutdown.FactoryForDeserialization, this); _packetReceivedEvent = new AutoResetEvent(false); _receivedPackets = new Queue <INodePacket>(); _taskHostLock = new Object(); _setParameters = new Dictionary <string, object>(); }
/// <summary> /// Overload for if there are more than four string format arguments. /// </summary> /// <param name="xmlNode">The invalid project node (can be null).</param> /// <param name="resourceName">The resource string for the error message.</param> internal static void ThrowInvalidProject ( IElementLocation elementLocation, string resourceName, params object[] args ) { ThrowInvalidProject(null, elementLocation, resourceName, args); }
/// <summary> /// Overload for four string format arguments. /// </summary> /// <param name="condition">The condition to check.</param> /// <param name="xmlNode">The invalid project node (can be null).</param> /// <param name="resourceName">The resource string for the error message.</param> /// <param name="arg0"></param> /// <param name="arg1"></param> /// <param name="arg2"></param> /// <param name="arg3"></param> internal static void VerifyThrowInvalidProject ( bool condition, IElementLocation elementLocation, string resourceName, object arg0, object arg1, object arg2, object arg3 ) { VerifyThrowInvalidProject(condition, null, elementLocation, resourceName, arg0, arg1, arg2, arg3); }
internal BuildEventFileInfo(IElementLocation location) : this(location.File, location.Line, location.Column) { }
/// <summary> /// Validates the given set of parameters, logging the appropriate errors as necessary. /// </summary> private static void VerifyThrowIdentityParametersValid(IDictionary <string, string> identityParameters, IElementLocation errorLocation, string taskName, string runtimeName, string architectureName) { // validate the task factory parameters if (identityParameters != null && identityParameters.Count > 0) { string runtime = null; if (identityParameters.TryGetValue(XMakeAttributes.runtime, out runtime)) { if (!XMakeAttributes.IsValidMSBuildRuntimeValue(runtime)) { ProjectErrorUtilities.ThrowInvalidProject ( errorLocation, "TaskLoadFailureInvalidTaskHostFactoryParameter", taskName, runtime, runtimeName, XMakeAttributes.MSBuildRuntimeValues.clr2, XMakeAttributes.MSBuildRuntimeValues.clr4, XMakeAttributes.MSBuildRuntimeValues.currentRuntime, XMakeAttributes.MSBuildRuntimeValues.any ); } } string architecture = null; if (identityParameters.TryGetValue(XMakeAttributes.architecture, out architecture)) { if (!XMakeAttributes.IsValidMSBuildArchitectureValue(architecture)) { ProjectErrorUtilities.ThrowInvalidProject ( errorLocation, "TaskLoadFailureInvalidTaskHostFactoryParameter", taskName, architecture, architectureName, XMakeAttributes.MSBuildArchitectureValues.x86, XMakeAttributes.MSBuildArchitectureValues.x64, XMakeAttributes.MSBuildArchitectureValues.currentArchitecture, XMakeAttributes.MSBuildArchitectureValues.any ); } } } }
private ItemExpressionFragment <P, I> ProcessItemExpression(string expression, IElementLocation elementLocation, out bool isItemListExpression) { isItemListExpression = false; // Code corresponds to Expander.ExpandSingleItemVectorExpressionIntoItems if (expression.Length == 0) { return(null); } var capture = Expander <P, I> .ExpandSingleItemVectorExpressionIntoExpressionCapture(expression, ExpanderOptions.ExpandItems, elementLocation); if (capture == null) { return(null); } isItemListExpression = true; return(new ItemExpressionFragment <P, I>(capture, expression, this)); }
/// <summary> /// Creates an instance of this class using the given location. /// This does not provide end-line or end-column information. /// This is the preferred overload. /// </summary> internal BuildEventFileInfo(IElementLocation location) : this(location.File, location.Line, location.Column) { // do nothing }
internal static void ValidateValidMetadataAsAttributeName(string name, string parentName, IElementLocation parentLocation) { if (!AttributeNameIsValidMetadataName(name)) { ProjectErrorUtilities.ThrowInvalidProject(parentLocation, "InvalidMetadataAsAttribute", name, parentName); } }
private static void ThrowDriveEnumerationExceptionWithEvaluationLoggingContext(IElementLocation importLocation, IElementLocation includeLocation, IElementLocation excludeLocation, string filespecUnescaped, string fileSpec, bool excludeFileSpecIsEmpty) { if (importLocation != null) { ProjectErrorUtilities.ThrowInvalidProject( importLocation, DriveEnumeratingWildcardMessageResourceName, filespecUnescaped, XMakeAttributes.project, XMakeElements.import); } else if (excludeFileSpecIsEmpty) { ProjectErrorUtilities.ThrowInvalidProject( includeLocation, DriveEnumeratingWildcardMessageResourceName, fileSpec, XMakeAttributes.include, XMakeElements.itemGroup); } else { ProjectErrorUtilities.ThrowInvalidProject( excludeLocation, DriveEnumeratingWildcardMessageResourceName, fileSpec, XMakeAttributes.exclude, XMakeElements.itemGroup); } }
private static void ThrowDriveEnumerationExceptionWithTargetLoggingContext(IElementLocation includeLocation, IElementLocation excludeLocation, bool excludeFileSpecIsEmpty, string filespecUnescaped, string fileSpec) { // The first condition is necessary to reach for both GetFileListEscaped calls // whenever the wildcarded Include attribute results in drive enumeration, and // the second condition is necessary to skip for the GetFileListUnescaped call // whenever the wildcarded Exclude attribute results in drive enumeration. if (excludeFileSpecIsEmpty && (includeLocation != null)) { ProjectErrorUtilities.ThrowInvalidProject( includeLocation, DriveEnumeratingWildcardMessageResourceName, filespecUnescaped, XMakeAttributes.include, XMakeElements.itemGroup); } // The first condition is necessary to reach for both GetFileListEscaped calls // whenever the wildcarded Exclude attribute results in drive enumeration, and // the second condition is necessary to reach for the GetFileListUnescaped call // (also when the wildcarded Exclude attribute results in drive enumeration). else if ((!excludeFileSpecIsEmpty) || (includeLocation == null)) { ProjectErrorUtilities.ThrowInvalidProject( excludeLocation, DriveEnumeratingWildcardMessageResourceName, fileSpec, XMakeAttributes.exclude, XMakeElements.itemGroup); } }
private static void LogDriveEnumerationWarningWithEvaluationLoggingContext(EvaluationLoggingContext evaluationLoggingContext, IElementLocation importLocation, bool excludeFileSpecIsEmpty, string filespecUnescaped, string fileSpec) { if (importLocation != null) { evaluationLoggingContext.LogWarning( DriveEnumeratingWildcardMessageResourceName, filespecUnescaped, XMakeAttributes.project, XMakeElements.import); } else if (excludeFileSpecIsEmpty) { evaluationLoggingContext.LogWarning( DriveEnumeratingWildcardMessageResourceName, fileSpec, XMakeAttributes.include, XMakeElements.itemGroup); } else { evaluationLoggingContext.LogWarning( DriveEnumeratingWildcardMessageResourceName, fileSpec, XMakeAttributes.exclude, XMakeElements.itemGroup); } }
internal static void ValidateValidMetadataAsAttributeName(string name, string parentName, IElementLocation parentLocation) { bool isKnownAttribute; bool isValidMetadataNameInAttribute; ProjectParser.CheckMetadataAsAttributeName(name, out isKnownAttribute, out isValidMetadataNameInAttribute); if (isKnownAttribute || !isValidMetadataNameInAttribute) { ProjectErrorUtilities.ThrowInvalidProject(parentLocation, "InvalidMetadataAsAttribute", name, parentName); } }
/// <summary> /// Constructor /// </summary> public TaskHostTask(IElementLocation taskLocation, TaskLoggingContext taskLoggingContext, IBuildComponentHost buildComponentHost, IDictionary<string, string> taskHostParameters, LoadedType taskType, AppDomainSetup appDomainSetup) { ErrorUtilities.VerifyThrowInternalNull(taskType, "taskType"); _taskLocation = taskLocation; _taskLoggingContext = taskLoggingContext; _buildComponentHost = buildComponentHost; _taskType = taskType; _appDomainSetup = appDomainSetup; _taskHostParameters = taskHostParameters; _packetFactory = new NodePacketFactory(); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.LogMessage, LogMessagePacket.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.TaskHostTaskComplete, TaskHostTaskComplete.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeShutdown, NodeShutdown.FactoryForDeserialization, this); _packetReceivedEvent = new AutoResetEvent(false); _receivedPackets = new Queue<INodePacket>(); _taskHostLock = new Object(); _setParameters = new Dictionary<string, object>(); }
private void AddItemReferences(string expression, OperationBuilder operationBuilder, IElementLocation elementLocation) { if (expression.Length == 0) { return; } else { ExpressionShredder.ItemExpressionCapture match = Expander <P, I> .ExpandSingleItemVectorExpressionIntoExpressionCapture( expression, ExpanderOptions.ExpandItems, elementLocation); if (match == null) { return; } AddReferencedItemLists(operationBuilder, match); } }
public IDisposable TrackCondition(IElementLocation location, string condition) { return(_shouldTrackElements ? new EvaluationFrame(this, CurrentLocation.WithFileLineAndCondition(location.File, location.Line, condition)) : null); }
private IEnumerable <ItemFragment> BuildItemFragments(IElementLocation itemSpecLocation, bool expandProperties) { var builder = ImmutableList.CreateBuilder <ItemFragment>(); // Code corresponds to Evaluator.CreateItemsFromInclude var evaluatedItemspecEscaped = ItemSpecString; if (string.IsNullOrEmpty(evaluatedItemspecEscaped)) { return(builder.ToImmutable()); } // STEP 1: Expand properties in Include if (expandProperties) { evaluatedItemspecEscaped = Expander.ExpandIntoStringLeaveEscaped(ItemSpecString, ExpanderOptions.ExpandProperties, itemSpecLocation); } // STEP 2: Split Include on any semicolons, and take each split in turn if (evaluatedItemspecEscaped.Length > 0) { var splitsEscaped = ExpressionShredder.SplitSemiColonSeparatedList(evaluatedItemspecEscaped); foreach (var splitEscaped in splitsEscaped) { // STEP 3: If expression is "@(x)" copy specified list with its metadata, otherwise just treat as string bool isItemListExpression; var itemReferenceFragment = ProcessItemExpression(splitEscaped, itemSpecLocation, out isItemListExpression); if (isItemListExpression) { builder.Add(itemReferenceFragment); } else { // The expression is not of the form "@(X)". Treat as string // Code corresponds to EngineFileUtilities.GetFileList var containsEscapedWildcards = EscapingUtilities.ContainsEscapedWildcards(splitEscaped); var containsRealWildcards = FileMatcher.HasWildcards(splitEscaped); // '*' is an illegal character to have in a filename. // todo file-system assumption on legal path characters: https://github.com/Microsoft/msbuild/issues/781 if (containsEscapedWildcards && containsRealWildcards) { // Just return the original string. builder.Add(new ValueFragment(splitEscaped, itemSpecLocation.File)); } else if (!containsEscapedWildcards && containsRealWildcards) { // Unescape before handing it to the filesystem. var filespecUnescaped = EscapingUtilities.UnescapeAll(splitEscaped); builder.Add(new GlobFragment(filespecUnescaped, itemSpecLocation.File)); } else { // No real wildcards means we just return the original string. Don't even bother // escaping ... it should already be escaped appropriately since it came directly // from the project file builder.Add(new ValueFragment(splitEscaped, itemSpecLocation.File)); } } } } return(builder.ToImmutable()); }
/// <summary> /// Overload for four string format arguments. /// </summary> /// <param name="condition">The condition to check.</param> /// <param name="errorSubCategoryResourceName">The resource string for the /// error sub-category (can be null).</param> /// <param name="xmlNode">The invalid project node (can be null).</param> /// <param name="resourceName">The resource string for the error message.</param> /// <param name="arg0"></param> /// <param name="arg1"></param> /// <param name="arg2"></param> /// <param name="arg3"></param> internal static void VerifyThrowInvalidProject ( bool condition, string errorSubCategoryResourceName, IElementLocation elementLocation, string resourceName, object arg0, object arg1, object arg2, object arg3 ) { // PERF NOTE: check the condition here instead of pushing it into // the ThrowInvalidProject() method, because that method always // allocates memory for its variable array of arguments if (!condition) { ThrowInvalidProject(errorSubCategoryResourceName, elementLocation, resourceName, arg0, arg1, arg2, arg3); } }
/// <summary> /// Validates the given set of parameters, logging the appropriate errors as necessary. /// </summary> private static void VerifyThrowIdentityParametersValid(IDictionary<string, string> identityParameters, IElementLocation errorLocation, string taskName, string runtimeName, string architectureName) { // validate the task factory parameters if (identityParameters != null && identityParameters.Count > 0) { string runtime = null; if (identityParameters.TryGetValue(XMakeAttributes.runtime, out runtime)) { if (!XMakeAttributes.IsValidMSBuildRuntimeValue(runtime)) { ProjectErrorUtilities.ThrowInvalidProject ( errorLocation, "TaskLoadFailureInvalidTaskHostFactoryParameter", taskName, runtime, runtimeName, XMakeAttributes.MSBuildRuntimeValues.clr2, XMakeAttributes.MSBuildRuntimeValues.clr4, XMakeAttributes.MSBuildRuntimeValues.currentRuntime, XMakeAttributes.MSBuildRuntimeValues.any ); } } string architecture = null; if (identityParameters.TryGetValue(XMakeAttributes.architecture, out architecture)) { if (!XMakeAttributes.IsValidMSBuildArchitectureValue(architecture)) { ProjectErrorUtilities.ThrowInvalidProject ( errorLocation, "TaskLoadFailureInvalidTaskHostFactoryParameter", taskName, architecture, architectureName, XMakeAttributes.MSBuildArchitectureValues.x86, XMakeAttributes.MSBuildArchitectureValues.x64, XMakeAttributes.MSBuildArchitectureValues.currentArchitecture, XMakeAttributes.MSBuildArchitectureValues.any ); } } } }