string EventsToString() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < events.Count; i++) { BuildStatusEventArgs args = events [i]; ProjectStartedEventArgs pargs = args as ProjectStartedEventArgs; if (pargs != null) { sb.AppendFormat("{0} ({1}) ->\n", pargs.ProjectFile, String.IsNullOrEmpty(pargs.TargetNames) ? "default targets" : pargs.TargetNames); continue; } TargetStartedEventArgs targs = args as TargetStartedEventArgs; if (targs != null) { sb.AppendFormat("({0} target) ->\n", targs.TargetName); } } return(sb.ToString()); }
/// <summary> /// Raises a catch-all build status event to all registered loggers. /// </summary> /// <param name="sender">sender of the event</param> /// <param name="buildEvent">BuildStatusEventArgs</param> /// <exception cref="LoggerException">When EventHandler raises an logger exception the LoggerException is rethrown</exception> /// <exception cref="InternalLoggerException">Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException</exception> /// <exception cref="Exception">ExceptionHandling.IsCriticalException exceptions will not be wrapped</exception> private void RaiseStatusEvent(object sender, BuildStatusEventArgs buildEvent) { if (StatusEventRaised != null) { try { StatusEventRaised(sender, buildEvent); } catch (LoggerException) { // if a logger has failed politely, abort immediately // first unregister all loggers, since other loggers may receive remaining events in unexpected orderings // if a fellow logger is throwing in an event handler. this.UnregisterAllEventHandlers(); throw; } catch (Exception exception) { // first unregister all loggers, since other loggers may receive remaining events in unexpected orderings // if a fellow logger is throwing in an event handler. this.UnregisterAllEventHandlers(); if (ExceptionHandling.IsCriticalException(exception)) { throw; } InternalLoggerException.Throw(exception, buildEvent, "FatalErrorWhileLogging", false); } } RaiseAnyEvent(sender, buildEvent); }
public void StatusEventRaised(object sender, BuildStatusEventArgs e) { try { lock (syncLock) { // This happens when we consume args created by us (deserialized) if (e is ProjectEvaluationStartedEventArgs projectEvaluationStarted) { var projectName = projectEvaluationStarted.ProjectFile; var project = EvaluationFolder.GetOrCreateNodeWithName <Project>(projectName); project.Id = e.BuildEventContext.ProjectContextId; } else if (e is ProjectEvaluationFinishedEventArgs projectEvaluationFinished) { } // this happens during live build using MSBuild 15.3 or newer else if (e.GetType().Name == "ProjectEvaluationStartedEventArgs") { var projectName = Utilities.ParseQuotedSubstring(e.Message); var project = EvaluationFolder.GetOrCreateNodeWithName <Project>(projectName); project.Id = Reflector.GetEvaluationId(e.BuildEventContext); } } } catch (Exception ex) { HandleException(ex); } }
void eventSource_StatusEventRaised(object sender, BuildStatusEventArgs e) { if (Verbosity > LoggerVerbosity.Normal) { output.AppendFormat("{0}" + Environment.NewLine, e.Message); } }
private void EventSource_StatusEventRaised(object sender, BuildStatusEventArgs e) { if (Verbosity >= LoggerVerbosity.Diagnostic) { HtmlQueue.Enqueue(new LogLine($"<span class=\"{StyleSheet.StatusCssClass}\">{e.Message} - {e.HelpKeyword}</span>")); } }
public override void StatusEventHandler(object sender, BuildStatusEventArgs e) { if (e is ProjectEvaluationStartedEventArgs projectEvaluationStarted) { if (showPerfSummary) { PerformanceCounter counter = GetPerformanceCounter(projectEvaluationStarted.ProjectFile, ref projectEvaluationPerformanceCounters); counter.InScope = true; } } else if (e is ProjectEvaluationFinishedEventArgs projectEvaluationFinished) { if (showPerfSummary) { PerformanceCounter counter = GetPerformanceCounter(projectEvaluationFinished.ProjectFile, ref projectEvaluationPerformanceCounters); counter.InScope = false; } if (Verbosity == LoggerVerbosity.Diagnostic && showItemAndPropertyList) { if (projectEvaluationFinished.Properties != null) { var propertyList = ExtractPropertyList(projectEvaluationFinished.Properties); WriteProperties(propertyList); } if (projectEvaluationFinished.Items != null) { SortedList itemList = ExtractItemList(projectEvaluationFinished.Items); WriteItems(itemList); } } } }
public void StatusEventRaised(object sender, BuildStatusEventArgs e) { try { lock (syncLock) { if (e is ProjectEvaluationStartedEventArgs projectEvaluationStarted) { var evaluationId = projectEvaluationStarted.BuildEventContext.EvaluationId; var projectFilePath = Intern(projectEvaluationStarted.ProjectFile); var projectName = Intern(Path.GetFileName(projectFilePath)); var nodeName = Intern(GetEvaluationProjectName(evaluationId, projectName)); var projectEvaluation = new ProjectEvaluation { Name = nodeName }; EvaluationFolder.AddChild(projectEvaluation); projectEvaluation.ProjectFile = projectFilePath; projectEvaluation.Id = evaluationId; projectEvaluation.EvaluationText = Intern("id:" + evaluationId); projectEvaluation.NodeId = e.BuildEventContext.NodeId; projectEvaluation.StartTime = e.Timestamp; projectEvaluation.EndTime = e.Timestamp; } else if (e is ProjectEvaluationFinishedEventArgs projectEvaluationFinished) { var evaluationId = projectEvaluationFinished.BuildEventContext.EvaluationId; var projectFilePath = Intern(projectEvaluationFinished.ProjectFile); var projectName = Intern(Path.GetFileName(projectFilePath)); var nodeName = Intern(GetEvaluationProjectName(evaluationId, projectName)); var projectEvaluation = EvaluationFolder.FindLastChild <ProjectEvaluation>(e => e.Id == evaluationId); if (projectEvaluation == null) { // no matching ProjectEvaluationStarted return; } projectEvaluation.EndTime = e.Timestamp; var profilerResult = projectEvaluationFinished.ProfilerResult; if (profilerResult != null && projectName != null) { ConstructProfilerResult(projectEvaluation, profilerResult.Value); } if (projectEvaluationFinished.GlobalProperties != null) { AddGlobalProperties(projectEvaluation, projectEvaluationFinished.GlobalProperties); } AddProperties(projectEvaluation, projectEvaluationFinished.Properties); AddItems(projectEvaluation, projectEvaluationFinished.Items); } } } catch (Exception ex) { HandleException(ex); } }
public void StatusEventRaised(object sender, BuildStatusEventArgs e) { try { lock (syncLock) { if (e is ProjectEvaluationStartedEventArgs projectEvaluationStarted) { var projectName = projectEvaluationStarted.ProjectFile; var project = EvaluationFolder.GetOrCreateNodeWithName <Project>(projectName); project.Id = e.BuildEventContext.ProjectContextId; } else if (e is ProjectEvaluationFinishedEventArgs projectEvaluationFinished) { } else if (e.Message.StartsWith("Evaluation started")) { var projectName = Utilities.ParseQuotedSubstring(e.Message); var project = EvaluationFolder.GetOrCreateNodeWithName <Project>(projectName); project.Id = e.BuildEventContext.ProjectContextId; } } } catch (Exception ex) { HandleException(ex); } }
public ExecutionInfo(string name, BuildStatusEventArgs startedArgs, BuildStatusEventArgs finishedArgs) { this.Name = name; this.StartedArgs = startedArgs; this.FinishedArgs = finishedArgs; this.TimeSpent = finishedArgs.Timestamp.Subtract(startedArgs.Timestamp); }
public BuildMessage(BuildStatusEventArgs args) { EventType = args.GetType().Name.Replace("EventArgs", ""); Message = args.Message; HelpKeyword = args.HelpKeyword; SenderName = args.SenderName; Timestamp = args.Timestamp; ThreadId = args.ThreadId; }
/// <summary> /// Handle a status event /// </summary> /// <param name="sender">Who sent the event</param> /// <param name="e">Event raised on the event source</param> private void Source_StatusEventRaised(object sender, BuildStatusEventArgs e) { _enteredStatusEventHandler = true; _raisedStatusEvent = e; if (_exceptionInHandlers != null) { throw _exceptionInHandlers; } }
public void StatusEventRaised(object sender, BuildStatusEventArgs e) { try { lock (syncLock) { // This happens when we consume args created by us (deserialized) if (e is ProjectEvaluationStartedEventArgs projectEvaluationStarted) { EvaluationFolder = Build.GetOrCreateNodeWithName <Folder>(Intern("Evaluation")); var evaluationId = -e.BuildEventContext.ProjectContextId; var projectName = Intern(projectEvaluationStarted.ProjectFile); var nodeName = Intern(GetEvaluationProjectName(evaluationId, projectName)); var project = EvaluationFolder.GetOrCreateNodeWithName <Project>(nodeName); if (project.ProjectFile == null) { project.ProjectFile = projectName; } // we stash the evaluation Id as a negative ProjectContextId project.Id = evaluationId; } else if (e is ProjectEvaluationFinishedEventArgs projectEvaluationFinished) { EvaluationFolder = Build.GetOrCreateNodeWithName <Folder>("Evaluation"); var projectName = Intern(projectEvaluationFinished.ProjectFile); var profilerResult = projectEvaluationFinished.ProfilerResult; if (profilerResult != null && projectName != null) { var nodeName = Intern(GetEvaluationProjectName(-projectEvaluationFinished.BuildEventContext.ProjectContextId, projectName)); var project = EvaluationFolder.GetOrCreateNodeWithName <Project>(nodeName); ConstructProfilerResult(project, profilerResult.Value); } } // this happens during live build using MSBuild 15.3 or newer else if (e.GetType().Name == "ProjectEvaluationStartedEventArgs") { var projectName = Intern(TextUtilities.ParseQuotedSubstring(e.Message)); var nodeName = Intern(GetEvaluationProjectName(-e.BuildEventContext.ProjectContextId, projectName)); var project = EvaluationFolder.GetOrCreateNodeWithName <Project>(nodeName); project.Id = Reflector.GetEvaluationId(e.BuildEventContext); if (project.ProjectFile == null) { project.ProjectFile = projectName; } } } } catch (Exception ex) { HandleException(ex); } }
// In binlog 14 we need to gather properties and items during evaluation and "glue" them with the project event args // But can never remove ProjectStarted: "even v14 will log them on ProjectStarted if any legacy loggers are present (for compat)" // See https://twitter.com/KirillOsenkov/status/1427686459713019904 private void StatusEventRaised(object sender, BuildStatusEventArgs e) { if (e is ProjectEvaluationFinishedEventArgs msBuildEv) { _evalulationResults[msBuildEv.BuildEventContext.EvaluationId] = new PropertiesAndItems { Properties = msBuildEv.Properties, Items = msBuildEv.Items }; } }
private void BuildStatusHandler(object sender, BuildStatusEventArgs e) { if (_forwardingTable[ProjectEvaluationStartedEventDescription] == 1 && e is ProjectEvaluationStartedEventArgs) { ForwardToCentralLogger(e); } if (_forwardingTable[ProjectEvaluationFinishedEventDescription] == 1 && e is ProjectEvaluationFinishedEventArgs) { ForwardToCentralLogger(e); } }
private void eventSource_StatusEventRaised(object sender, BuildStatusEventArgs e) { if (stop) { return; } Execute(new BuildMessage(e)); if (stop) { KillThyself(); } }
public void ExecuteFinishedHandler(BuildStatusEventArgs finished_args) { if (!StartHandlerHasExecuted) { return; } if (EventArgs is ProjectStartedEventArgs) { var pfa = finished_args as ProjectFinishedEventArgs; // FIXME: BuildFinishedHandlerActual sends us BuildFinishedEventArgs via PopEvent if (pfa == null) { return; } ConsoleLogger.ProjectFinishedHandler(Sender, pfa); } else if (EventArgs is TargetStartedEventArgs) { var fa = finished_args as TargetFinishedEventArgs; // FIXME: BuildFinishedHandlerActual sends us BuildFinishedEventArgs via PopEvent if (fa == null) { return; } ConsoleLogger.TargetFinishedHandler(Sender, fa); } else if (EventArgs is TaskStartedEventArgs) { // FIXME: BuildFinishedHandlerActual sends us BuildFinishedEventArgs via PopEvent if (!(finished_args is TaskFinishedEventArgs)) { return; } ConsoleLogger.TaskFinishedHandler(Sender, (TaskFinishedEventArgs)finished_args); } else if (!(EventArgs is BuildStartedEventArgs)) { throw new InvalidOperationException("Unexpected event on the stack, type: " + EventArgs.GetType()); } }
public void StatusEventRaised(object sender, BuildStatusEventArgs e) { try { lock (syncLock) { // This happens when we consume args created by us (deserialized) if (e is ProjectEvaluationStartedEventArgs projectEvaluationStarted) { var evaluationId = projectEvaluationStarted.BuildEventContext.EvaluationId; var projectName = Intern(projectEvaluationStarted.ProjectFile); var nodeName = Intern(GetEvaluationProjectName(evaluationId, projectName)); var projectEvaluation = EvaluationFolder.GetOrCreateNodeWithName <ProjectEvaluation>(nodeName); if (projectEvaluation.ProjectFile == null) { projectEvaluation.ProjectFile = projectName; } projectEvaluation.Id = evaluationId; projectEvaluation.NodeId = e.BuildEventContext.NodeId; projectEvaluation.StartTime = e.Timestamp; projectEvaluation.EndTime = e.Timestamp; } else if (e is ProjectEvaluationFinishedEventArgs projectEvaluationFinished) { var projectName = Intern(projectEvaluationFinished.ProjectFile); var evaluationId = projectEvaluationFinished.BuildEventContext.EvaluationId; var nodeName = Intern(GetEvaluationProjectName(evaluationId, projectName)); var projectEvaluation = EvaluationFolder.GetOrCreateNodeWithName <ProjectEvaluation>(nodeName); projectEvaluation.EndTime = e.Timestamp; var profilerResult = projectEvaluationFinished.ProfilerResult; if (profilerResult != null && projectName != null) { ConstructProfilerResult(projectEvaluation, profilerResult.Value); } } } } catch (Exception ex) { HandleException(ex); } }
public void ExecuteFinishedHandler(BuildStatusEventArgs finished_args) { if (!StartHandlerHasExecuted) { return; } if (EventArgs is ProjectStartedEventArgs && finished_args is ProjectFinishedEventArgs) { ConsoleLogger.ProjectFinishedHandler(null, (ProjectFinishedEventArgs)finished_args); } else if (EventArgs is TargetStartedEventArgs && finished_args is TargetFinishedEventArgs) { ConsoleLogger.TargetFinishedHandler(null, (TargetFinishedEventArgs)finished_args); } else if (EventArgs is TaskStartedEventArgs && finished_args is TaskFinishedEventArgs) { ConsoleLogger.TaskFinishedHandler(null, (TaskFinishedEventArgs)finished_args); } }
public override void StatusEventHandler(object sender, BuildStatusEventArgs e) { if (showPerfSummary) { ProjectEvaluationStartedEventArgs projectEvaluationStarted = e as ProjectEvaluationStartedEventArgs; if (projectEvaluationStarted != null) { PerformanceCounter counter = GetPerformanceCounter(projectEvaluationStarted.ProjectFile, ref projectEvaluationPerformanceCounters); counter.InScope = true; return; } ProjectEvaluationFinishedEventArgs projectEvaluationFinished = e as ProjectEvaluationFinishedEventArgs; if (projectEvaluationFinished != null) { PerformanceCounter counter = GetPerformanceCounter(projectEvaluationFinished.ProjectFile, ref projectEvaluationPerformanceCounters); counter.InScope = false; } } }
string EventsToString() { StringBuilder sb = new StringBuilder(); string last_imported_target_file = String.Empty; for (int i = 0; i < events.Count; i++) { BuildStatusEventArgs args = events [i]; ProjectStartedEventArgs pargs = args as ProjectStartedEventArgs; if (pargs != null) { sb.AppendFormat("{0} ({1}) ->\n", pargs.ProjectFile, String.IsNullOrEmpty(pargs.TargetNames) ? "default targets" : pargs.TargetNames); last_imported_target_file = String.Empty; continue; } TargetStartedEventArgs targs = args as TargetStartedEventArgs; if (targs != null) { if (targs.TargetFile != targs.ProjectFile && targs.TargetFile != last_imported_target_file) { // target from an imported file, // and it hasn't been mentioned as yet sb.AppendFormat("{0} ", targs.TargetFile); } last_imported_target_file = targs.TargetFile; sb.AppendFormat("({0} target) ->\n", targs.TargetName); } } return(sb.ToString()); }
public void ExecuteFinishedHandler(BuildStatusEventArgs finished_args) { if (!StartHandlerHasExecuted) { return; } if (EventArgs is ProjectStartedEventArgs) { ConsoleLogger.ProjectFinishedHandler(null, finished_args as ProjectFinishedEventArgs); } else if (EventArgs is TargetStartedEventArgs) { ConsoleLogger.TargetFinishedHandler(null, finished_args as TargetFinishedEventArgs); } else if (EventArgs is TaskStartedEventArgs) { ConsoleLogger.TaskFinishedHandler(null, finished_args as TaskFinishedEventArgs); } else if (!(EventArgs is BuildStartedEventArgs)) { throw new InvalidOperationException("Unexpected event on the stack, type: " + EventArgs.GetType()); } }
private static string FormatMessage(BuildStatusEventArgs e) { return string.Format("{0}:{1}$$", e.HelpKeyword, e.Message); }
public abstract void StatusEventHandler(object sender, BuildStatusEventArgs e);
/// <summary> /// Comment Event handler, logs to build log file. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void eventSource_StatusEventRaised(object sender, BuildStatusEventArgs e) { //this.LogToBuildLog(e, false); }
void StatusEvent(object sender, BuildStatusEventArgs e) { writer.WriteLine(GetLogMessage("StatusEvent", e)); }
void PushEvent(BuildStatusEventArgs args) { events.Add(args); current_events_string = null; }
void eventSource_StatusEventRaised(object sender, BuildStatusEventArgs e) { EventRaised(e.Message); }
void StatusEventRaised(object sender, BuildStatusEventArgs e) { this.Log().Debug("{0}", e.Message); }
void eventSource_StatusEventRaised_add(object sender, BuildStatusEventArgs e) { AddMessage(sender, e, MessageType.StatusEventRaised); }
void eventSource_StatusEventRaised(object sender, BuildStatusEventArgs e) { //WriteLineWithSenderAndMessage(String.Empty, e); }
// ReSharper disable once UnusedMember.Local private void OnStatusEventRaised(BuildStatusEventArgs e) { StatusEventRaised?.Invoke(this, e); }