Exemple #1
0
            /// <summary>
            /// TODO: Logic is very similar to CreateProjectInfos - can we reduce the duplication?
            /// </summary>
            async Task <ConcurrentBag <ProjectInfo> > CreateProjectInfosFromCache(IEnumerable <MonoDevelop.Projects.Project> mdProjects, CancellationToken token)
            {
                var projects = new ConcurrentBag <ProjectInfo> ();
                var allTasks = new List <Task> ();

                foreach (var proj in mdProjects)
                {
                    if (token.IsCancellationRequested)
                    {
                        return(null);
                    }
                    if (!CanLoadProject(proj))
                    {
                        continue;
                    }
                    foreach (string framework in GetFrameworks(proj))
                    {
                        if (!workspaceCache.TryGetCachedItems(proj, workspace.MetadataReferenceManager, projectMap, framework, out var cacheInfo))
                        {
                            continue;
                        }

                        var tp = LoadProject(proj, token, null, cacheInfo, framework).ContinueWith(t => {
                            if (!t.IsCanceled)
                            {
                                projects.Add(t.Result);
                            }
                        }, TaskContinuationOptions.ExecuteSynchronously);
                        allTasks.Add(tp);
                    }
                }

                if (allTasks.Count == 0)
                {
                    return(null);
                }

                await Task.WhenAll(allTasks.ToArray()).ConfigureAwait(false);

                if (token.IsCancellationRequested)
                {
                    return(null);
                }

                return(projects);
            }
        static ProjectCacheInfo GetProjectCacheInfo(Solution sol, Project p)
        {
            var ws    = IdeServices.TypeSystemService.GetWorkspace(sol);
            var cache = new WorkspaceFilesCache();

            cache.Load(sol);

            if (cache.TryGetCachedItems(p, ws.MetadataReferenceManager, ws.ProjectMap, out ProjectCacheInfo cacheInfo))
            {
                return(cacheInfo);
            }
            return(null);
        }