예제 #1
0
        //
        // Top node of grammar
        //    See grammar for how the following methods relate to each
        //    other.
        //
        private GenericExpressionNode Expr(string expression)
        {
            GenericExpressionNode node = BooleanTerm(expression);

            if (!lexer.IsNext(Token.TokenType.EndOfInput))
            {
                node = ExprPrime(expression, node);
            }

            #region REMOVE_COMPAT_WARNING
            // Check for potential change in behavior
            if (LoggingServices != null && !warnedForExpression &&
                node.PotentialAndOrConflict())
            {
                // We only want to warn once even if there multiple () sub expressions
                warnedForExpression = true;
                // Try to figure out where this expression was located
                string projectFile  = String.Empty;
                int    lineNumber   = 0;
                int    columnNumber = 0;
                if (this.conditionAttribute != null)
                {
                    projectFile = XmlUtilities.GetXmlNodeFile(this.conditionAttribute, String.Empty /* no project file if XML is purely in-memory */);
                    XmlSearcher.GetLineColumnByNode(this.conditionAttribute, out lineNumber, out columnNumber);
                }
                // Log a warning regarding the fact the expression may have been evaluated
                // incorrectly in earlier version of MSBuild
                LoggingServices.LogWarning(logBuildEventContext, new BuildEventFileInfo(projectFile, lineNumber, columnNumber), "ConditionMaybeEvaluatedIncorrectly", expression);
            }
            #endregion

            return(node);
        }
예제 #2
0
        /// <summary>
        /// Instantiates a new BuildEventFileInfo object using an XML node (presumably from the project
        /// file).  The reason this isn't just another constructor on BuildEventFileInfo is because
        /// BuildEventFileInfo.cs gets compiled into multiple assemblies (Engine and Conversion, at least),
        /// and not all of those assemblies have the code for XmlUtilities.
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <param name="defaultFile"></param>
        /// <returns></returns>
        /// <owner>RGoel</owner>
        internal static BuildEventFileInfo CreateBuildEventFileInfo(XmlNode xmlNode, string defaultFile)
        {
            ErrorUtilities.VerifyThrow(xmlNode != null, "Need Xml node.");

            // Get the file path out of the Xml node.
            int    line   = 0;
            int    column = 0;
            string file   = XmlUtilities.GetXmlNodeFile(xmlNode, String.Empty);

            if (file.Length == 0)
            {
                file = defaultFile;
            }
            else
            {
                // Compute the line number and column number of the XML node.
                XmlSearcher.GetLineColumnByNode(xmlNode, out line, out column);
            }

            return(new BuildEventFileInfo(file, line, column));
        }
예제 #3
0
        /// <summary>
        /// Creates an instance of this exception using rich error information.
        /// </summary>
        /// <remarks>This constructor is preferred over the basic constructors.</remarks>
        /// <owner>RGoel, SumedhK</owner>
        /// <param name="xmlNode">The XML node where the error is (can be null).</param>
        /// <param name="message">Error message for exception.</param>
        /// <param name="errorSubcategory">Error sub-category that describes the error (can be null).</param>
        /// <param name="errorCode">The error code (can be null).</param>
        /// <param name="helpKeyword">The F1-help keyword for the host IDE (can be null).</param>
        public InvalidProjectFileException
        (
            XmlNode xmlNode,
            string message,
            string errorSubcategory,
            string errorCode,
            string helpKeyword
        ) :
            base(message)
        {
            ErrorUtilities.VerifyThrowArgumentLength(message, nameof(message));

            if (xmlNode != null)
            {
                this.projectFile = XmlUtilities.GetXmlNodeFile(xmlNode, String.Empty /* no project file if XML is purely in-memory */);
                XmlSearcher.GetLineColumnByNode(xmlNode, out this.lineNumber, out this.columnNumber);
            }

            this.errorSubcategory = errorSubcategory;
            this.errorCode        = errorCode;
            this.helpKeyword      = helpKeyword;
        }
예제 #4
0
        /// <summary>
        /// Figure out the line and column number of the task XML node in the original
        /// project context
        /// </summary>
        internal void GetLineColumnOfXmlNode(int handleId, out int lineNumber, out int columnNumber)
        {
            TaskExecutionContext executionContext = GetTaskContextFromHandleId(handleId);

            XmlSearcher.GetLineColumnByNode(executionContext.TaskNode, out lineNumber, out columnNumber);
        }