{"action":"created","comment":{"url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/comments/79711270","id":79711270,"diff_hunk":"@@ -0,0 +1,437 @@\n+﻿// Copyright (c) .NET Foundation. All rights reserved.\n+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\n+\n+using System;\n+using System.Collections.Generic;\n+using System.Diagnostics;\n+using System.Globalization;\n+using System.IO;\n+using System.Linq;\n+using System.Threading.Tasks;\n+using EnvDTE;\n+using Microsoft.VisualStudio;\n+using Microsoft.VisualStudio.Shell;\n+using Microsoft.VisualStudio.Shell.Interop;\n+using NuGet.Common;\n+using NuGet.ProjectManagement;\n+using NuGet.ProjectModel;\n+using VSLangProj;\n+using VSLangProj80;\n+using EnvDTEProject = EnvDTE.Project;\n+\n+namespace NuGet.PackageManagement.VisualStudio\n+{\n+    public static class VSProjectReferenceUtility\n+    {\n+        /// <summary>\n+        /// Returns the closure of all project to project references below this project. While calculating the closure,\n+        /// this method populates the <see cref=\"ExternalProjectReferenceContext.ClosureCache\"/> and the\n+        /// <see cref=\"ExternalProjectReferenceContext.DirectReferenceCache\"/>.\n+        /// </summary>\n+        /// <remarks>This uses DTE and should be called from the UI thread.</remarks>\n+        public static async Task<IReadOnlyList<ExternalProjectReference>> GetProjectReferenceClosureAsync(\n+            EnvDTEProject rootProject,\n+            ExternalProjectReferenceContext context)\n+        {\n+            // DTE calls need to be done from the main thread\n+            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();\n+\n+            var results = new HashSet<ExternalProjectReference>();\n+\n+            // projects to walk - DFS\n+            var toProcess = new Stack<DTEReference>();\n+\n+            // keep track of found projects to avoid duplicates\n+            var rootProjectPath = EnvDTEProjectUtility.GetFullProjectPath(rootProject);\n+\n+            // start with the current project\n+            toProcess.Push(new DTEReference(rootProject, rootProjectPath));\n+\n+            var itemsFactory = ServiceLocator.GetInstance<IVsEnumHierarchyItemsFactory>();\n+            var uniqueNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\n+\n+            // continue walking all project references until we run out\n+            while (toProcess.Count > 0)\n+            {\n+                var dteReference = toProcess.Pop();\n+\n+                // Find the path of the current project\n+                var projectPath = dteReference.Path;\n+                var project = dteReference.Project;\n+\n+                if (string.IsNullOrEmpty(projectPath) || !uniqueNames.Add(projectPath))\n+                {\n+                    // This has already been processed or does not exist\n+                    continue;\n+                }\n+\n+                IReadOnlyList<ExternalProjectReference> cacheReferences;\n+                if (context.ClosureCache.TryGetValue(projectPath, out cacheReferences))\n+                {\n+                    // The cached value contains the entire closure, add it to the results and skip\n+                    // all child references.\n+                    results.UnionWith(cacheReferences);\n+                }\n+                else\n+                {\n+                    // Get direct references\n+                    var projectResult = GetDirectProjectReferences(\n+                        dteReference.Project,\n+                        projectPath,\n+                        itemsFactory,\n+                        rootProjectPath,\n+                        context.Logger);\n+\n+                    // Add results to the closure\n+                    results.UnionWith(projectResult.Processed);\n+\n+                    // Continue processing\n+                    foreach (var item in projectResult.ToProcess)\n+                    {\n+                        toProcess.Push(item);\n+                    }\n+                }\n+            }\n+\n+            // Cache the results for this project and every child project which has not been cached\n+            foreach (var project in results)\n+            {\n+                if (!context.ClosureCache.ContainsKey(project.MSBuildProjectPath))\n+                {\n+                    var closure = DependencyGraphProjectCacheUtility.GetExternalClosure(project.UniqueName, results);\n+                    var direct = DependencyGraphProjectCacheUtility.GetDirectReferences(project.UniqueName, closure);","path":"src/NuGet.Clients/PackageManagement.VisualStudio/IDE/VsProjectReferenceUtility.cs","position":102,"original_position":102,"commit_id":"5923d488084036945f3139f5769ddafb17bde24a","original_commit_id":"5923d488084036945f3139f5769ddafb17bde24a","user":{"login":"jainaashish","id":18219758,"avatar_url":"https://avatars.githubusercontent.com/u/18219758?v=3","gravatar_id":"","url":"https://api.github.com/users/jainaashish","html_url":"https://github.com/jainaashish","followers_url":"https://api.github.com/users/jainaashish/followers","following_url":"https://api.github.com/users/jainaashish/following{/other_user}","gists_url":"https://api.github.com/users/jainaashish/gists{/gist_id}","starred_url":"https://api.github.com/users/jainaashish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jainaashish/subscriptions","organizations_url":"https://api.github.com/users/jainaashish/orgs","repos_url":"https://api.github.com/users/jainaashish/repos","events_url":"https://api.github.com/users/jainaashish/events{/privacy}","received_events_url":"https://api.github.com/users/jainaashish/received_events","type":"User","site_admin":false},"body":"Why don't you add direct references in the else part where you get direct references in first place? That way you won't need an additional api for this.","created_at":"2016-09-20T21:00:29Z","updated_at":"2016-09-20T21:00:29Z","html_url":"https://github.com/NuGet/NuGet.Client/pull/877#discussion_r79711270","pull_request_url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/877","_links":{"self":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/comments/79711270"},"html":{"href":"https://github.com/NuGet/NuGet.Client/pull/877#discussion_r79711270"},"pull_request":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/877"}}},"pull_request":{"url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/877","id":85891118,"html_url":"https://github.com/NuGet/NuGet.Client/pull/877","diff_url":"https://github.com/NuGet/NuGet.Client/pull/877.diff","patch_url":"https://github.com/NuGet/NuGet.Client/pull/877.patch","issue_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues/877","number":877,"state":"open","locked":false,"title":"Include all project types in the DependencyGraphSpec on-build restore (Visual Studio)","user":{"login":"joelverhagen","id":94054,"avatar_url":"https://avatars.githubusercontent.com/u/94054?v=3","gravatar_id":"","url":"https://api.github.com/users/joelverhagen","html_url":"https://github.com/joelverhagen","followers_url":"https://api.github.com/users/joelverhagen/followers","following_url":"https://api.github.com/users/joelverhagen/following{/other_user}","gists_url":"https://api.github.com/users/joelverhagen/gists{/gist_id}","starred_url":"https://api.github.com/users/joelverhagen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelverhagen/subscriptions","organizations_url":"https://api.github.com/users/joelverhagen/orgs","repos_url":"https://api.github.com/users/joelverhagen/repos","events_url":"https://api.github.com/users/joelverhagen/events{/privacy}","received_events_url":"https://api.github.com/users/joelverhagen/received_events","type":"User","site_admin":false},"body":"This takes the UWP project.json restore logic and refactors it to include all project types (except .xproj) and uses the `DependencyGraphSpec`-based restore.\r\n\r\nThis addresses https://github.com/NuGet/Home/issues/3455.\r\n\r\nNote that this is going into the `dev-msbuild` branch, not `dev` (yet).\r\n\r\n/cc @jainaashish @alpaix @emgarten ","created_at":"2016-09-20T00:09:13Z","updated_at":"2016-09-20T21:00:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cdf735ece34b24f17daab60e134585db0ef63a87","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/877/commits","review_comments_url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/877/comments","review_comment_url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues/877/comments","statuses_url":"https://api.github.com/repos/NuGet/NuGet.Client/statuses/5923d488084036945f3139f5769ddafb17bde24a","head":{"label":"NuGet:jver-buildrestore","ref":"jver-buildrestore","sha":"5923d488084036945f3139f5769ddafb17bde24a","user":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"repo":{"id":19330736,"name":"NuGet.Client","full_name":"NuGet/NuGet.Client","owner":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NuGet/NuGet.Client","description":"Core client libraries for NuGet Services","fork":false,"url":"https://api.github.com/repos/NuGet/NuGet.Client","forks_url":"https://api.github.com/repos/NuGet/NuGet.Client/forks","keys_url":"https://api.github.com/repos/NuGet/NuGet.Client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NuGet/NuGet.Client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NuGet/NuGet.Client/teams","hooks_url":"https://api.github.com/repos/NuGet/NuGet.Client/hooks","issue_events_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues/events{/number}","events_url":"https://api.github.com/repos/NuGet/NuGet.Client/events","assignees_url":"https://api.github.com/repos/NuGet/NuGet.Client/assignees{/user}","branches_url":"https://api.github.com/repos/NuGet/NuGet.Client/branches{/branch}","tags_url":"https://api.github.com/repos/NuGet/NuGet.Client/tags","blobs_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/refs{/sha}","trees_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NuGet/NuGet.Client/statuses/{sha}","languages_url":"https://api.github.com/repos/NuGet/NuGet.Client/languages","stargazers_url":"https://api.github.com/repos/NuGet/NuGet.Client/stargazers","contributors_url":"https://api.github.com/repos/NuGet/NuGet.Client/contributors","subscribers_url":"https://api.github.com/repos/NuGet/NuGet.Client/subscribers","subscription_url":"https://api.github.com/repos/NuGet/NuGet.Client/subscription","commits_url":"https://api.github.com/repos/NuGet/NuGet.Client/commits{/sha}","git_commits_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/commits{/sha}","comments_url":"https://api.github.com/repos/NuGet/NuGet.Client/comments{/number}","issue_comment_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues/comments{/number}","contents_url":"https://api.github.com/repos/NuGet/NuGet.Client/contents/{+path}","compare_url":"https://api.github.com/repos/NuGet/NuGet.Client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NuGet/NuGet.Client/merges","archive_url":"https://api.github.com/repos/NuGet/NuGet.Client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NuGet/NuGet.Client/downloads","issues_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues{/number}","pulls_url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls{/number}","milestones_url":"https://api.github.com/repos/NuGet/NuGet.Client/milestones{/number}","notifications_url":"https://api.github.com/repos/NuGet/NuGet.Client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NuGet/NuGet.Client/labels{/name}","releases_url":"https://api.github.com/repos/NuGet/NuGet.Client/releases{/id}","deployments_url":"https://api.github.com/repos/NuGet/NuGet.Client/deployments","created_at":"2014-04-30T23:46:11Z","updated_at":"2016-09-19T22:11:23Z","pushed_at":"2016-09-20T20:32:47Z","git_url":"git://github.com/NuGet/NuGet.Client.git","ssh_url":"git@github.com:NuGet/NuGet.Client.git","clone_url":"https://github.com/NuGet/NuGet.Client.git","svn_url":"https://github.com/NuGet/NuGet.Client","homepage":null,"size":30048,"stargazers_count":98,"watchers_count":98,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":136,"mirror_url":null,"open_issues_count":28,"forks":136,"open_issues":28,"watchers":98,"default_branch":"dev"}},"base":{"label":"NuGet:dev-msbuild","ref":"dev-msbuild","sha":"9df799cef33ba02025c745076af7c9483cb9353d","user":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"repo":{"id":19330736,"name":"NuGet.Client","full_name":"NuGet/NuGet.Client","owner":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NuGet/NuGet.Client","description":"Core client libraries for NuGet Services","fork":false,"url":"https://api.github.com/repos/NuGet/NuGet.Client","forks_url":"https://api.github.com/repos/NuGet/NuGet.Client/forks","keys_url":"https://api.github.com/repos/NuGet/NuGet.Client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NuGet/NuGet.Client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NuGet/NuGet.Client/teams","hooks_url":"https://api.github.com/repos/NuGet/NuGet.Client/hooks","issue_events_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues/events{/number}","events_url":"https://api.github.com/repos/NuGet/NuGet.Client/events","assignees_url":"https://api.github.com/repos/NuGet/NuGet.Client/assignees{/user}","branches_url":"https://api.github.com/repos/NuGet/NuGet.Client/branches{/branch}","tags_url":"https://api.github.com/repos/NuGet/NuGet.Client/tags","blobs_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/refs{/sha}","trees_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NuGet/NuGet.Client/statuses/{sha}","languages_url":"https://api.github.com/repos/NuGet/NuGet.Client/languages","stargazers_url":"https://api.github.com/repos/NuGet/NuGet.Client/stargazers","contributors_url":"https://api.github.com/repos/NuGet/NuGet.Client/contributors","subscribers_url":"https://api.github.com/repos/NuGet/NuGet.Client/subscribers","subscription_url":"https://api.github.com/repos/NuGet/NuGet.Client/subscription","commits_url":"https://api.github.com/repos/NuGet/NuGet.Client/commits{/sha}","git_commits_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/commits{/sha}","comments_url":"https://api.github.com/repos/NuGet/NuGet.Client/comments{/number}","issue_comment_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues/comments{/number}","contents_url":"https://api.github.com/repos/NuGet/NuGet.Client/contents/{+path}","compare_url":"https://api.github.com/repos/NuGet/NuGet.Client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NuGet/NuGet.Client/merges","archive_url":"https://api.github.com/repos/NuGet/NuGet.Client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NuGet/NuGet.Client/downloads","issues_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues{/number}","pulls_url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls{/number}","milestones_url":"https://api.github.com/repos/NuGet/NuGet.Client/milestones{/number}","notifications_url":"https://api.github.com/repos/NuGet/NuGet.Client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NuGet/NuGet.Client/labels{/name}","releases_url":"https://api.github.com/repos/NuGet/NuGet.Client/releases{/id}","deployments_url":"https://api.github.com/repos/NuGet/NuGet.Client/deployments","created_at":"2014-04-30T23:46:11Z","updated_at":"2016-09-19T22:11:23Z","pushed_at":"2016-09-20T20:32:47Z","git_url":"git://github.com/NuGet/NuGet.Client.git","ssh_url":"git@github.com:NuGet/NuGet.Client.git","clone_url":"https://github.com/NuGet/NuGet.Client.git","svn_url":"https://github.com/NuGet/NuGet.Client","homepage":null,"size":30048,"stargazers_count":98,"watchers_count":98,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":136,"mirror_url":null,"open_issues_count":28,"forks":136,"open_issues":28,"watchers":98,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/877"},"html":{"href":"https://github.com/NuGet/NuGet.Client/pull/877"},"issue":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/issues/877"},"comments":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/issues/877/comments"},"review_comments":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/877/comments"},"review_comment":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/877/commits"},"statuses":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/statuses/5923d488084036945f3139f5769ddafb17bde24a"}}}}
{"actor":{"display_login":"jainaashish"}}