public static void Analyze(Task task)
        {
            Folder analyzerReport = null;
            Folder parent         = null;

            foreach (var message in task.Children.OfType <Message>().ToArray())
            {
                var text = message.Text;
                if (text.StartsWith(Strings.TotalAnalyzerExecutionTime))
                {
                    analyzerReport      = new Folder();
                    analyzerReport.Name = Strings.AnalyzerReport;
                    task.AddChild(analyzerReport);
                    parent = analyzerReport;
                }
                else if (text.Contains(", Version=") && analyzerReport != null)
                {
                    var lastAssembly = new Folder();
                    lastAssembly.Name = text;
                    analyzerReport.AddChild(lastAssembly);
                    parent = lastAssembly;
                }

                if (parent != null)
                {
                    message.Parent.Children.Remove(message);
                    parent.AddChild(message);
                }
            }
        }
        public static void CreateMergedReport(Folder destination, Folder[] analyzerReports)
        {
            var assemblyData = new Dictionary <string, AnalyzerAssemblyData>();

            foreach (var report in analyzerReports)
            {
                foreach (var folder in report.Children.OfType <Folder>())
                {
                    var data = AnalyzerAssemblyData.FromFolder(folder);
                    if (assemblyData.TryGetValue(data.Name, out var existingData))
                    {
                        existingData.CombineWith(data);
                    }
                    else
                    {
                        assemblyData.Add(data.Name, data);
                    }
                }
            }

            foreach (var data in assemblyData.OrderByDescending(data => data.Value.TotalTime))
            {
                var folder = new Folder {
                    Name = $"{TextUtilities.DisplayDuration(data.Value.TotalTime, showZero: true)}   {data.Value.Name}"
                };
                foreach (var analyzer in data.Value.AnalyzerTimes.OrderByDescending(analyzer => analyzer.Value).ThenBy(analyzer => analyzer.Key, StringComparer.OrdinalIgnoreCase))
                {
                    folder.AddChild(new Item {
                        Name = analyzer.Key, Text = TextUtilities.DisplayDuration(analyzer.Value, showZero: true)
                    });
                }

                destination.AddChild(folder);
            }
        }
        public void AppendDoubleWritesFolder(Build build)
        {
            Folder doubleWrites = null;

            foreach (var bucket in GetDoubleWrites())
            {
                doubleWrites = doubleWrites ?? build.GetOrCreateNodeWithName <Folder>("DoubleWrites");
                var item = new Item {
                    Text = bucket.Key
                };
                doubleWrites.AddChild(item);
                foreach (var source in bucket.Value)
                {
                    item.AddChild(new Item {
                        Text = source
                    });
                }
            }
        }
        public static Folder Analyze(Task task)
        {
            Folder analyzerReport = null;
            Folder parent         = null;

            foreach (var message in task.Children.OfType <Message>().ToArray())
            {
                var text = message.Text;
                if (text.StartsWith(Strings.TotalAnalyzerExecutionTime, StringComparison.Ordinal))
                {
                    analyzerReport      = new Folder();
                    analyzerReport.Name = Strings.AnalyzerReport;
                    task.AddChild(analyzerReport);
                    parent = analyzerReport;
                }
                else if (text.Contains(", Version=") && analyzerReport != null)
                {
                    var lastAssembly = new Folder();
                    lastAssembly.Name = text;
                    analyzerReport.AddChild(lastAssembly);
                    parent = lastAssembly;

                    // Remove the message since we are already using the same text for the containing folder
                    message.Parent.Children.Remove(message);
                    continue;
                }

                if (parent != null)
                {
                    message.Parent.Children.Remove(message);
                    parent.AddChild(message);
                }
            }

            return(analyzerReport);
        }