Exemple #1
0
        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);
        }
Exemple #2
0
        /// <summary>
        /// Logs that a project evaluation has finished
        /// </summary>
        /// <param name="projectEvaluationEventContext">Event context for the project.</param>
        /// <param name="projectFile">Project file being built</param>
        /// <param name="globalProperties">Global properties used for the evaluation.</param>
        /// <param name="properties">Properties produced by the evaluation.</param>
        /// <param name="items">Items produced by the evaluation.</param>
        /// <param name="profilerResult">Profiler results if evaluation profiling was enabled.</param>
        /// <exception cref="InternalErrorException">BuildEventContext is null</exception>
        public void LogProjectEvaluationFinished(
            BuildEventContext projectEvaluationEventContext,
            string projectFile,
            IEnumerable globalProperties,
            IEnumerable properties,
            IEnumerable items,
            ProfilerResult?profilerResult)
        {
            lock (_lockObject)
            {
                ErrorUtilities.VerifyThrow(projectEvaluationEventContext != null, "projectBuildEventContext");

                ProjectEvaluationFinishedEventArgs buildEvent =
                    new ProjectEvaluationFinishedEventArgs(ResourceUtilities.GetResourceString("EvaluationFinished"), projectFile)
                {
                    BuildEventContext = projectEvaluationEventContext,
                    ProjectFile       = projectFile,
                    ProfilerResult    = profilerResult,
                    GlobalProperties  = globalProperties,
                    Properties        = properties,
                    Items             = items
                };
                ProcessLoggingEvent(buildEvent);
            }
        }
Exemple #3
0
        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);
                }
            }
        }
        public void RoundtripProjectEvaluationFinishedEventArgsWithProfileData()
        {
            var args = new ProjectEvaluationFinishedEventArgs("Message")
            {
                BuildEventContext = BuildEventContext.Invalid,
                ProjectFile       = @"C:\foo\bar.proj",
                ProfilerResult    = new ProfilerResult(new Dictionary <EvaluationLocation, ProfiledLocation>
                {
                    {
                        new EvaluationLocation(1, 0, EvaluationPass.InitialProperties, "desc1", "file1", 7, "element1", "description", EvaluationLocationKind.Condition),
                        new ProfiledLocation(TimeSpan.FromSeconds(1), TimeSpan.FromHours(2), 1)
                    },
                    {
                        new EvaluationLocation(0, null, EvaluationPass.LazyItems, "desc2", "file1", null, "element2", "description2", EvaluationLocationKind.Glob),
                        new ProfiledLocation(TimeSpan.FromSeconds(1), TimeSpan.FromHours(2), 2)
                    },
                    {
                        new EvaluationLocation(2, 0, EvaluationPass.Properties, "desc2", "file1", null, "element2", "description2", EvaluationLocationKind.Element),
                        new ProfiledLocation(TimeSpan.FromSeconds(1), TimeSpan.FromHours(2), 2)
                    }
                })
            };

            Roundtrip(args,
                      e => e.Message,
                      e => e.ProjectFile,
                      e => ToString(e.ProfilerResult.Value.ProfiledLocations));
        }
        public void RoundtripProjectEvaluationFinishedEventArgs()
        {
            var projectFile = @"C:\foo\bar.proj";
            var args        = new ProjectEvaluationFinishedEventArgs(
                ResourceUtilities.GetResourceString("EvaluationFinished"),
                projectFile)
            {
                BuildEventContext = BuildEventContext.Invalid,
                ProjectFile       = @"C:\foo\bar.proj",
                GlobalProperties  = new Dictionary <string, string>()
                {
                    { "GlobalKey", "GlobalValue" }
                },
                Properties = new List <DictionaryEntry>()
                {
                    new DictionaryEntry("Key", "Value")
                },
                Items = new List <DictionaryEntry>()
                {
                    new DictionaryEntry("Key", new MyTaskItem()
                    {
                        ItemSpec = "TestItemSpec"
                    })
                }
            };

            Roundtrip(args,
                      e => e.Message,
                      e => e.ProjectFile,
                      e => TranslationHelpers.GetPropertiesString(e.GlobalProperties),
                      e => TranslationHelpers.GetPropertiesString(e.Properties),
                      e => TranslationHelpers.GetMultiItemsString(e.Items));
        }
Exemple #6
0
        private void OnProjectEvaluationFinished(object sender, ProjectEvaluationFinishedEventArgs args)
        {
            var evaluationInfo       = FindEvaluationContext(args);
            var evaluatedProjectInfo = evaluationInfo.EndEvaluatingProject(args.ProjectFile);

            evaluatedProjectInfo.EndEvaluatedProject(args.Timestamp);
            AddMessage(evaluatedProjectInfo, args);
        }
Exemple #7
0
        public void RoundtripProjectEvaluationFinishedEventArgs()
        {
            var args = new ProjectEvaluationFinishedEventArgs("Message")
            {
                BuildEventContext = BuildEventContext.Invalid,
                ProjectFile       = @"C:\foo\bar.proj",
            };

            Roundtrip(args,
                      e => e.Message,
                      e => e.ProjectFile);
        }
Exemple #8
0
        private BuildEventArgs ReadProjectEvaluationFinishedEventArgs()
        {
            var fields      = ReadBuildEventArgsFields();
            var projectFile = ReadString();

            var e = new ProjectEvaluationFinishedEventArgs(fields.Message)
            {
                ProjectFile = projectFile
            };

            SetCommonFields(e, fields);
            return(e);
        }
Exemple #9
0
        private void OnProjectEvaluationFinished(object sender, ProjectEvaluationFinishedEventArgs args)
        {
            var evaluationInfo       = FindEvaluationContext(args);
            var evaluatedProjectInfo = evaluationInfo.EndEvaluatingProject(args.ProjectFile);
            EvaluatedProfileInfo evaluationProfileInfo = null;

            if (args.ProfilerResult != null)
            {
                evaluationProfileInfo = InterpretEvaluationProfile(args.ProfilerResult.Value);
            }
            evaluatedProjectInfo.EndEvaluatedProject(evaluationProfileInfo, args.Timestamp);
            AddMessage(evaluatedProjectInfo, args);
        }
Exemple #10
0
        /// <summary>
        /// Logs that a project evaluation has finished
        /// </summary>
        /// <param name="projectEvaluationEventContext">Event context for the project.</param>
        /// <param name="projectFile">Project file being built</param>
        /// <exception cref="InternalErrorException">BuildEventContext is null</exception>
        public void LogProjectEvaluationFinished(BuildEventContext projectEvaluationEventContext, string projectFile)
        {
            lock (_lockObject)
            {
                ErrorUtilities.VerifyThrow(projectEvaluationEventContext != null, "projectBuildEventContext");

                ProjectEvaluationFinishedEventArgs buildEvent =
                    new ProjectEvaluationFinishedEventArgs(ResourceUtilities.GetResourceString("EvaluationFinished"), projectFile)
                {
                    BuildEventContext = projectEvaluationEventContext,
                    ProjectFile       = projectFile
                };
                ProcessLoggingEvent(buildEvent);
            }
        }
Exemple #11
0
        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);
                }
            }
        }
Exemple #12
0
        private static ProjectEvaluationFinishedEventArgs CreateProjectEvaluationFinished()
        {
            string projectFile = "test.csproj";
            var    result      = new ProjectEvaluationFinishedEventArgs(
                ResourceUtilities.GetResourceString("EvaluationFinished"),
                projectFile)
            {
                ProjectFile      = projectFile,
                GlobalProperties = CreateProperties(),
                Properties       = CreateProperties(),
                Items            = new ArrayList
                {
                    new DictionaryEntry("Compile", new TaskItemData("a", null)),
                    new DictionaryEntry("Compile", new TaskItemData("b", CreateStringDictionary())),
                    new DictionaryEntry("Reference", new TaskItemData("c", CreateStringDictionary())),
                }
            };

            result.BuildEventContext = CreateBuildEventContext();

            return(result);
        }
Exemple #13
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);
            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);
        }
        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;
                }
            }
        }
Exemple #15
0
        /// <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);
            }
        }
Exemple #16
0
        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;
            }
        }
 private void Write(ProjectEvaluationFinishedEventArgs e)
 {
     Write(BinaryLogRecordKind.ProjectEvaluationFinished);
     WriteBuildEventArgsFields(e);
     Write(e.ProjectFile);
 }
Exemple #18
0
 public async void OnProjectEvaluationFinished(SolutionItem solutionItem, ProjectEvaluationFinishedEventArgs e)
 {
     await MessageSinks[0].AddMessage(e);
 }