Example #1
0
        public void BuildGraph()
        {
            if (_graphWorkSet.IsCompleted)
            {
                return;
            }

            Dictionary <ConfigurationMetadata, ProjectGraphNode> allParsedProjects = FindGraphNodes();

            Edges = CreateEdgesAndDetectCycles(allParsedProjects);
            _projectInterpretation.PostProcess(allParsedProjects, this);

            EntryPointNodes = _entryPointConfigurationMetadata.Select(e => allParsedProjects[e]).ToList();
            RootNodes       = GetGraphRoots(EntryPointNodes);
            ProjectNodes    = allParsedProjects.Values.ToList();

            IReadOnlyCollection <ProjectGraphNode> GetGraphRoots(IReadOnlyCollection <ProjectGraphNode> entryPointNodes)
            {
                var graphRoots = new List <ProjectGraphNode>(entryPointNodes.Count);

                foreach (var entryPointNode in entryPointNodes)
                {
                    if (entryPointNode.ReferencingProjects.Count == 0)
                    {
                        graphRoots.Add(entryPointNode);
                    }
                }

                graphRoots.TrimExcess();

                return(graphRoots);
            }
        }
Example #2
0
 private void AddEdges(Dictionary <ConfigurationMetadata, ParsedProject> allParsedProjects)
 {
     Edges = new GraphEdges();
     AddEdgesFromProjectFileReferences(allParsedProjects, Edges);
     _projectInterpretation.PostProcess(allParsedProjects, this);
     if (_solutionDependencies != null && _solutionDependencies.Count != 0)
     {
         AddEdgesFromSolution(allParsedProjects, _solutionDependencies, Edges);
     }
 }
Example #3
0
        (IReadOnlyCollection <ProjectGraphNode> EntryPointNodes, IReadOnlyCollection <ProjectGraphNode> RootNodes, IReadOnlyCollection <ProjectGraphNode> AllNodes) LoadGraph(
            List <ConfigurationMetadata> entryPointConfigurationMetadata,
            ProjectCollection projectCollection,
            ProjectInstanceFactoryFunc projectInstanceFactory,
            ProjectInterpretation sdkInfo)
        {
            var allParsedProjects  = new ConcurrentDictionary <ConfigurationMetadata, ProjectGraphNode>();
            var tasksInProgress    = new ConcurrentDictionary <ConfigurationMetadata, object>();
            var projectsToEvaluate = new ConcurrentQueue <ConfigurationMetadata>();

            foreach (var entryPoint in entryPointConfigurationMetadata)
            {
                projectsToEvaluate.Enqueue(entryPoint);
            }

            if (FindGraphNodes(
                    projectsToEvaluate,
                    projectCollection,
                    tasksInProgress,
                    projectInstanceFactory,
                    sdkInfo,
                    allParsedProjects,
                    out var exceptions))
            {
                var entryPointNodes = entryPointConfigurationMetadata.Select(e => allParsedProjects[e]).ToList();

                CreateEdgesAndDetectCycles(entryPointConfigurationMetadata, sdkInfo, allParsedProjects);

                var graphRoots = GetGraphRoots(entryPointNodes);

                ProjectInterpretation.PostProcess(allParsedProjects);

                return(entryPointNodes.AsReadOnly(), graphRoots.AsReadOnly(), allParsedProjects.Values.ToList());
            }
            else
            {
                throw new AggregateException(exceptions);
            }

            List <ProjectGraphNode> GetGraphRoots(List <ProjectGraphNode> entryPointNodes)
            {
                var graphRoots = new List <ProjectGraphNode>(entryPointNodes.Count);

                foreach (var entryPointNode in entryPointNodes)
                {
                    if (entryPointNode.ReferencingProjects.Count == 0)
                    {
                        graphRoots.Add(entryPointNode);
                    }
                }
                return(graphRoots);
            }
        }
Example #4
0
        public void BuildGraph(
            IEnumerable <ProjectGraphEntryPoint> entryPoints,
            ProjectCollection projectCollection,
            ProjectGraph.ProjectInstanceFactoryFunc projectInstanceFactory
            )
        {
            var entryPointConfigurationMetadata = AddGraphBuildPropertyToEntryPoints(entryPoints);

            var allParsedProjects  = new ConcurrentDictionary <ConfigurationMetadata, ProjectGraphNode>();
            var projectsToEvaluate = new ConcurrentQueue <ConfigurationMetadata>(entryPointConfigurationMetadata);

            if (FindGraphNodes(
                    projectsToEvaluate,
                    projectCollection,
                    projectInstanceFactory,
                    ProjectInterpretation,
                    allParsedProjects,
                    out var exceptions))
            {
                Edges = new GraphEdges();

                CreateEdgesAndDetectCycles(entryPointConfigurationMetadata, ProjectInterpretation, allParsedProjects, Edges);

                ProjectInterpretation.PostProcess(allParsedProjects, this);

                EntryPointNodes = entryPointConfigurationMetadata.Select(e => allParsedProjects[e]).ToList();
                RootNodes       = GetGraphRoots(EntryPointNodes);
                ProjectNodes    = allParsedProjects.Values.ToList();
            }
            else
            {
                throw new AggregateException(exceptions);
            }

            IReadOnlyCollection <ProjectGraphNode> GetGraphRoots(IReadOnlyCollection <ProjectGraphNode> entryPointNodes)
            {
                var graphRoots = new List <ProjectGraphNode>(entryPointNodes.Count);

                foreach (var entryPointNode in entryPointNodes)
                {
                    if (entryPointNode.ReferencingProjects.Count == 0)
                    {
                        graphRoots.Add(entryPointNode);
                    }
                }

                graphRoots.TrimExcess();

                return(graphRoots);
            }
        }