示例#1
0
        /// <summary>
        /// Output an error message to the console.
        /// </summary>
        /// <param name="inspectorTestType">The type of inspector test.</param>
        /// <param name="node">The node that caused the error.</param>
        /// <param name="message">Detailed error message.</param>
        /// <param name="args">Additional formatted string arguments.</param>
        /// <returns>Returns true indicating that action should be taken on this error, and false if it should be ignored.</returns>
        private bool OnError(InspectorTestType inspectorTestType, XmlNode node, string message, params object[] args)
        {
            if (this.ignoreErrors.Contains(inspectorTestType)) // ignore the error
            {
                return(false);
            }

            // increase the error count
            this.errors++;

            // set the warning/error part of the message
            string warningError;

            if (this.errorsAsWarnings.Contains(inspectorTestType)) // error as warning
            {
                warningError = "warning";
            }
            else // normal error
            {
                warningError = "error";
            }

            if (null != node)
            {
                Console.WriteLine("{0}({1}) : {2} WXCP{3:0000} : {4} ({5})", this.sourceFile, ((IXmlLineInfo)node).LineNumber, warningError, (int)inspectorTestType, String.Format(CultureInfo.CurrentCulture, message, args), inspectorTestType.ToString());
            }
            else
            {
                string source = (null == this.sourceFile ? "wixcop.exe" : this.sourceFile);

                Console.WriteLine("{0} : {1} WXCP{2:0000} : {3} ({4})", source, warningError, (int)inspectorTestType, String.Format(CultureInfo.CurrentCulture, message, args), inspectorTestType.ToString());
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Instantiate a new Inspector class.
        /// </summary>
        /// <param name="errorsAsWarnings">Test errors to display as warnings.</param>
        /// <param name="indentationAmount">Indentation value to use when validating leading whitespace.</param>
        public Inspector(string[] errorsAsWarnings, string[] ignoreErrors, int indentationAmount)
        {
            this.errorsAsWarnings  = new Hashtable();
            this.ignoreErrors      = new Hashtable();
            this.indentationAmount = indentationAmount;

            if (null != errorsAsWarnings)
            {
                foreach (string error in errorsAsWarnings)
                {
                    InspectorTestType itt = GetInspectorTestType(error);

                    if (itt != InspectorTestType.Unknown)
                    {
                        this.errorsAsWarnings.Add(itt, null);
                    }
                    else // not a known InspectorTestType
                    {
                        this.OnError(InspectorTestType.InspectorTestTypeUnknown, null, "Unknown error type: '{0}'.", error);
                    }
                }
            }

            if (null != ignoreErrors)
            {
                foreach (string error in ignoreErrors)
                {
                    InspectorTestType itt = GetInspectorTestType(error);

                    if (itt != InspectorTestType.Unknown)
                    {
                        this.ignoreErrors.Add(itt, null);
                    }
                    else // not a known InspectorTestType
                    {
                        this.OnError(InspectorTestType.InspectorTestTypeUnknown, null, "Unknown error type: '{0}'.", error);
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Output an error message to the console.
        /// </summary>
        /// <param name="inspectorTestType">The type of inspector test.</param>
        /// <param name="node">The node that caused the error.</param>
        /// <param name="message">Detailed error message.</param>
        /// <param name="args">Additional formatted string arguments.</param>
        private void OnError(InspectorTestType inspectorTestType, XmlNode node, string message, params object[] args)
        {
            // increase the error count
            this.errors++;

            // set the warning/error part of the message
            string warningError;
            if (this.errorsAsWarnings.Contains(inspectorTestType)) // error as warning
            {
                warningError = "warning";
            }
            else // normal error
            {
                warningError = "error";
            }

            if (null != node)
            {
                Console.WriteLine("{0}({1}) : {2} WXCP{3:0000} : {4} ({5})", this.sourceFile, ((IXmlLineInfo)node).LineNumber, warningError, (int)inspectorTestType, String.Format(message, args), inspectorTestType.ToString());
            }
            else
            {
                string source = (null == this.sourceFile ? "wixcop.exe" : this.sourceFile);

                Console.WriteLine("{0} : {1} WXCP{2:0000} : {3} ({4})", source, warningError, (int)inspectorTestType, String.Format(message, args), inspectorTestType.ToString());
            }
        }