private BuildEventArgs ReadProjectEvaluationFinishedEventArgs() { var fields = ReadBuildEventArgsFields(); var projectFile = ReadString(); var e = new ProjectEvaluationFinishedEventArgs(fields.Message) { ProjectFile = projectFile }; SetCommonFields(e, fields); // ProfilerResult was introduced in version 5 if (fileFormatVersion > 4) { var hasProfileData = ReadBoolean(); if (hasProfileData) { var count = ReadInt32(); var d = new Dictionary <EvaluationLocation, ProfiledLocation>(count); for (int i = 0; i < count; i++) { d.Add(ReadEvaluationLocation(), ReadProfiledLocation()); } e.ProfilerResult = new ProfilerResult(d); } } return(e); }
private void Write(ProjectEvaluationFinishedEventArgs e) { Write(BinaryLogRecordKind.ProjectEvaluationFinished); WriteBuildEventArgsFields(e, writeMessage: false); WriteDeduplicatedString(e.ProjectFile); if (e.GlobalProperties == null) { Write(false); } else { Write(true); WriteProperties(e.GlobalProperties); } WriteProperties(e.Properties); WriteProjectItems(e.Items); var result = e.ProfilerResult; Write(result.HasValue); if (result.HasValue) { Write(result.Value.ProfiledLocations.Count); foreach (var item in result.Value.ProfiledLocations) { Write(item.Key); Write(item.Value); } } }
private void Write(ProjectEvaluationFinishedEventArgs e) { Write(BinaryLogRecordKind.ProjectEvaluationFinished); WriteBuildEventArgsFields(e); Write(e.ProjectFile); Write(e.ProfilerResult.HasValue); if (e.ProfilerResult.HasValue) { Write(e.ProfilerResult.Value.ProfiledLocations.Count); foreach (var item in e.ProfilerResult.Value.ProfiledLocations) { Write(item.Key); Write(item.Value); } } }
/// <summary> /// Write a provided instance of BuildEventArgs to the BinaryWriter /// </summary> public void Write(BuildEventArgs e) { var type = e.GetType().Name; // the cases are ordered by most used first for performance if (e is BuildMessageEventArgs && type != "ProjectImportedEventArgs" && type != "TargetSkippedEventArgs") { Write((BuildMessageEventArgs)e); } else if (e is TaskStartedEventArgs) { Write((TaskStartedEventArgs)e); } else if (e is TaskFinishedEventArgs) { Write((TaskFinishedEventArgs)e); } else if (e is TargetStartedEventArgs) { Write((TargetStartedEventArgs)e); } else if (e is TargetFinishedEventArgs) { Write((TargetFinishedEventArgs)e); } else if (e is BuildErrorEventArgs) { Write((BuildErrorEventArgs)e); } else if (e is BuildWarningEventArgs) { Write((BuildWarningEventArgs)e); } else if (e is ProjectStartedEventArgs) { Write((ProjectStartedEventArgs)e); } else if (e is ProjectFinishedEventArgs) { Write((ProjectFinishedEventArgs)e); } else if (e is BuildStartedEventArgs) { Write((BuildStartedEventArgs)e); } else if (e is BuildFinishedEventArgs) { Write((BuildFinishedEventArgs)e); } else if (e is ProjectEvaluationStartedEventArgs) { Write((ProjectEvaluationStartedEventArgs)e); } else if (e is ProjectEvaluationFinishedEventArgs) { Write((ProjectEvaluationFinishedEventArgs)e); } // The following cases are due to the fact that StructuredLogger.dll // only references MSBuild 14.0 .dlls. The following BuildEventArgs types // were only introduced in MSBuild 15.3 so we can't refer to them statically. // To still provide a good experience to those who are using the BinaryLogger // from StructuredLogger.dll against MSBuild 15.3 or later we need to preserve // these new events, so use reflection to create our "equivalents" of those // and populate them to be binary identical to the originals. Then serialize // our copies so that it's impossible to tell what wrote these. else if (type == "ProjectEvaluationStartedEventArgs") { var evaluationStarted = new ProjectEvaluationStartedEventArgs(e.Message); evaluationStarted.BuildEventContext = e.BuildEventContext; evaluationStarted.ProjectFile = Reflector.GetProjectFileFromEvaluationStarted(e); Write(evaluationStarted); } else if (type == "ProjectEvaluationFinishedEventArgs") { var evaluationFinished = new ProjectEvaluationFinishedEventArgs(e.Message); evaluationFinished.BuildEventContext = e.BuildEventContext; evaluationFinished.ProjectFile = Reflector.GetProjectFileFromEvaluationFinished(e); Write(evaluationFinished); } else if (type == "ProjectImportedEventArgs") { var message = e as BuildMessageEventArgs; var projectImported = new ProjectImportedEventArgs(message.LineNumber, message.ColumnNumber, e.Message); projectImported.BuildEventContext = e.BuildEventContext; projectImported.ProjectFile = message.ProjectFile; projectImported.ImportedProjectFile = Reflector.GetImportedProjectFile(e); projectImported.UnexpandedProject = Reflector.GetUnexpandedProject(e); Write(projectImported); } else if (type == "TargetSkippedEventArgs") { var message = e as BuildMessageEventArgs; var targetSkipped = new TargetSkippedEventArgs(e.Message); targetSkipped.BuildEventContext = e.BuildEventContext; targetSkipped.ProjectFile = message.ProjectFile; targetSkipped.TargetName = Reflector.GetTargetNameFromTargetSkipped(e); targetSkipped.TargetFile = Reflector.GetTargetFileFromTargetSkipped(e); targetSkipped.ParentTarget = Reflector.GetParentTargetFromTargetSkipped(e); targetSkipped.BuildReason = Reflector.GetBuildReasonFromTargetSkipped(e); Write(targetSkipped); } else { // convert all unrecognized objects to message // and just preserve the message var buildMessageEventArgs = new BuildMessageEventArgs( e.Message, e.HelpKeyword, e.SenderName, MessageImportance.Normal, e.Timestamp); buildMessageEventArgs.BuildEventContext = e.BuildEventContext ?? BuildEventContext.Invalid; Write(buildMessageEventArgs); } }