Esempio n. 1
0
        private void PostAnalyzeProject(Project project)
        {
            // if nothing in the project is important, mark the project as not important as well
            if (project.HasChildren)
            {
                bool allLowRelevance = true;

                var entryTargets = project.FindChild <Folder>(Strings.EntryTargets);
                if (entryTargets != null)
                {
                    if (entryTargets.Children.OfType <IHasRelevance>().All(c => c.IsLowRelevance))
                    {
                        entryTargets.IsLowRelevance = true;
                    }
                }

                foreach (var child in project.Children)
                {
                    if (child is IHasRelevance hasRelevance)
                    {
                        if (!hasRelevance.IsLowRelevance)
                        {
                            allLowRelevance = false;
                            break;
                        }
                    }
                    else
                    {
                        allLowRelevance = false;
                        break;
                    }
                }

                if (allLowRelevance)
                {
                    project.IsLowRelevance = true;
                }
            }

            if (string.IsNullOrEmpty(project.TargetFramework))
            {
                var evaluation = build.FindEvaluation(project.EvaluationId);
                if (evaluation != null)
                {
                    project.TargetFramework = evaluation.TargetFramework;
                    if (!string.IsNullOrEmpty(project.TargetFramework))
                    {
                        var text = $"Properties and items are available at evaluation id:{project.EvaluationId}. Use the hyperlink above or the new 'Properties and items' tab.";
#if DEBUG
                        text = build.StringTable.Intern(text);
#endif
                        project.AddChildAtBeginning(new Note
                        {
                            Text = text
                        });
                    }
                }
            }
        }
Esempio n. 2
0
        private void ConstructProfilerResult(Project project, ProfilerResult profilerResult)
        {
            var nodes = new Dictionary <long, EvaluationProfileEntry>();

            foreach (var kvp in profilerResult.ProfiledLocations)
            {
                var location = kvp.Key;
                var result   = kvp.Value;

                if (!nodes.TryGetValue(location.Id, out var node))
                {
                    node = new EvaluationProfileEntry();
                    nodes[location.Id] = node;

                    node.ElementName               = location.ElementName;
                    node.ElementDescription        = location.ElementDescription;
                    node.EvaluationPassDescription = location.EvaluationPassDescription;
                    node.Kind           = location.Kind;
                    node.SourceFilePath = location.File;
                    node.LineNumber     = location.Line ?? 0;

                    node.AddEntry(result);
                }
            }

            foreach (var kvp in profilerResult.ProfiledLocations)
            {
                var location = kvp.Key;

                if (nodes.TryGetValue(location.Id, out var node))
                {
                    if (location.ParentId.HasValue && nodes.TryGetValue(location.ParentId.Value, out var parentNode))
                    {
                        parentNode.AddChild(node);

                        var parentDuration = parentNode.ProfiledLocation.InclusiveTime.TotalMilliseconds;
                        var duration       = node.ProfiledLocation.InclusiveTime.TotalMilliseconds;

                        double ratio = GetRatio(parentDuration, duration);

                        node.Value = ratio;
                    }
                    else
                    {
                        project.AddChildAtBeginning(node);
                        node.Value = 100;
                    }
                }
            }
        }