Example #1
0
        static bool ProcessTaskParameter(MSBuildOutputProcessor processor, BuildMessageEventArgs e, StringInternPool stringPool)
        {
            if (e.Message.IndexOf('\n') == -1)
            {
                var message = stringPool.Add(e.Message, TaskParameterMessagePrefix.Length, e.Message.Length - TaskParameterMessagePrefix.Length);
                processor.CurrentNode.AddParameter(message, message);
            }
            else
            {
                string content   = e.Message.Substring(TaskParameterMessagePrefix.Length);
                int    equalSign = content.IndexOf('=');
                if (equalSign < 0)
                {
                    return(false);
                }

                content = $"{content.Substring (0, equalSign).Trim ()}={content.Substring (equalSign + 1, content.Length - equalSign - 1).Trim ()}";
                processor.CurrentNode.AddParameter(stringPool.Add(content), stringPool.Add(e.Message));
            }

            return(true);
        }
Example #2
0
        static void ProcessMessageEvent(MSBuildOutputProcessor processor, BuildMessageEventArgs e, StringInternPool stringPool)
        {
            if (String.IsNullOrEmpty(e.Message))
            {
                return;
            }

            switch (e.Message[0])
            {
            case 'S':
                if (e.Message.StartsWith(SkippingTargetMessagePrefix, StringComparison.Ordinal))
                {
                    // "Skipping target ..." messages
                    if (e.Message [SkippingTargetMessagePrefix.Length] == '"')
                    {
                        int nextQuoteIndex = e.Message.IndexOf('"', SkippingTargetMessagePrefix.Length + 1);
                        if (nextQuoteIndex >= 0)
                        {
                            if (processor.CurrentNode.NodeType == BuildOutputNodeType.Target &&
                                e.Message.IndexOf(processor.CurrentNode.Message,
                                                  SkippingTargetMessagePrefix.Length + 1,
                                                  nextQuoteIndex - 1 - SkippingTargetMessagePrefix.Length,
                                                  StringComparison.Ordinal) == SkippingTargetMessagePrefix.Length + 1)
                            {
                                processor.CurrentNode.NodeType = BuildOutputNodeType.TargetSkipped;
                                return;
                            }
                        }
                    }
                }
                break;

            case 'T':
                if (e.Message.StartsWith(TaskParameterMessagePrefix, StringComparison.Ordinal))
                {
                    // Task parameters are added to a special folder
                    if (ProcessTaskParameter(processor, e, stringPool))
                    {
                        return;
                    }
                }
                else if (e.Message.StartsWith(TargetMessagePrefix, StringComparison.Ordinal))
                {
                    // "Target ... skipped" messages
                    int nextQuoteIndex = e.Message.IndexOf('"', TargetMessagePrefix.Length + 1);
                    if (nextQuoteIndex >= 0)
                    {
                        if (e.Message.IndexOf(SkippedSuffix, nextQuoteIndex + 1, SkippedSuffix.Length, StringComparison.Ordinal) == nextQuoteIndex + 1)
                        {
                            processor.AddNode(BuildOutputNodeType.TargetSkipped,
                                              stringPool.Add(e.Message, TargetMessagePrefix.Length, nextQuoteIndex - TargetMessagePrefix.Length),
                                              stringPool.Add(e.Message),
                                              false,
                                              e.Timestamp);
                            return;
                        }
                    }
                }
                break;
            }

            string shortMessage = stringPool.Add(e.Message);

            processor.AddNode(e.Importance == MessageImportance.Low ? BuildOutputNodeType.Diagnostics : BuildOutputNodeType.Message,
                              shortMessage, shortMessage,
                              false,
                              e.Timestamp,
                              !String.IsNullOrEmpty(e.File) ? stringPool.Add(e.File) : null,
                              !String.IsNullOrEmpty(e.ProjectFile) ? stringPool.Add(e.ProjectFile) : null,
                              e.LineNumber);
        }