コード例 #1
0
        internal async Task <IDictionary <string, List <IVsProjectAdapter> > > GetDependentProjectsDictionaryAsync()
        {
            // Get all of the projects in the solution and build the reverse graph. i.e.
            // if A has a project reference to B (A -> B) the this will return B -> A
            // We need to run this on the ui thread so that it doesn't freeze for websites. Since there might be a
            // large number of references.
            await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            await EnsureInitializeAsync();

            var dependentProjectsDictionary = new Dictionary <string, List <IVsProjectAdapter> >();
            var vsProjectAdapters           = await GetAllVsProjectAdaptersAsync();

            foreach (var vsProjectAdapter in vsProjectAdapters)
            {
                var referencedProjects = await vsProjectAdapter.GetReferencedProjectsAsync();

                foreach (var projectProjectPath in referencedProjects)
                {
                    var result = _projectSystemCache.TryGetVsProjectAdapter(projectProjectPath, out var vsReferencedProject);
                    if (result)
                    {
                        AddDependentProject(dependentProjectsDictionary, vsReferencedProject, vsProjectAdapter);
                    }
                }
            }

            return(dependentProjectsDictionary);
        }