void EventSourceWarningRaised (object sender, BuildWarningEventArgs e)
		{
			string file = e.File;
			if (file != null)
				file = Path.GetFullPath (Path.Combine (basePath, file));
			results.Add (new MSBuildResult (true, file, e.LineNumber, e.ColumnNumber, e.Code, e.Message));
		}
 public override string FormatWarningEvent(BuildWarningEventArgs args)
 {
     return (string.Format(Resources.WARNING_MESSAGE.Replace(@"\t", "\t"),
                           trimPath(args.ProjectFile),
                           trimPath(args.File),
                           args.LineNumber, args.ColumnNumber, args.Message));
 }
        public void LogBuildEvents()
        {
            // This event should only be logged when OnlyLogCriticalEvents is off
            BuildMessageEventArgs messageEvent = new BuildMessageEventArgs("MyMessage", "HelpKeyword", "Sender", MessageImportance.High);

            // These three should be logged when OnlyLogCritical Events is on or off
            BuildWarningEventArgs warning = new BuildWarningEventArgs("SubCategoryForSchemaValidationErrors", "MSB4000", "file", 1, 2, 3, 4, "message", "help", "sender");
            BuildErrorEventArgs error = new BuildErrorEventArgs("SubCategoryForSchemaValidationErrors", "MSB4000", "file", 1, 2, 3, 4, "message", "help", "sender");
            ExternalProjectStartedEventArgs externalStartedEvent = new ExternalProjectStartedEventArgs("message", "help", "senderName", "projectFile", "targetNames");

            ProcessBuildEventHelper loggingService = (ProcessBuildEventHelper)ProcessBuildEventHelper.CreateLoggingService(LoggerMode.Synchronous, 1);

            // Verify when OnlyLogCriticalEvents is false
            LogandVerifyBuildEvent(messageEvent, loggingService);
            LogandVerifyBuildEvent(warning, loggingService);
            LogandVerifyBuildEvent(error, loggingService);
            LogandVerifyBuildEvent(externalStartedEvent, loggingService);

            // Verify when OnlyLogCriticalEvents is true
            loggingService.OnlyLogCriticalEvents = true;
            loggingService.LogBuildEvent(messageEvent);
            Assert.IsNull(loggingService.ProcessedBuildEvent, "Expected ProcessedBuildEvent to be null");
            LogandVerifyBuildEvent(warning, loggingService);
            LogandVerifyBuildEvent(error, loggingService);
            LogandVerifyBuildEvent(externalStartedEvent, loggingService);
        }
示例#4
0
        /// <summary>
        /// Logs a warning event for the current task
        /// Thread safe.
        /// </summary>
        /// <param name="e">The event args</param>
        public void LogWarningEvent(Microsoft.Build.Framework.BuildWarningEventArgs e)
        {
            lock (_callbackMonitor)
            {
                ErrorUtilities.VerifyThrowArgumentNull(e, "e");

                if (!_activeProxy)
                {
                    // The task has been logging on another thread, typically
                    // because of logging a spawned process's output, and has
                    // not terminated this logging before it returned. This is common
                    // enough that we don't want to crash and break the entire build. But
                    // we don't have any good way to log it any more, as not only has this task
                    // finished, the whole build might have finished! The task author will
                    // just have to figure out that their task has a bug by themselves.
                    if (s_breakOnLogAfterTaskReturns)
                    {
                        Trace.Fail(String.Format(CultureInfo.CurrentUICulture, "Task at {0}, after already returning, attempted to log '{1}'", _taskLocation.ToString(), e.Message));
                    }

                    return;
                }

                // If we are in building across process we need the events to be serializable. This method will
                // check to see if we are building with multiple process and if the event is serializable. It will
                // also log a warning if the event is not serializable and drop the logging message.
                if (IsRunningMultipleNodes && !IsEventSerializable(e))
                {
                    return;
                }

                e.BuildEventContext = _taskLoggingContext.BuildEventContext;
                _taskLoggingContext.LoggingService.LogBuildEvent(e);
            }
        }
示例#5
0
 public override bool Execute()
 {
     var message = "CustomTask version is " + GetType().Assembly.GetName().Version;
     var args = new BuildWarningEventArgs("", "", "", 0, 0, 0, 0, message, "", "CustomTask");
     BuildEngine.LogWarningEvent(args);
     return true;
 }
示例#6
0
        public void VerifyEventType()
        {
            BuildFinishedEventArgs buildFinished = new BuildFinishedEventArgs("Message", "Keyword", true);
            BuildStartedEventArgs buildStarted = new BuildStartedEventArgs("Message", "Help");
            BuildMessageEventArgs lowMessage = new BuildMessageEventArgs("Message", "help", "sender", MessageImportance.Low);
            TaskStartedEventArgs taskStarted = new TaskStartedEventArgs("message", "help", "projectFile", "taskFile", "taskName");
            TaskFinishedEventArgs taskFinished = new TaskFinishedEventArgs("message", "help", "projectFile", "taskFile", "taskName", true);
            TaskCommandLineEventArgs commandLine = new TaskCommandLineEventArgs("commandLine", "taskName", MessageImportance.Low);
            BuildWarningEventArgs warning = new BuildWarningEventArgs("SubCategoryForSchemaValidationErrors", "MSB4000", "file", 1, 2, 3, 4, "message", "help", "sender");
            BuildErrorEventArgs error = new BuildErrorEventArgs("SubCategoryForSchemaValidationErrors", "MSB4000", "file", 1, 2, 3, 4, "message", "help", "sender");
            TargetStartedEventArgs targetStarted = new TargetStartedEventArgs("message", "help", "targetName", "ProjectFile", "targetFile");
            TargetFinishedEventArgs targetFinished = new TargetFinishedEventArgs("message", "help", "targetName", "ProjectFile", "targetFile", true);
            ProjectStartedEventArgs projectStarted = new ProjectStartedEventArgs(-1, "message", "help", "ProjectFile", "targetNames", null, null, null);
            ProjectFinishedEventArgs projectFinished = new ProjectFinishedEventArgs("message", "help", "ProjectFile", true);
            ExternalProjectStartedEventArgs externalStartedEvent = new ExternalProjectStartedEventArgs("message", "help", "senderName", "projectFile", "targetNames");

            VerifyLoggingPacket(buildFinished, LoggingEventType.BuildFinishedEvent);
            VerifyLoggingPacket(buildStarted, LoggingEventType.BuildStartedEvent);
            VerifyLoggingPacket(lowMessage, LoggingEventType.BuildMessageEvent);
            VerifyLoggingPacket(taskStarted, LoggingEventType.TaskStartedEvent);
            VerifyLoggingPacket(taskFinished, LoggingEventType.TaskFinishedEvent);
            VerifyLoggingPacket(commandLine, LoggingEventType.TaskCommandLineEvent);
            VerifyLoggingPacket(warning, LoggingEventType.BuildWarningEvent);
            VerifyLoggingPacket(error, LoggingEventType.BuildErrorEvent);
            VerifyLoggingPacket(targetStarted, LoggingEventType.TargetStartedEvent);
            VerifyLoggingPacket(targetFinished, LoggingEventType.TargetFinishedEvent);
            VerifyLoggingPacket(projectStarted, LoggingEventType.ProjectStartedEvent);
            VerifyLoggingPacket(projectFinished, LoggingEventType.ProjectFinishedEvent);
            VerifyLoggingPacket(externalStartedEvent, LoggingEventType.CustomEvent);
        }
		public void AssignmentTest ()
		{
			BuildWarningEventArgs bwea;
			string subcategory = "subcategory";
			string code = "CS0000";
			string file = "file";
			int lineNumber = 1;
			int columnNumber = 2;
			int endLineNumber = 3;
			int endColumnNumber = 4;
			string message = "message";
			string helpKeyword = "helpKeyword";
			string senderName = "senderName";
			
			bwea = new BuildWarningEventArgs (subcategory, code, file, lineNumber, columnNumber, endLineNumber,
				endColumnNumber, message, helpKeyword, senderName);
			
			Assert.AreEqual (subcategory, bwea.Subcategory, "Subcategory");
			Assert.AreEqual (code, bwea.Code, "Code");
			Assert.AreEqual (file, bwea.File, "File");
			Assert.AreEqual (lineNumber, bwea.LineNumber, "LineNumber");
			Assert.AreEqual (columnNumber, bwea.ColumnNumber, "ColumnNumber");
			Assert.AreEqual (endLineNumber, bwea.EndLineNumber, "EndLineNumber");
			Assert.AreEqual (endColumnNumber, bwea.EndColumnNumber, "EndColumnNumber");
			Assert.AreEqual (message, bwea.Message, "Message");
			Assert.AreEqual (helpKeyword, bwea.HelpKeyword, "HelpKeyword");
			Assert.AreEqual (senderName, bwea.SenderName, "SenderName");
		}
示例#8
0
        /// <summary>
        /// Format the warning message and all the other event data into a
        /// single string.
        /// </summary>
        /// <owner>t-jeffv, sumedhk</owner>
        /// <param name="e">Warning to format</param>
        /// <returns>The formatted message string.</returns>
        internal static string FormatEventMessage(BuildWarningEventArgs e, bool removeCarriageReturn)
        {
            ErrorUtilities.VerifyThrowArgumentNull(e, "e");

            // "warning" should not be localized
            return FormatEventMessage("warning", e.Subcategory, removeCarriageReturn ? EscapeCarriageReturn(e.Message) : e.Message,
                           e.Code, e.File, e.LineNumber, e.EndLineNumber,
                           e.ColumnNumber, e.EndColumnNumber, e.ThreadId);
        }
示例#9
0
		void EventSourceWarningRaised (object sender, BuildWarningEventArgs e)
		{
			//NOTE: as of Mono 3.2.7, e.ProjectFile does not exist, so we use our projectFile variable instead
			results.Add (new MSBuildTargetResult (
				projectFile, true, e.Subcategory, e.Code, e.File,
				e.LineNumber, e.ColumnNumber, e.ColumnNumber, e.EndLineNumber,
				e.Message, e.HelpKeyword)
			);
		}
示例#10
0
 private void HandleWarningRaised(object sender, BuildWarningEventArgs e)
 {
     var fullPath = m_projectDirectory != null ? Path.Combine(m_projectDirectory, e.File) : e.File;
     if (e.Code != null)
     {
         Console.WriteLine("{0}:{1}:{2}: Warning: {3}", fullPath, e.LineNumber, e.ColumnNumber, e.Message);
         m_warningCount++;
     }
 }
 public void EventArgsCtors()
 {
     BuildWarningEventArgs buildWarningEvent = new BuildWarningEventArgs2();
     buildWarningEvent = new BuildWarningEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "sender");
     buildWarningEvent = new BuildWarningEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "Message", "HelpKeyword", "sender", DateTime.Now);
     buildWarningEvent = new BuildWarningEventArgs("Subcategory", "Code", "File", 1, 2, 3, 4, "{0}", "HelpKeyword", "sender", DateTime.Now, "Message");
     buildWarningEvent = new BuildWarningEventArgs(null, null, null, 1, 2, 3, 4, null, null, null);
     buildWarningEvent = new BuildWarningEventArgs(null, null, null, 1, 2, 3, 4, null, null, null, DateTime.Now);
     buildWarningEvent = new BuildWarningEventArgs(null, null, null, 1, 2, 3, 4, null, null, null, DateTime.Now, null);
 }
示例#12
0
 void WarningRaised(object sender, BuildWarningEventArgs e)
 {
     string fullPath = ProjectDirectory != null ? Path.Combine(ProjectDirectory, e.File) : e.File;
     Console.ForegroundColor = ConsoleColor.DarkYellow;
     if (e.Code != null)
     {
         Console.WriteLine("{0}({1},{2})  warning:{3}  {4}", fullPath, e.LineNumber, e.ColumnNumber, e.Code, e.Message);
         WarningCount++;
     }
     Console.ForegroundColor = ConsoleColor.White;
 }
示例#13
0
文件: Logger.cs 项目: nlhepler/mono
		public virtual string FormatWarningEvent (BuildWarningEventArgs args)
		{
			StringBuilder sb = new StringBuilder ();

			sb.Append (args.File);
			AppendLineNumbers (sb, args.LineNumber, args.ColumnNumber, args.EndLineNumber, args.EndColumnNumber);
			sb.Append (": ");
			sb.Append (args.Subcategory);
			sb.Append (" warning ");
			sb.Append (args.Code);
			sb.Append (": ");
			sb.Append (args.Message);

			return sb.ToString ();
		}
示例#14
0
 public SharpBuildWarningEvent(BuildWarningEventArgs arg)
     : base(SharpBuildEventType.WarningLog)
 {
     if (arg != null)
     {
         Code = arg.Code;
         ColumnNumber = arg.ColumnNumber;
         EndColumnNumber = arg.EndColumnNumber;
         EndLineNumber = arg.EndLineNumber;
         File = arg.File;
         LineNumber = arg.LineNumber;
         ProjectFile = arg.ProjectFile;
         Message = arg.Message;
     }
 }
示例#15
0
        public void LogWarningEvent(BuildWarningEventArgs eventArgs)
        {
            if (eventArgs.File != null && eventArgs.File.Length > 0)
            {
                Console.Write("{0}({1},{2}): ", eventArgs.File, eventArgs.LineNumber, eventArgs.ColumnNumber);
            }

            Console.Write("WARNING " + eventArgs.Code + ": ");
            _log += "WARNING " + eventArgs.Code + ": ";
            ++_warnings;

            Console.WriteLine(eventArgs.Message);
            _log += eventArgs.Message;
            _log += "\n";
        }
        /// <summary>
        /// Logs a warning event for the current task
        /// </summary>
        /// <param name="e">The event args</param>
        public void LogWarningEvent(Microsoft.Build.Framework.BuildWarningEventArgs e)
        {
            ErrorUtilities.VerifyThrowArgumentNull(e, "e");
            VerifyActiveProxy();

            // If we are in building across process we need the events to be serializable. This method will
            // check to see if we are building with multiple process and if the event is serializable. It will
            // also log a warning if the event is not serializable and drop the logging message.
            if (IsRunningMultipleNodes && !IsEventSerializable(e))
            {
                return;
            }

            e.BuildEventContext = _loggingContext.BuildEventContext;
            _loggingContext.LoggingService.LogBuildEvent(e);
        }
示例#17
0
 public BuildMessage(BuildWarningEventArgs args)
 {
     EventType = args.GetType().Name.Replace("EventArgs", "");
     Code = args.Code;
     ColumnNumber = args.ColumnNumber;
     EndColumnNumber = args.EndColumnNumber;
     EndLineNumber = args.EndLineNumber;
     File = args.File;
     LineNumber = args.LineNumber;
     Message = args.Message;
     ProjectFile = args.ProjectFile;
     Subcategory = args.Subcategory;
     HelpKeyword = args.HelpKeyword;
     SenderName = args.SenderName;
     Timestamp = args.Timestamp;
     ThreadId = args.ThreadId;
 }
示例#18
0
        private void LogWarning(string value)
        {
            BuildWarningEventArgs warning = new BuildWarningEventArgs(
                subcategory: null,
                code: null,
                file: this.buildEngine.ProjectFileOfTaskNode,
                lineNumber: this.buildEngine.LineNumberOfTaskNode,
                columnNumber: this.buildEngine.ColumnNumberOfTaskNode,
                endLineNumber: 0,
                endColumnNumber: 0,
                message: value,
                helpKeyword: null,
                senderName: this.taskName,
                eventTimestamp: DateTime.UtcNow);

            this.buildEngine.LogWarningEvent(warning);
        }
示例#19
0
        public void LogWarningEvent(BuildWarningEventArgs eventArgs)
        {
            if (eventArgs.File != null && eventArgs.File.Length > 0)
            {
                if (logToConsole)
                    Console.Write("{0}({1},{2}): ", eventArgs.File, eventArgs.LineNumber, eventArgs.ColumnNumber);
                log += String.Format("{0}({1},{2}): ", eventArgs.File, eventArgs.LineNumber, eventArgs.ColumnNumber);
            }

            if (logToConsole)
                Console.Write("WARNING " + eventArgs.Code + ": ");
            log += "WARNING " + eventArgs.Code + ": ";
            ++warnings;

            if (logToConsole)
                Console.WriteLine(eventArgs.Message);
            log += eventArgs.Message;
            log += "\n";
        }
示例#20
0
 public abstract void WarningHandler(object sender, BuildWarningEventArgs e);
示例#21
0
 private void eventSource_WarningRaised(object sender, Microsoft.Build.Framework.BuildWarningEventArgs e)
 {
     warningsCount++;
     this.AddNode(String.Format("MSBUILD : warning {0} : {1}", e.Code, e.Message));
 }
示例#22
0
			void OnWarning(object sender, BuildWarningEventArgs e)
			{
				AppendError(e.File, e.LineNumber, e.ColumnNumber, e.Code, e.Message, e.ProjectFile, e.Subcategory, e.HelpKeyword, true);
			}
示例#23
0
 /// <summary>
 /// This is the delegate for warning events.
 /// </summary>
 protected virtual void WarningHandler(object sender, BuildWarningEventArgs warningEvent)
 {
     // NOTE: This may run on a background thread!
     QueueOutputText(MessageImportance.High, GetFormattedErrorMessage(warningEvent.File, warningEvent.LineNumber, warningEvent.ColumnNumber, true, warningEvent.Code, warningEvent.Message));
     QueueTaskEvent(warningEvent);
 }
示例#24
0
 void eventSource_WarningRaised(object sender, BuildWarningEventArgs e)
 {
     LogErrorOrWarning(XmlLoggerElements.Warning, e.Message, e.Code, e.File, e.LineNumber, e.ColumnNumber, e.Timestamp);
 }
示例#25
0
		// Raises a warning to all registered loggers.
		public void LogWarningEvent (BuildWarningEventArgs e)
		{
			engine.EventSource.FireWarningRaised (this, e);
		}
            public void LogWarningEvent(BuildWarningEventArgs eventArgs)
            {
                if (eventArgs == null)
                {
                    throw new ArgumentNullException("eventArgs");
                }

                if (!enableLog) return;

                if (eventArgs.File != null && eventArgs.File.Length > 0)
                {
                    log.Append(String.Format(CultureInfo.InvariantCulture, "{0}({1},{2}): ", eventArgs.File, eventArgs.LineNumber, eventArgs.ColumnNumber));
                }

                log.Append("WARNING ");
                log.Append(eventArgs.Code);
                log.Append(": ");
                ++warnings;

                log.AppendLine(eventArgs.Message);
            }
		/// <summary>
		/// This is the delegate for warning events.
		/// </summary>
		private void WarningHandler(object sender, BuildWarningEventArgs errorEvent)
		{
            try
            {
                AddToErrorList(
                    errorEvent,
                    errorEvent.Subcategory, 
                    errorEvent.Code,
                    errorEvent.File,
                    errorEvent.LineNumber,
                    errorEvent.ColumnNumber,
                    errorEvent.EndLineNumber,
                    errorEvent.EndColumnNumber);
            }
            catch (Exception e)
            {
                Debug.Assert(false, "Problem adding warning to warning list: " + e.Message + " at " + e.TargetSite);
            }
		}
 internal override void OutputWarning(object sender, BuildWarningEventArgs e)
 {
     if (GetHeaderOnlyFirstTyme() != null) { logStream.WriteLine(GetHeaderOnlyFirstTyme()); }
     logStream.WriteLine(FormatWarningEvent(e));
 }
 /// <summary>
 /// Raises a warning event to all registered loggers.
 /// </summary>
 /// <param name="e">The event data.</param>
 public void LogWarningEvent(BuildWarningEventArgs e)
 {
     this.context.Warning(e.Message);
 }
示例#30
0
 private void eventSource_WarningRaised(object sender, Microsoft.Build.Framework.BuildWarningEventArgs e)
 {
     warningsCount++;
     textBox.Text += Environment.NewLine + e.Message;
 }
示例#31
0
 /// <summary>
 /// Sends the provided warning back to the parent node to be logged, tagging it with 
 /// the parent node's ID so that, as far as anyone is concerned, it might as well have 
 /// just come from the parent node to begin with. 
 /// </summary>
 public void LogWarningEvent(BuildWarningEventArgs e)
 {
     SendBuildEvent(e);
 }
示例#32
0
        /// <summary>
        /// Generates the error event corresponding to a particular resource string and set of args
        /// </summary>
        private void LogWarningFromResource(string messageResource, params object[] messageArgs)
        {
            ErrorUtilities.VerifyThrow(_currentConfiguration != null, "We should never have a null configuration when we're trying to log warnings!");

            // Using the CLR 2 build event because this class is shared between MSBuildTaskHost.exe (CLR2) and MSBuild.exe (CLR4+)
            BuildWarningEventArgs warning = new BuildWarningEventArgs
                                                (
                                                    null,
                                                    null,
                                                    ProjectFileOfTaskNode,
                                                    LineNumberOfTaskNode,
                                                    ColumnNumberOfTaskNode,
                                                    0,
                                                    0,
                                                    ResourceUtilities.FormatString(AssemblyResources.GetString(messageResource), messageArgs),
                                                    null,
                                                    _currentConfiguration.TaskName
                                                );

            LogWarningEvent(warning);
        }
示例#33
0
 void OnWarningRaised(object sender, BuildWarningEventArgs e)
 {
     TraceSource.TraceEvent(TraceEventType.Warning, 0, e.Message);
 }
示例#34
0
 public void LogWarningEvent(BuildWarningEventArgs e)
 {
     _log.LogWarning(e.Message);
 }
示例#35
0
 public void LogWarningEvent(Microsoft.Build.Framework.BuildWarningEventArgs e)
 {
 }