private void TaskFinishedHandler(object sender, TaskFinishedEventArgs args) { if (args.TaskName.EndsWith("MSBuild")) { var e = new TraceEvent { name = $"MSBuild (yielded) in project \"{args.ProjectFile}\" ({args.BuildEventContext.ProjectInstanceId})", ph = "E", ts = (args.Timestamp - firstObservedTime).TotalMicroseconds(), tid = args.BuildEventContext.ProjectInstanceId, pid = args.BuildEventContext.NodeId.ToString(), }; events.Add(e); } }
/// <summary> /// This is the delegate for TaskFinishedHandler events. /// </summary> private void TaskFinishedHandler(object sender, TaskFinishedEventArgs buildEvent) { try { --this.currentIndent; if ((isLogTaskDone) && LogAtImportance(buildEvent.Succeeded ? MessageImportance.Normal : MessageImportance.High)) { LogEvent(sender, buildEvent); } } catch (Exception e) { Debug.Assert(false, "Problem logging taskfinished event: " + e.Message + " at " + e.TargetSite); // swallow the exception } }
public void TaskFinishedHandler(TaskFinishedEventArgs args) { indent--; if (IsVerbosityGreaterOrEqual(LoggerVerbosity.Detailed) || (!args.Succeeded && IsVerbosityGreaterOrEqual(LoggerVerbosity.Normal))) { SetColor(eventColor); if (args.Succeeded) { WriteLine(String.Format("Done executing task \"{0}\"", args.TaskName)); } else { WriteLine(String.Format("Task \"{0}\" execution -- FAILED", args.TaskName)); } ResetColor(); } }
public void TaskFinishedHandler(object sender, TaskFinishedEventArgs args) { indent--; if (this.verbosity == LoggerVerbosity.Detailed || !args.Succeeded) { SetColor(eventColor); if (args.Succeeded) { WriteLine(String.Format("Done executing task \"{0}\"", args.TaskName)); } else { WriteLine(String.Format("Task \"{0}\" execution -- FAILED", args.TaskName)); } ResetColor(); } PopEvent(); }
public void TaskFinished(object sender, TaskFinishedEventArgs args) { try { lock (syncLock) { var project = GetOrAddProject(args.BuildEventContext.ProjectContextId); var target = project.GetTargetById(args.BuildEventContext.TargetId); var task = target.GetTaskById(args.BuildEventContext.TaskId); task.EndTime = args.Timestamp; } } catch (Exception ex) { HandleException(ex); } }
/// <summary> /// Logs that a task has finished executing with all registered loggers. /// </summary> /// <owner>SumedhK</owner> /// <param name="taskName"></param> /// <param name="projectFile"></param> /// <param name="success"></param> /// <param name="projectFileOfTaskNode">project file actually containing the task</param> virtual internal void LogTaskFinished(BuildEventContext buildEventContext, string taskName, string projectFile, string projectFileOfTaskNode, bool success) { if (!OnlyLogCriticalEvents) { string message = ResourceUtilities.FormatResourceString(success ? "TaskFinishedSuccess" : "TaskFinishedFailure", taskName); TaskFinishedEventArgs e = new TaskFinishedEventArgs ( message, null, // no help keyword projectFile, projectFileOfTaskNode, taskName, success ); e.BuildEventContext = buildEventContext; PostLoggingEvent(e); } }
public void AssignmentTest() { TaskFinishedEventArgs tfea; string message = "message"; string helpKeyword = "helpKeyword"; string projectFile = "projectFile"; string taskFile = "taskFile"; string taskName = "taskName"; bool succeeded = true; tfea = new TaskFinishedEventArgs(message, helpKeyword, projectFile, taskFile, taskName, succeeded); Assert.AreEqual(message, tfea.Message, "Message"); Assert.AreEqual(helpKeyword, tfea.HelpKeyword, "HelpKeyword"); Assert.AreEqual(projectFile, tfea.ProjectFile, "ProjectFile"); Assert.AreEqual(taskFile, tfea.TaskFile, "TaskFile"); Assert.AreEqual(taskName, tfea.TaskName, "TaskName"); Assert.AreEqual(succeeded, tfea.Succeeded, "Succeeded"); }
public void LogTaskFinished(BuildEventContext taskBuildEventContext, string taskName, string projectFile, string projectFileOfTaskNode, bool success) { if (!OnlyLogCriticalEvents) { ErrorUtilities.VerifyThrow(taskBuildEventContext != null, "taskBuildEventContext is null"); TaskFinishedEventArgs buildEvent = new TaskFinishedEventArgs ( message: null, helpKeyword: null, projectFile, projectFileOfTaskNode, taskName, success ); buildEvent.BuildEventContext = taskBuildEventContext; ProcessLoggingEvent(buildEvent); } }
void TaskFinished(object sender, TaskFinishedEventArgs e) { XmlElement taskElement = taskElements.Pop(); taskElement.Attributes.Append(CreateFinishedAttribute(e.Timestamp)); if (base.IsVerbosityAtLeast(LoggerVerbosity.Detailed)) { taskElement.Attributes.Append(CreateAttribute("FinishMessage", e.Message)); taskElement.Attributes.Append(CreateAttribute("ProjectFile", e.ProjectFile)); taskElement.Attributes.Append(CreateAttribute("TaskFile", e.TaskFile)); } //var taskProjInstDiff = comparer.Compare(_projectStartedProjInstance, GetProjInstanceById(e.BuildEventContext.ProjectInstanceId)); //if (!taskProjInstDiff.AreEqual) { // taskElement.AppendChild(GetChangesElementFor(taskProjInstDiff)); //} buildTypeList.Pop(); }
private BuildEventArgs ReadTaskFinishedEventArgs() { var fields = ReadBuildEventArgsFields(); var succeeded = ReadBoolean(); var taskName = ReadOptionalString(); var projectFile = ReadOptionalString(); var taskFile = ReadOptionalString(); var e = new TaskFinishedEventArgs( fields.Message, fields.HelpKeyword, projectFile, taskFile, taskName, succeeded, fields.Timestamp); SetCommonFields(e, fields); return(e); }
/// <summary> /// Handler for task finished events /// </summary> /// <param name="sender">sender (should be null)</param> /// <param name="e">event arguments</param> public override void TaskFinishedHandler(object sender, TaskFinishedEventArgs e) { // Done with the task, so shift everything left again. this.currentIndentLevel--; if (this.showPerfSummary) { PerformanceCounter counter = GetPerformanceCounter(e.TaskName, ref taskPerformanceCounters); // Place the counter "in scope" meaning the task is done executing. counter.InScope = false; } // if verbosity is detailed or diagnostic if (IsVerbosityAtLeast(LoggerVerbosity.Detailed)) { setColor(ConsoleColor.Cyan); WriteLinePretty(e.Message); resetColor(); } }
void TaskFinished(object sender, TaskFinishedEventArgs e) { AppendLine(string.Format("#####Task Finished:{0}", e.Message.EscapeMarkdownCharacters())); if (IsVerbosityAtLeast(LoggerVerbosity.Detailed)) { AppendLine(e.ToPropertyValues().ToMarkdownTable().ToMarkdown()); } var startInfo = _tasksStarted.Pop(); var execInfo = new TaskExecutionInfo(startInfo, e); TaskExecutionInfo previousExecInfo; this._taskExecuted.TryGetValue(e.TaskName, out previousExecInfo); if (previousExecInfo != null) { execInfo.TimeSpent = execInfo.TimeSpent.Add(previousExecInfo.TimeSpent); } this._taskExecuted[execInfo.Name] = execInfo; }
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); TaskParameterEventArgs taskParameter = CreateTaskParameter(); 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); TargetSkippedEventArgs targetSkipped = CreateTargetSkipped(); 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"); ProjectEvaluationStartedEventArgs evaluationStarted = new ProjectEvaluationStartedEventArgs(); ProjectEvaluationFinishedEventArgs evaluationFinished = new ProjectEvaluationFinishedEventArgs(); 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(taskParameter, LoggingEventType.TaskParameterEvent); VerifyLoggingPacket(warning, LoggingEventType.BuildWarningEvent); VerifyLoggingPacket(error, LoggingEventType.BuildErrorEvent); VerifyLoggingPacket(targetStarted, LoggingEventType.TargetStartedEvent); VerifyLoggingPacket(targetFinished, LoggingEventType.TargetFinishedEvent); VerifyLoggingPacket(targetSkipped, LoggingEventType.TargetSkipped); VerifyLoggingPacket(projectStarted, LoggingEventType.ProjectStartedEvent); VerifyLoggingPacket(projectFinished, LoggingEventType.ProjectFinishedEvent); VerifyLoggingPacket(evaluationStarted, LoggingEventType.ProjectEvaluationStartedEvent); VerifyLoggingPacket(evaluationFinished, LoggingEventType.ProjectEvaluationFinishedEvent); VerifyLoggingPacket(externalStartedEvent, LoggingEventType.CustomEvent); }
/// <summary> /// Logs that a task has finished executing. /// </summary> /// <param name="taskBuildEventContext">Event context for the task</param> /// <param name="taskName">Name of the task</param> /// <param name="projectFile">Project which is being processed</param> /// <param name="projectFileOfTaskNode">Project file which contains the task</param> /// <param name="success">Did the task pass or fail</param> /// <exception cref="InternalErrorException">BuildEventContext is null</exception> public void LogTaskFinished(BuildEventContext taskBuildEventContext, string taskName, string projectFile, string projectFileOfTaskNode, bool success) { lock (_lockObject) { if (!OnlyLogCriticalEvents) { ErrorUtilities.VerifyThrow(taskBuildEventContext != null, "taskBuildEventContext is null"); string message = ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword(success ? "TaskFinishedSuccess" : "TaskFinishedFailure", taskName); TaskFinishedEventArgs buildEvent = new TaskFinishedEventArgs ( message, null, // no help keyword projectFile, projectFileOfTaskNode, taskName, success ); buildEvent.BuildEventContext = taskBuildEventContext; ProcessLoggingEvent(buildEvent); } } }
/// <summary> /// Compare this build event context with another object to determine /// equality. This means the values inside the object are identical. /// </summary> /// <param name="obj">Object to compare to this object</param> /// <returns>True if the object values are identical, false if they are not identical</returns> public static bool IsEquivalent(TaskFinishedEventArgs args, TaskFinishedEventArgs other) { if (!String.Equals(args.ProjectFile, other.ProjectFile, StringComparison.OrdinalIgnoreCase)) { return(false); } if (!String.Equals(args.TaskFile, other.TaskFile, StringComparison.OrdinalIgnoreCase)) { return(false); } if (!String.Equals(args.TaskName, other.TaskName, StringComparison.OrdinalIgnoreCase)) { return(false); } if (args.Succeeded != other.Succeeded) { return(false); } return(((BuildEventArgs)args).IsEquivalent(other)); }
/// <summary> /// This is the delegate for TaskFinishedHandler events. /// </summary> protected virtual void TaskFinishedHandler(object sender, TaskFinishedEventArgs buildEvent) { // NOTE: This may run on a background thread! UnindentOutput(); QueueOutputEvent(MessageImportance.Low, buildEvent); }
/// <summary> /// Handler for task finished events /// </summary> /// <param name="sender">sender (should be null)</param> /// <param name="e">event arguments</param> public void TaskFinishedHandler(object sender, TaskFinishedEventArgs e) { InitializeBaseConsoleLogger(); // for compat: see DDB#136924 _consoleLogger.TaskFinishedHandler(sender, e); }
private void TaskFinished(object sender, TaskFinishedEventArgs e) { SendMessage(FormatMessage(e)); }
public void TaskFinishedHandler(object sender, TaskFinishedEventArgs args) { GetBuildRecord(sender).TaskFinishedHandler(args); }
private void eventSource_TaskFinishedHandler(object sender, TaskFinishedEventArgs e) { LogStageFinished(e.Succeeded, e.Timestamp); }
public abstract void TaskFinishedHandler(object sender, TaskFinishedEventArgs e);
/// <summary> /// Task Finished Event handler, logs to build log file. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void eventSource_TaskFinishedEvent(object sender, TaskFinishedEventArgs e) { tabcount = 1; this.LogToBuildLog((BuildEventArgs)e, false); }
private void TaskFinished(object sender, TaskFinishedEventArgs e) { string line = string.Format(CultureInfo.InvariantCulture, "{0}", e.Message); this.WriteLine(line); }
void TaskFinished(object sender, TaskFinishedEventArgs e) { writer.WriteLine(GetLogMessage("TaskFinished", e)); }
void eventSource_TaskFinished(object sender, TaskFinishedEventArgs e) { Task task = new DummyTask(_task.Project, e.TaskName); _task.Project.OnTaskFinished(sender, new NAnt.Core.BuildEventArgs(task)); }
private void CompareLogMessagePackets(LogMessagePacket left, LogMessagePacket right) { Assert.Equal(left.EventType, right.EventType); Assert.Equal(left.NodeBuildEvent.Value.Value.GetType(), right.NodeBuildEvent.Value.Value.GetType()); CompareNodeBuildEventArgs(left.NodeBuildEvent.Value, right.NodeBuildEvent.Value, left.EventType == LoggingEventType.CustomEvent /* expectInvalidBuildEventContext */); switch (left.EventType) { case LoggingEventType.BuildErrorEvent: BuildErrorEventArgs leftError = left.NodeBuildEvent.Value.Value as BuildErrorEventArgs; BuildErrorEventArgs rightError = right.NodeBuildEvent.Value.Value as BuildErrorEventArgs; Assert.NotNull(leftError); Assert.NotNull(rightError); Assert.Equal(leftError.Code, rightError.Code); Assert.Equal(leftError.ColumnNumber, rightError.ColumnNumber); Assert.Equal(leftError.EndColumnNumber, rightError.EndColumnNumber); Assert.Equal(leftError.EndLineNumber, rightError.EndLineNumber); Assert.Equal(leftError.File, rightError.File); Assert.Equal(leftError.LineNumber, rightError.LineNumber); Assert.Equal(leftError.Message, rightError.Message); Assert.Equal(leftError.Subcategory, rightError.Subcategory); break; case LoggingEventType.BuildFinishedEvent: BuildFinishedEventArgs leftFinished = left.NodeBuildEvent.Value.Value as BuildFinishedEventArgs; BuildFinishedEventArgs rightFinished = right.NodeBuildEvent.Value.Value as BuildFinishedEventArgs; Assert.NotNull(leftFinished); Assert.NotNull(rightFinished); Assert.Equal(leftFinished.Succeeded, rightFinished.Succeeded); break; case LoggingEventType.BuildMessageEvent: BuildMessageEventArgs leftMessage = left.NodeBuildEvent.Value.Value as BuildMessageEventArgs; BuildMessageEventArgs rightMessage = right.NodeBuildEvent.Value.Value as BuildMessageEventArgs; Assert.NotNull(leftMessage); Assert.NotNull(rightMessage); Assert.Equal(leftMessage.Importance, rightMessage.Importance); break; case LoggingEventType.BuildStartedEvent: BuildStartedEventArgs leftBuildStart = left.NodeBuildEvent.Value.Value as BuildStartedEventArgs; BuildStartedEventArgs rightBuildStart = right.NodeBuildEvent.Value.Value as BuildStartedEventArgs; Assert.NotNull(leftBuildStart); Assert.NotNull(rightBuildStart); break; case LoggingEventType.BuildWarningEvent: BuildWarningEventArgs leftBuildWarn = left.NodeBuildEvent.Value.Value as BuildWarningEventArgs; BuildWarningEventArgs rightBuildWarn = right.NodeBuildEvent.Value.Value as BuildWarningEventArgs; Assert.NotNull(leftBuildWarn); Assert.NotNull(rightBuildWarn); Assert.Equal(leftBuildWarn.Code, rightBuildWarn.Code); Assert.Equal(leftBuildWarn.ColumnNumber, rightBuildWarn.ColumnNumber); Assert.Equal(leftBuildWarn.EndColumnNumber, rightBuildWarn.EndColumnNumber); Assert.Equal(leftBuildWarn.EndLineNumber, rightBuildWarn.EndLineNumber); Assert.Equal(leftBuildWarn.File, rightBuildWarn.File); Assert.Equal(leftBuildWarn.LineNumber, rightBuildWarn.LineNumber); Assert.Equal(leftBuildWarn.Subcategory, rightBuildWarn.Subcategory); break; case LoggingEventType.CustomEvent: ExternalProjectStartedEventArgs leftCustom = left.NodeBuildEvent.Value.Value as ExternalProjectStartedEventArgs; ExternalProjectStartedEventArgs rightCustom = right.NodeBuildEvent.Value.Value as ExternalProjectStartedEventArgs; Assert.NotNull(leftCustom); Assert.NotNull(rightCustom); Assert.Equal(leftCustom.ProjectFile, rightCustom.ProjectFile); Assert.Equal(leftCustom.TargetNames, rightCustom.TargetNames); break; case LoggingEventType.ProjectFinishedEvent: ProjectFinishedEventArgs leftProjectFinished = left.NodeBuildEvent.Value.Value as ProjectFinishedEventArgs; ProjectFinishedEventArgs rightProjectFinished = right.NodeBuildEvent.Value.Value as ProjectFinishedEventArgs; Assert.NotNull(leftProjectFinished); Assert.NotNull(rightProjectFinished); Assert.Equal(leftProjectFinished.ProjectFile, rightProjectFinished.ProjectFile); Assert.Equal(leftProjectFinished.Succeeded, rightProjectFinished.Succeeded); break; case LoggingEventType.ProjectStartedEvent: ProjectStartedEventArgs leftProjectStarted = left.NodeBuildEvent.Value.Value as ProjectStartedEventArgs; ProjectStartedEventArgs rightProjectStarted = right.NodeBuildEvent.Value.Value as ProjectStartedEventArgs; Assert.NotNull(leftProjectStarted); Assert.NotNull(rightProjectStarted); Assert.Equal(leftProjectStarted.ParentProjectBuildEventContext, rightProjectStarted.ParentProjectBuildEventContext); Assert.Equal(leftProjectStarted.ProjectFile, rightProjectStarted.ProjectFile); Assert.Equal(leftProjectStarted.ProjectId, rightProjectStarted.ProjectId); Assert.Equal(leftProjectStarted.TargetNames, rightProjectStarted.TargetNames); // UNDONE: (Serialization.) We don't actually serialize the items at this time. // Assert.AreEqual(leftProjectStarted.Items, rightProjectStarted.Items); // UNDONE: (Serialization.) We don't actually serialize properties at this time. // Assert.AreEqual(leftProjectStarted.Properties, rightProjectStarted.Properties); break; case LoggingEventType.ProjectEvaluationStartedEvent: ProjectEvaluationStartedEventArgs leftEvaluationStarted = left.NodeBuildEvent.Value.Value as ProjectEvaluationStartedEventArgs; ProjectEvaluationStartedEventArgs rightEvaluationStarted = right.NodeBuildEvent.Value.Value as ProjectEvaluationStartedEventArgs; Assert.NotNull(leftEvaluationStarted); Assert.NotNull(rightEvaluationStarted); Assert.Equal(leftEvaluationStarted.ProjectFile, rightEvaluationStarted.ProjectFile); break; case LoggingEventType.ProjectEvaluationFinishedEvent: ProjectEvaluationFinishedEventArgs leftEvaluationFinished = left.NodeBuildEvent.Value.Value as ProjectEvaluationFinishedEventArgs; ProjectEvaluationFinishedEventArgs rightEvaluationFinished = right.NodeBuildEvent.Value.Value as ProjectEvaluationFinishedEventArgs; Assert.NotNull(leftEvaluationFinished); Assert.NotNull(rightEvaluationFinished); Assert.Equal(leftEvaluationFinished.ProjectFile, rightEvaluationFinished.ProjectFile); Assert.Equal(leftEvaluationFinished.ProfilerResult, rightEvaluationFinished.ProfilerResult); Assert.Equal( TranslationHelpers.GetPropertiesString(leftEvaluationFinished.GlobalProperties), TranslationHelpers.GetPropertiesString(rightEvaluationFinished.GlobalProperties)); Assert.Equal( TranslationHelpers.GetPropertiesString(leftEvaluationFinished.Properties), TranslationHelpers.GetPropertiesString(rightEvaluationFinished.Properties)); Assert.Equal( TranslationHelpers.GetMultiItemsString(leftEvaluationFinished.Items), TranslationHelpers.GetMultiItemsString(rightEvaluationFinished.Items)); break; case LoggingEventType.TargetFinishedEvent: TargetFinishedEventArgs leftTargetFinished = left.NodeBuildEvent.Value.Value as TargetFinishedEventArgs; TargetFinishedEventArgs rightTargetFinished = right.NodeBuildEvent.Value.Value as TargetFinishedEventArgs; Assert.NotNull(leftTargetFinished); Assert.NotNull(rightTargetFinished); Assert.Equal(leftTargetFinished.ProjectFile, rightTargetFinished.ProjectFile); Assert.Equal(leftTargetFinished.Succeeded, rightTargetFinished.Succeeded); Assert.Equal(leftTargetFinished.TargetFile, rightTargetFinished.TargetFile); Assert.Equal(leftTargetFinished.TargetName, rightTargetFinished.TargetName); // TODO: target output translation is a special case and is done in TranslateTargetFinishedEvent // Assert.Equal(leftTargetFinished.TargetOutputs, rightTargetFinished.TargetOutputs); break; case LoggingEventType.TargetStartedEvent: TargetStartedEventArgs leftTargetStarted = left.NodeBuildEvent.Value.Value as TargetStartedEventArgs; TargetStartedEventArgs rightTargetStarted = right.NodeBuildEvent.Value.Value as TargetStartedEventArgs; Assert.NotNull(leftTargetStarted); Assert.NotNull(rightTargetStarted); Assert.Equal(leftTargetStarted.ProjectFile, rightTargetStarted.ProjectFile); Assert.Equal(leftTargetStarted.TargetFile, rightTargetStarted.TargetFile); Assert.Equal(leftTargetStarted.TargetName, rightTargetStarted.TargetName); break; case LoggingEventType.TargetSkipped: TargetSkippedEventArgs leftTargetSkipped = left.NodeBuildEvent.Value.Value as TargetSkippedEventArgs; TargetSkippedEventArgs rightTargetSkipped = right.NodeBuildEvent.Value.Value as TargetSkippedEventArgs; Assert.Equal(leftTargetSkipped.BuildReason, rightTargetSkipped.BuildReason); Assert.Equal(leftTargetSkipped.SkipReason, rightTargetSkipped.SkipReason); Assert.Equal(leftTargetSkipped.BuildEventContext, rightTargetSkipped.BuildEventContext); Assert.Equal(leftTargetSkipped.OriginalBuildEventContext, rightTargetSkipped.OriginalBuildEventContext); Assert.Equal(leftTargetSkipped.Condition, rightTargetSkipped.Condition); Assert.Equal(leftTargetSkipped.EvaluatedCondition, rightTargetSkipped.EvaluatedCondition); Assert.Equal(leftTargetSkipped.Importance, rightTargetSkipped.Importance); Assert.Equal(leftTargetSkipped.OriginallySucceeded, rightTargetSkipped.OriginallySucceeded); Assert.Equal(leftTargetSkipped.ProjectFile, rightTargetSkipped.ProjectFile); Assert.Equal(leftTargetSkipped.TargetFile, rightTargetSkipped.TargetFile); Assert.Equal(leftTargetSkipped.TargetName, rightTargetSkipped.TargetName); Assert.Equal(leftTargetSkipped.ParentTarget, rightTargetSkipped.ParentTarget); break; case LoggingEventType.TaskCommandLineEvent: TaskCommandLineEventArgs leftCommand = left.NodeBuildEvent.Value.Value as TaskCommandLineEventArgs; TaskCommandLineEventArgs rightCommand = right.NodeBuildEvent.Value.Value as TaskCommandLineEventArgs; Assert.NotNull(leftCommand); Assert.NotNull(rightCommand); Assert.Equal(leftCommand.CommandLine, rightCommand.CommandLine); Assert.Equal(leftCommand.Importance, rightCommand.Importance); Assert.Equal(leftCommand.TaskName, rightCommand.TaskName); break; case LoggingEventType.TaskParameterEvent: var leftTaskParameter = left.NodeBuildEvent.Value.Value as TaskParameterEventArgs; var rightTaskParameter = right.NodeBuildEvent.Value.Value as TaskParameterEventArgs; Assert.NotNull(leftTaskParameter); Assert.NotNull(rightTaskParameter); Assert.Equal(leftTaskParameter.Kind, rightTaskParameter.Kind); Assert.Equal(leftTaskParameter.ItemType, rightTaskParameter.ItemType); Assert.Equal(leftTaskParameter.Items.Count, rightTaskParameter.Items.Count); Assert.Equal(leftTaskParameter.Message, rightTaskParameter.Message); Assert.Equal(leftTaskParameter.BuildEventContext, rightTaskParameter.BuildEventContext); Assert.Equal(leftTaskParameter.Timestamp, rightTaskParameter.Timestamp); Assert.Equal(leftTaskParameter.LineNumber, rightTaskParameter.LineNumber); Assert.Equal(leftTaskParameter.ColumnNumber, rightTaskParameter.ColumnNumber); break; case LoggingEventType.TaskFinishedEvent: TaskFinishedEventArgs leftTaskFinished = left.NodeBuildEvent.Value.Value as TaskFinishedEventArgs; TaskFinishedEventArgs rightTaskFinished = right.NodeBuildEvent.Value.Value as TaskFinishedEventArgs; Assert.NotNull(leftTaskFinished); Assert.NotNull(rightTaskFinished); Assert.Equal(leftTaskFinished.ProjectFile, rightTaskFinished.ProjectFile); Assert.Equal(leftTaskFinished.Succeeded, rightTaskFinished.Succeeded); Assert.Equal(leftTaskFinished.TaskFile, rightTaskFinished.TaskFile); Assert.Equal(leftTaskFinished.TaskName, rightTaskFinished.TaskName); break; case LoggingEventType.TaskStartedEvent: TaskStartedEventArgs leftTaskStarted = left.NodeBuildEvent.Value.Value as TaskStartedEventArgs; TaskStartedEventArgs rightTaskStarted = right.NodeBuildEvent.Value.Value as TaskStartedEventArgs; Assert.NotNull(leftTaskStarted); Assert.NotNull(rightTaskStarted); Assert.Equal(leftTaskStarted.ProjectFile, rightTaskStarted.ProjectFile); Assert.Equal(leftTaskStarted.TaskFile, rightTaskStarted.TaskFile); Assert.Equal(leftTaskStarted.TaskName, rightTaskStarted.TaskName); Assert.Equal(leftTaskStarted.LineNumber, rightTaskStarted.LineNumber); Assert.Equal(leftTaskStarted.ColumnNumber, rightTaskStarted.ColumnNumber); break; default: Assert.True(false, string.Format("Unexpected logging event type {0}", left.EventType)); break; } }
/// <summary> /// Handle a task finished event /// </summary> /// <param name="sender">Who sent the event</param> /// <param name="e">Event raised on the event source</param> private void Source_TaskFinished(object sender, TaskFinishedEventArgs e) { HandleEvent(e); }
void TaskFinished(object sender, TaskFinishedEventArgs e) { string indentStr = new string('\t', currentIndent--); AppendLine(string.Format("{0}TaskFinished:{1}", indentStr, e.Message)); }
/// <summary> /// Task Finished Event handler, logs to build log file. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void eventSource_TaskFinishedEvent(object sender, TaskFinishedEventArgs e) { projectperf.SetProjectTargetTaskData(e.TaskName, true, e.Timestamp); }
void TaskFinished(object sender, TaskFinishedEventArgs e) { m_logDump.Add(string.Format("Finished task {0}.", e.TaskName)); }
private void OnTaskFinished(string taskId) { var taskFinished = TaskFinished; if(taskFinished != null) { var args = new TaskFinishedEventArgs {TaskInfo = GetTaskInfo(taskId)}; taskFinished(this, args); } }
/// <summary> /// Compares two LogMessagePacket objects for equivalence. /// </summary> private void CompareLogMessagePackets(LogMessagePacket left, LogMessagePacket right) { Assert.AreEqual(left.EventType, right.EventType); Assert.AreEqual(left.NodeBuildEvent.Value.Value.GetType(), right.NodeBuildEvent.Value.Value.GetType()); CompareNodeBuildEventArgs(left.NodeBuildEvent.Value, right.NodeBuildEvent.Value, left.EventType == LoggingEventType.CustomEvent /* expectInvalidBuildEventContext */); switch (left.EventType) { case LoggingEventType.BuildErrorEvent: BuildErrorEventArgs leftError = left.NodeBuildEvent.Value.Value as BuildErrorEventArgs; BuildErrorEventArgs rightError = right.NodeBuildEvent.Value.Value as BuildErrorEventArgs; Assert.IsNotNull(leftError); Assert.IsNotNull(rightError); Assert.AreEqual(leftError.Code, rightError.Code); Assert.AreEqual(leftError.ColumnNumber, rightError.ColumnNumber); Assert.AreEqual(leftError.EndColumnNumber, rightError.EndColumnNumber); Assert.AreEqual(leftError.EndLineNumber, rightError.EndLineNumber); Assert.AreEqual(leftError.File, rightError.File); Assert.AreEqual(leftError.LineNumber, rightError.LineNumber); Assert.AreEqual(leftError.Message, rightError.Message); Assert.AreEqual(leftError.Subcategory, rightError.Subcategory); break; case LoggingEventType.BuildFinishedEvent: BuildFinishedEventArgs leftFinished = left.NodeBuildEvent.Value.Value as BuildFinishedEventArgs; BuildFinishedEventArgs rightFinished = right.NodeBuildEvent.Value.Value as BuildFinishedEventArgs; Assert.IsNotNull(leftFinished); Assert.IsNotNull(rightFinished); Assert.AreEqual(leftFinished.Succeeded, rightFinished.Succeeded); break; case LoggingEventType.BuildMessageEvent: BuildMessageEventArgs leftMessage = left.NodeBuildEvent.Value.Value as BuildMessageEventArgs; BuildMessageEventArgs rightMessage = right.NodeBuildEvent.Value.Value as BuildMessageEventArgs; Assert.IsNotNull(leftMessage); Assert.IsNotNull(rightMessage); Assert.AreEqual(leftMessage.Importance, rightMessage.Importance); break; case LoggingEventType.BuildStartedEvent: BuildStartedEventArgs leftBuildStart = left.NodeBuildEvent.Value.Value as BuildStartedEventArgs; BuildStartedEventArgs rightBuildStart = right.NodeBuildEvent.Value.Value as BuildStartedEventArgs; Assert.IsNotNull(leftBuildStart); Assert.IsNotNull(rightBuildStart); break; case LoggingEventType.BuildWarningEvent: BuildWarningEventArgs leftBuildWarn = left.NodeBuildEvent.Value.Value as BuildWarningEventArgs; BuildWarningEventArgs rightBuildWarn = right.NodeBuildEvent.Value.Value as BuildWarningEventArgs; Assert.IsNotNull(leftBuildWarn); Assert.IsNotNull(rightBuildWarn); Assert.AreEqual(leftBuildWarn.Code, rightBuildWarn.Code); Assert.AreEqual(leftBuildWarn.ColumnNumber, rightBuildWarn.ColumnNumber); Assert.AreEqual(leftBuildWarn.EndColumnNumber, rightBuildWarn.EndColumnNumber); Assert.AreEqual(leftBuildWarn.EndLineNumber, rightBuildWarn.EndLineNumber); Assert.AreEqual(leftBuildWarn.File, rightBuildWarn.File); Assert.AreEqual(leftBuildWarn.LineNumber, rightBuildWarn.LineNumber); Assert.AreEqual(leftBuildWarn.Subcategory, rightBuildWarn.Subcategory); break; case LoggingEventType.CustomEvent: ExternalProjectStartedEventArgs leftCustom = left.NodeBuildEvent.Value.Value as ExternalProjectStartedEventArgs; ExternalProjectStartedEventArgs rightCustom = right.NodeBuildEvent.Value.Value as ExternalProjectStartedEventArgs; Assert.IsNotNull(leftCustom); Assert.IsNotNull(rightCustom); Assert.AreEqual(leftCustom.ProjectFile, rightCustom.ProjectFile); Assert.AreEqual(leftCustom.TargetNames, rightCustom.TargetNames); break; case LoggingEventType.ProjectFinishedEvent: ProjectFinishedEventArgs leftProjectFinished = left.NodeBuildEvent.Value.Value as ProjectFinishedEventArgs; ProjectFinishedEventArgs rightProjectFinished = right.NodeBuildEvent.Value.Value as ProjectFinishedEventArgs; Assert.IsNotNull(leftProjectFinished); Assert.IsNotNull(rightProjectFinished); Assert.AreEqual(leftProjectFinished.ProjectFile, rightProjectFinished.ProjectFile); Assert.AreEqual(leftProjectFinished.Succeeded, rightProjectFinished.Succeeded); break; case LoggingEventType.ProjectStartedEvent: ProjectStartedEventArgs leftProjectStarted = left.NodeBuildEvent.Value.Value as ProjectStartedEventArgs; ProjectStartedEventArgs rightProjectStarted = right.NodeBuildEvent.Value.Value as ProjectStartedEventArgs; Assert.IsNotNull(leftProjectStarted); Assert.IsNotNull(rightProjectStarted); Assert.AreEqual(leftProjectStarted.ParentProjectBuildEventContext, rightProjectStarted.ParentProjectBuildEventContext); Assert.AreEqual(leftProjectStarted.ProjectFile, rightProjectStarted.ProjectFile); Assert.AreEqual(leftProjectStarted.ProjectId, rightProjectStarted.ProjectId); Assert.AreEqual(leftProjectStarted.TargetNames, rightProjectStarted.TargetNames); // UNDONE: (Serialization.) We don't actually serialize the items at this time. // Assert.AreEqual(leftProjectStarted.Items, rightProjectStarted.Items); // UNDONE: (Serialization.) We don't actually serialize properties at this time. // Assert.AreEqual(leftProjectStarted.Properties, rightProjectStarted.Properties); break; case LoggingEventType.TargetFinishedEvent: TargetFinishedEventArgs leftTargetFinished = left.NodeBuildEvent.Value.Value as TargetFinishedEventArgs; TargetFinishedEventArgs rightTargetFinished = right.NodeBuildEvent.Value.Value as TargetFinishedEventArgs; Assert.IsNotNull(leftTargetFinished); Assert.IsNotNull(rightTargetFinished); Assert.AreEqual(leftTargetFinished.ProjectFile, rightTargetFinished.ProjectFile); Assert.AreEqual(leftTargetFinished.Succeeded, rightTargetFinished.Succeeded); Assert.AreEqual(leftTargetFinished.TargetFile, rightTargetFinished.TargetFile); Assert.AreEqual(leftTargetFinished.TargetName, rightTargetFinished.TargetName); break; case LoggingEventType.TargetStartedEvent: TargetStartedEventArgs leftTargetStarted = left.NodeBuildEvent.Value.Value as TargetStartedEventArgs; TargetStartedEventArgs rightTargetStarted = right.NodeBuildEvent.Value.Value as TargetStartedEventArgs; Assert.IsNotNull(leftTargetStarted); Assert.IsNotNull(rightTargetStarted); Assert.AreEqual(leftTargetStarted.ProjectFile, rightTargetStarted.ProjectFile); Assert.AreEqual(leftTargetStarted.TargetFile, rightTargetStarted.TargetFile); Assert.AreEqual(leftTargetStarted.TargetName, rightTargetStarted.TargetName); break; case LoggingEventType.TaskCommandLineEvent: TaskCommandLineEventArgs leftCommand = left.NodeBuildEvent.Value.Value as TaskCommandLineEventArgs; TaskCommandLineEventArgs rightCommand = right.NodeBuildEvent.Value.Value as TaskCommandLineEventArgs; Assert.IsNotNull(leftCommand); Assert.IsNotNull(rightCommand); Assert.AreEqual(leftCommand.CommandLine, rightCommand.CommandLine); Assert.AreEqual(leftCommand.Importance, rightCommand.Importance); Assert.AreEqual(leftCommand.TaskName, rightCommand.TaskName); break; case LoggingEventType.TaskFinishedEvent: TaskFinishedEventArgs leftTaskFinished = left.NodeBuildEvent.Value.Value as TaskFinishedEventArgs; TaskFinishedEventArgs rightTaskFinished = right.NodeBuildEvent.Value.Value as TaskFinishedEventArgs; Assert.IsNotNull(leftTaskFinished); Assert.IsNotNull(rightTaskFinished); Assert.AreEqual(leftTaskFinished.ProjectFile, rightTaskFinished.ProjectFile); Assert.AreEqual(leftTaskFinished.Succeeded, rightTaskFinished.Succeeded); Assert.AreEqual(leftTaskFinished.TaskFile, rightTaskFinished.TaskFile); Assert.AreEqual(leftTaskFinished.TaskName, rightTaskFinished.TaskName); break; case LoggingEventType.TaskStartedEvent: TaskStartedEventArgs leftTaskStarted = left.NodeBuildEvent.Value.Value as TaskStartedEventArgs; TaskStartedEventArgs rightTaskStarted = right.NodeBuildEvent.Value.Value as TaskStartedEventArgs; Assert.IsNotNull(leftTaskStarted); Assert.IsNotNull(rightTaskStarted); Assert.AreEqual(leftTaskStarted.ProjectFile, rightTaskStarted.ProjectFile); Assert.AreEqual(leftTaskStarted.TaskFile, rightTaskStarted.TaskFile); Assert.AreEqual(leftTaskStarted.TaskName, rightTaskStarted.TaskName); break; default: Assert.Fail("Unexpected logging event type {0}", left.EventType); break; } }
public static void EncodeEvent(BinaryWriter writer, BuildEventArgs e) { EventTypes type = GetEventType(e); writer.WriteInt32((int)type); writer.WriteNullableString(e.Message); writer.WriteNullableString(e.HelpKeyword); writer.WriteNullableString(e.SenderName); writer.WriteDateTime(e.Timestamp); switch (type) { case EventTypes.Error: BuildErrorEventArgs error = (BuildErrorEventArgs)e; writer.WriteNullableString(error.Subcategory); writer.WriteNullableString(error.Code); writer.WriteNullableString(error.File); writer.WriteInt32(error.LineNumber); writer.WriteInt32(error.ColumnNumber); writer.WriteInt32(error.EndLineNumber); writer.WriteInt32(error.EndColumnNumber); break; case EventTypes.Warning: BuildWarningEventArgs warning = (BuildWarningEventArgs)e; writer.WriteNullableString(warning.Subcategory); writer.WriteNullableString(warning.Code); writer.WriteNullableString(warning.File); writer.WriteInt32(warning.LineNumber); writer.WriteInt32(warning.ColumnNumber); writer.WriteInt32(warning.EndLineNumber); writer.WriteInt32(warning.EndColumnNumber); break; case EventTypes.Message: BuildMessageEventArgs message = (BuildMessageEventArgs)e; writer.WriteInt32((int)message.Importance); break; case EventTypes.BuildFinished: BuildFinishedEventArgs buildFinished = (BuildFinishedEventArgs)e; writer.Write(buildFinished.Succeeded); break; case EventTypes.BuildStarted: break; case EventTypes.ProjectFinished: ProjectFinishedEventArgs projectFinished = (ProjectFinishedEventArgs)e; writer.WriteNullableString(projectFinished.ProjectFile); writer.Write(projectFinished.Succeeded); break; case EventTypes.ProjectStarted: ProjectStartedEventArgs projectStarted = (ProjectStartedEventArgs)e; writer.WriteNullableString(projectStarted.ProjectFile); writer.WriteNullableString(projectStarted.TargetNames); break; case EventTypes.TargetFinished: TargetFinishedEventArgs targetFinished = (TargetFinishedEventArgs)e; writer.WriteNullableString(targetFinished.TargetName); writer.WriteNullableString(targetFinished.ProjectFile); writer.WriteNullableString(targetFinished.TargetFile); writer.Write(targetFinished.Succeeded); break; case EventTypes.TargetStarted: TargetStartedEventArgs targetStarted = (TargetStartedEventArgs)e; writer.WriteNullableString(targetStarted.TargetName); writer.WriteNullableString(targetStarted.ProjectFile); writer.WriteNullableString(targetStarted.TargetFile); #if MSBUILD35 writer.WriteNullableString(null); #else writer.WriteNullableString(targetStarted.ParentTarget); #endif break; case EventTypes.TaskFinished: TaskFinishedEventArgs taskFinished = (TaskFinishedEventArgs)e; writer.WriteNullableString(taskFinished.ProjectFile); writer.WriteNullableString(taskFinished.TaskFile); writer.WriteNullableString(taskFinished.TaskName); writer.Write(taskFinished.Succeeded); break; case EventTypes.TaskStarted: TaskStartedEventArgs taskStarted = (TaskStartedEventArgs)e; writer.WriteNullableString(taskStarted.ProjectFile); writer.WriteNullableString(taskStarted.TaskFile); writer.WriteNullableString(taskStarted.TaskName); break; default: // unknown etc. break; } }