Beispiel #1
0
        public virtual void Display(object sender, MessageEventArgs mea)
        {
            string message = this.GetMessageString(sender, mea);

            if (null != message)
            {
            #if DEBUG
                Debugger.Log((int)mea.Level, this.shortAppName, string.Concat(message, "\n"));
            #endif
                Console.WriteLine(message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sends a message to the message delegate if there is one.
        /// </summary>
        /// <param name="mea">Message event arguments.</param>
        public void OnMessage(MessageEventArgs e)
        {
            WixErrorEventArgs errorEventArgs = e as WixErrorEventArgs;

            if (null != this.Message)
            {
                this.Message(this, e);
            }
            else if (null != errorEventArgs)
            {
                throw new WixException(errorEventArgs);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Sends a message to the message delegate if there is one.
        /// </summary>
        /// <param name="mea">Message event arguments.</param>
        public void OnMessage(MessageEventArgs mea)
        {
            if (mea is WixErrorEventArgs)
            {
                this.encounteredError = true;
            }

            if (null != this.MessageHandler)
            {
                this.MessageHandler(this, mea);
                if (MessageLevel.Error == mea.Level)
                {
                    this.encounteredError = true;
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Sends a message to the message delegate if there is one.
        /// </summary>
        /// <param name="mea">Message event arguments.</param>
        public void OnMessage(MessageEventArgs mea)
        {
            WixErrorEventArgs errorEventArgs = mea as WixErrorEventArgs;

            if (null != errorEventArgs)
            {
                this.encounteredError = true;
            }

            if (null != this.Message)
            {
                this.Message(this, mea);
                if (MessageLevel.Error == mea.Level)
                {
                    this.encounteredError = true;
                }
            }
            else if (null != errorEventArgs)
            {
                throw new WixException(errorEventArgs);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Sends a message to the message delegate if there is one.
        /// </summary>
        /// <param name="mea">Message event arguments.</param>
        public void OnMessage(MessageEventArgs e)
        {
            WixErrorEventArgs errorEventArgs = e as WixErrorEventArgs;

            if (null != errorEventArgs)
            {
                this.encounteredError = true;
            }

            if (null != this.MessageHandler)
            {
                this.MessageHandler(this, e);
                if (MessageLevel.Error == e.Level)
                {
                    this.encounteredError = true;
                }
            }
            else if (null != errorEventArgs)
            {
                throw new WixException(errorEventArgs);
            }
        }
 void decompiler_Message(object sender, MessageEventArgs mea)
 {
     System.Diagnostics.Debug.WriteLine(String.Format("Id: {0} Level:{1}", mea.Id, mea.Level));
     System.Diagnostics.Debug.WriteLine(mea);
 }
Beispiel #7
0
        /// <summary>
        /// Creates a properly formatted message string.
        /// </summary>
        /// <param name="messageLevel">Level of the message, as generated by MessageLevel(MessageEventArgs).</param>
        /// <param name="mea">Event arguments for the message.</param>
        /// <returns>String containing the formatted message.</returns>
        protected virtual string GenerateMessageString(MessageLevel messageLevel, MessageEventArgs mea)
        {
            if (null == mea)
            {
                throw new ArgumentNullException("mea");
            }

            if (MessageLevel.Nothing == messageLevel)
            {
                return String.Empty;
            }

            if (MessageLevel.Error == messageLevel)
            {
                this.encounteredError = true;
            }

            return String.Format(CultureInfo.InvariantCulture, mea.ResourceManager.GetString(mea.ResourceName), mea.MessageArgs);
        }
Beispiel #8
0
        /// <summary>
        /// Determines the level of this message, when taking into account warning-as-error, 
        /// warning level, verbosity level and message suppressed by the caller.
        /// </summary>
        /// <param name="mea">Event arguments for the message.</param>
        /// <returns>MessageLevel representing the level of this message.</returns>
        protected MessageLevel CalculateMessageLevel(MessageEventArgs mea)
        {
            if (null == mea)
            {
                throw new ArgumentNullException("mea");
            }

            MessageLevel messageLevel = MessageLevel.Nothing;

            if (mea is WixVerboseEventArgs)
            {
                if (this.showVerboseMessages)
                {
                    messageLevel = MessageLevel.Information;
                }
            }
            else if (mea is WixWarningEventArgs)
            {
                if (this.SuppressAllWarnings || this.suppressedWarnings.ContainsKey(mea.Id))
                {
                    messageLevel = MessageLevel.Nothing;
                }
                else if (this.WarningAsError || this.warningsAsErrors.ContainsKey(mea.Id))
                {
                    messageLevel = MessageLevel.Error;
                }
                else
                {
                    messageLevel = MessageLevel.Warning;
                }
            }
            else if (mea is WixErrorEventArgs)
            {
                messageLevel = MessageLevel.Error;
            }
            else if (mea is WixGenericMessageEventArgs)
            {
                messageLevel = mea.Level;
            }
            else
            {
                Debug.Assert(false, String.Format(CultureInfo.InvariantCulture, "Unknown MessageEventArgs type: {0}.", mea.GetType().ToString()));
            }

            mea.Level = messageLevel;
            return messageLevel;
        }
Beispiel #9
0
        public string GetMessageString(object sender, MessageEventArgs mea)
        {
            MessageLevel messageLevel = this.CalculateMessageLevel(mea);

            if (MessageLevel.Nothing != messageLevel)
            {
                return this.GenerateMessageString(messageLevel, mea);
            }
            else
            {
                return null;
            }
        }
Beispiel #10
0
        /// <summary>
        /// Sends a message to the message delegate if there is one.
        /// </summary>
        /// <param name="mea">Message event arguments.</param>
        private void OnMessage(MessageEventArgs mea)
        {
            WixErrorEventArgs errorEventArgs = mea as WixErrorEventArgs;

            if (null != this.Message)
            {
                this.Message(this, mea);
            }
            else if (null != errorEventArgs)
            {
                throw new WixException(errorEventArgs);
            }
        }
 /// <summary>
 /// Instantiate a new WixFatalErrorException.
 /// </summary>
 /// <param name="messageEventArgs">Message event args.</param>
 public WixFatalErrorException(MessageEventArgs messageEventArgs)
     : base(null, WixExceptionType.FatalError, null)
 {
     this.messageEventArgs = messageEventArgs;
 }
        /// <summary>
        /// Display a message to the console.
        /// </summary>
        /// <param name="sender">Sender of the message.</param>
        /// <param name="mea">Arguments for the message event.</param>
        public virtual void Display(object sender, MessageEventArgs mea)
        {
            MessageLevel messageLevel = this.CalculateMessageLevel(mea);
            if (MessageLevel.Nothing != messageLevel)
            {
                Console.WriteLine(this.GenerateMessageString(sender, messageLevel, mea));
            }

            // fatal errors immediately halt execution after displaying
            if (MessageLevel.FatalError == messageLevel)
            {
                throw new WixFatalErrorException(mea);
            }
        }
Beispiel #13
0
 /// <summary>
 /// Implements IMessageHandler to display error messages.
 /// </summary>
 /// <param name="mea">Message event arguments.</param>
 public void OnMessage(MessageEventArgs mea)
 {
     this.Display(this, mea);
 }
Beispiel #14
0
 /// <summary>
 /// Sends a message to the message delegate if there is one.
 /// </summary>
 /// <param name="mea">Message event arguments.</param>
 public void OnMessage(MessageEventArgs mea)
 {
     if (mea is WixError)
     {
         this.foundError = true;
     }
     if (null != this.Message)
     {
         this.Message(this, mea);
     }
 }
 /// <summary>
 /// Sends a message to the message delegate if there is one.
 /// </summary>
 /// <param name="mea">Message event arguments.</param>
 public void OnMessage(MessageEventArgs mea)
 {
     if (mea is WixError)
     {
         this.encounteredError = true;
     }
     if (null != this.MessageHandler)
     {
         this.MessageHandler(this, mea);
     }
 }
        /// <summary>
        /// Creates a properly formatted message string.
        /// </summary>
        /// <param name="sender">The object sending the message.</param>
        /// <param name="messageLevel">Level of the message, as generated by MessageLevel(MessageEventArgs).</param>
        /// <param name="mea">Event arguments for the message.</param>
        /// <returns>String containing the formatted message.</returns>
        protected string GenerateMessageString(object sender, MessageLevel messageLevel, MessageEventArgs mea)
        {
            if (null == mea)
            {
                throw new ArgumentNullException("mea");
            }

            if (MessageLevel.Nothing == messageLevel)
            {
                return String.Empty;
            }

            StringBuilder messageBuilder = new StringBuilder();

            string messageType = String.Empty;

            if (MessageLevel.Warning == messageLevel)
            {
                messageType = "warning";
            }
            else if (MessageLevel.Error == messageLevel)
            {
                this.lastErrorNumber = mea.Id;
                messageType = "error";
            }
            else if (MessageLevel.FatalError == messageLevel)
            {
                this.lastErrorNumber = mea.Id;
                messageType = "fatal error";
            }

            string message = String.Format(mea.ResourceManager.GetString(mea.ResourceName), mea.MessageArgs);
            string errorFileName = this.longAppName;
            ArrayList fileNames = new ArrayList();

            if (null != mea.SourceLineNumbers && 0 < mea.SourceLineNumbers.Count)
            {
                bool first = true;
                foreach (SourceLineNumber sln in mea.SourceLineNumbers)
                {
                    if (sln.HasLineNumber)
                    {
                        if (first)
                        {
                            first = false;
                            errorFileName = String.Format("{0}({1})", sln.FileName, sln.LineNumber);
                        }
                        fileNames.Add(String.Format("{0}: line {1}", sln.FileName, sln.LineNumber));
                    }
                    else
                    {
                        if (first)
                        {
                            first = false;
                            errorFileName = sln.FileName;
                        }
                        fileNames.Add(sln.FileName);
                    }
                }
            }

            if (MessageLevel.Information == messageLevel)
            {
                messageBuilder.AppendFormat("{0}", message);
            }
            else
            {
                messageBuilder.AppendFormat("{0} : {1} {2}{3:0000} : {4}", errorFileName, messageType, this.shortAppName, mea.Id, message);
            }

            if (this.sourceTrace)
            {
                if (0 == fileNames.Count)
                {
                    messageBuilder.AppendFormat("Source trace unavailable.{0}", Environment.NewLine);
                }
                else
                {
                    messageBuilder.AppendFormat("Source trace:{0}", Environment.NewLine);
                    foreach (string fileName in fileNames)
                    {
                        messageBuilder.AppendFormat("   at {0}{1}", fileName, Environment.NewLine);
                    }
                }

                messageBuilder.Append(Environment.NewLine);
            }

            return messageBuilder.ToString();
        }
        /// <summary>
        /// Determines the level of this message, when taking into account warning-as-error,
        /// warning level, verbosity level and message suppressed by the caller.
        /// </summary>
        /// <param name="mea">Event arguments for the message.</param>
        /// <returns>MessageLevel representing the level of this message.</returns>
        protected MessageLevel CalculateMessageLevel(MessageEventArgs mea)
        {
            if (null == mea)
            {
                throw new ArgumentNullException("mea");
            }

            MessageLevel messageLevel = MessageLevel.Nothing;

            if (mea is WixVerbose)
            {
                if (mea.Level >= (int)this.verbosityLevel)
                {
                    messageLevel = MessageLevel.Information;
                }
            }
            else if (mea is WixWarning)
            {
                if (this.suppressedWarnings.ContainsKey(mea.Id))
                {
                    return MessageLevel.Nothing;
                }

                if (mea.Level >= (int)this.warningLevel)
                {
                    if (this.warningAsError)
                    {
                        this.lastErrorNumber = mea.Id;
                        messageLevel = MessageLevel.Error;
                    }
                    else
                    {
                        messageLevel = MessageLevel.Warning;
                    }
                }
            }
            else if (mea is WixError)
            {
                this.lastErrorNumber = mea.Id;
                if ((int)ErrorLevel.Fatal == mea.Level)
                {
                    messageLevel = MessageLevel.FatalError;
                }
                else
                {
                    messageLevel = MessageLevel.Error;
                }
            }
            else
            {
                Debug.Assert(false, String.Format("Unknown MessageEventArgs type: {0}.", mea.GetType().ToString()));
            }

            return messageLevel;
        }
Beispiel #18
0
        /// <summary>
        /// Sends a message to the message delegate if there is one.
        /// </summary>
        /// <param name="mea">Message event arguments.</param>
        public void OnMessage(MessageEventArgs e)
        {
            WixErrorEventArgs errorEventArgs = e as WixErrorEventArgs;

            if (null != errorEventArgs)
            {
                this.encounteredError = true;
            }

            this.extension.OnMessage(e);
        }
Beispiel #19
0
 /// <summary>
 /// Sends a message to the message delegate if there is one.
 /// </summary>
 /// <param name="mea">Message event arguments.</param>
 private void OnMessage(MessageEventArgs mea)
 {
     if (null != this.Message)
     {
         this.Message(this, mea);
     }
 }
Beispiel #20
0
        /// <summary>
        /// Creates a properly formatted message string.
        /// </summary>
        /// <param name="messageLevel">Level of the message, as generated by MessageLevel(MessageEventArgs).</param>
        /// <param name="mea">Event arguments for the message.</param>
        /// <returns>String containing the formatted message.</returns>
        protected override string GenerateMessageString(MessageLevel messageLevel, MessageEventArgs mea)
        {
            string message = base.GenerateMessageString(messageLevel, mea);

            if (null == message)
            {
                return null;
            }

            StringBuilder messageBuilder = new StringBuilder();
            ArrayList fileNames = new ArrayList();
            string errorFileName = this.longAppName;
            string messageType = String.Empty;

            if (MessageLevel.Warning == messageLevel)
            {
                messageType = WixStrings.MessageType_Warning;
            }
            else if (MessageLevel.Error == messageLevel)
            {
                this.lastErrorNumber = mea.Id;
                messageType = WixStrings.MessageType_Error;
            }

            if (null != mea.SourceLineNumbers && 0 < mea.SourceLineNumbers.Count)
            {
                bool first = true;
                foreach (SourceLineNumber sln in mea.SourceLineNumbers)
                {
                    if (sln.HasLineNumber)
                    {
                        if (first)
                        {
                            first = false;
                            errorFileName = String.Format(CultureInfo.CurrentUICulture, WixStrings.Format_FirstLineNumber, sln.FileName, sln.LineNumber);
                        }

                        fileNames.Add(String.Format(CultureInfo.CurrentUICulture, WixStrings.Format_LineNumber, sln.FileName, sln.LineNumber));
                    }
                    else
                    {
                        if (first)
                        {
                            first = false;
                            errorFileName = sln.FileName;
                        }

                        fileNames.Add(sln.FileName);
                    }
                }
            }

            if (MessageLevel.Information == messageLevel)
            {
                messageBuilder.AppendFormat(WixStrings.Format_InfoMessage, message);
            }
            else
            {
                messageBuilder.AppendFormat(WixStrings.Format_NonInfoMessage, errorFileName, messageType, this.shortAppName, mea.Id, message);
            }

            if (this.SourceTrace)
            {
                if (0 == fileNames.Count)
                {
                    messageBuilder.AppendFormat(WixStrings.INF_SourceTraceUnavailable, Environment.NewLine);
                }
                else
                {
                    messageBuilder.AppendFormat(WixStrings.INF_SourceTrace, Environment.NewLine);
                    foreach (string fileName in fileNames)
                    {
                        messageBuilder.AppendFormat(WixStrings.INF_SourceTraceLocation, fileName, Environment.NewLine);
                    }
                }

                messageBuilder.Append(Environment.NewLine);
            }

            return messageBuilder.ToString();
        }
Beispiel #21
0
        /// <summary>
        /// Sends a message to the message delegate if there is one. WARNING: if warnings-as-errors is turned on, this won't stop the build on a warning.
        /// </summary>
        /// <param name="mea">Message event arguments.</param>
        private void OnMessage(MessageEventArgs mea)
        {
            WixErrorEventArgs errorEventArgs = mea as WixErrorEventArgs;

            if (null != this.Message)
            {
                lock (this.lockObject)
                {
                    if (null != errorEventArgs)
                    {
                        this.threadError = errorEventArgs.Id;
                    }
                    this.Message(this, mea);
                }
            }
            else if (null != errorEventArgs)
            {
                lock (this.lockObject)
                {
                    this.threadError = errorEventArgs.Id;
                }
                throw new WixException(errorEventArgs);
            }
        }
Beispiel #22
0
 /// <summary>
 /// Throws an exception for an error message event.
 /// </summary>
 /// <param name="mea">Message event arguments.</param>
 public static void OnMessage(MessageEventArgs e)
 {
     WixErrorEventArgs errorEventArgs = e as WixErrorEventArgs;
     if (null != errorEventArgs)
     {
         throw new WixException(errorEventArgs);
     }
 }
Beispiel #23
0
        /// <summary>
        /// Creates a properly formatted message string.
        /// </summary>
        /// <param name="sender">The object sending the message.</param>
        /// <param name="messageLevel">Level of the message, as generated by MessageLevel(MessageEventArgs).</param>
        /// <param name="mea">Event arguments for the message.</param>
        /// <returns>String containing the formatted message.</returns>
        protected string GenerateMessageString(object sender, MessageLevel messageLevel, MessageEventArgs mea)
        {
            if (null == mea)
            {
                throw new ArgumentNullException("mea");
            }

            if (MessageLevel.Nothing == messageLevel)
            {
                return(String.Empty);
            }

            StringBuilder messageBuilder = new StringBuilder();

            string messageType = String.Empty;

            if (MessageLevel.Warning == messageLevel)
            {
                messageType = "warning";
            }
            else if (MessageLevel.Error == messageLevel)
            {
                this.lastErrorNumber = mea.Id;
                messageType          = "error";
            }
            else if (MessageLevel.FatalError == messageLevel)
            {
                this.lastErrorNumber = mea.Id;
                messageType          = "fatal error";
            }

            string    message       = String.Format(mea.ResourceManager.GetString(mea.ResourceName), mea.MessageArgs);
            string    errorFileName = this.longAppName;
            ArrayList fileNames     = new ArrayList();

            if (null != mea.SourceLineNumbers && 0 < mea.SourceLineNumbers.Count)
            {
                bool first = true;
                foreach (SourceLineNumber sln in mea.SourceLineNumbers)
                {
                    if (sln.HasLineNumber)
                    {
                        if (first)
                        {
                            first         = false;
                            errorFileName = String.Format("{0}({1})", sln.FileName, sln.LineNumber);
                        }
                        fileNames.Add(String.Format("{0}: line {1}", sln.FileName, sln.LineNumber));
                    }
                    else
                    {
                        if (first)
                        {
                            first         = false;
                            errorFileName = sln.FileName;
                        }
                        fileNames.Add(sln.FileName);
                    }
                }
            }

            if (MessageLevel.Information == messageLevel)
            {
                messageBuilder.AppendFormat("{0}", message);
            }
            else
            {
                messageBuilder.AppendFormat("{0} : {1} {2}{3:0000} : {4}", errorFileName, messageType, this.shortAppName, mea.Id, message);
            }

            if (this.sourceTrace)
            {
                if (0 == fileNames.Count)
                {
                    messageBuilder.AppendFormat("Source trace unavailable.{0}", Environment.NewLine);
                }
                else
                {
                    messageBuilder.AppendFormat("Source trace:{0}", Environment.NewLine);
                    foreach (string fileName in fileNames)
                    {
                        messageBuilder.AppendFormat("   at {0}{1}", fileName, Environment.NewLine);
                    }
                }

                messageBuilder.Append(Environment.NewLine);
            }

            return(messageBuilder.ToString());
        }