{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/40878264","id":40878264,"diff_hunk":"@@ -45,60 +57,224 @@ internal partial class CommonReferenceManager<TCompilation, TAssemblySymbol>\n         /// -    Result of resolving assembly references of the corresponding assembly \n         ///     against provided set of assembly definitions. Essentially, this is an array returned by\n         ///     <see cref=\"AssemblyData.BindAssemblyReferences(ImmutableArray{AssemblyData}, AssemblyIdentityComparer)\"/> method.\n-        /// </returns>\n+        /// </return>\n         internal BoundInputAssembly[] Bind(\n-            ImmutableArray<AssemblyData> assemblies,\n+            ref ImmutableArray<AssemblyData> assemblies,\n+            MetadataReferenceResolver resolverOpt,\n+            MetadataImportOptions importOptions,\n+            ArrayBuilder<MetadataReference> implicitlyResolvedReferences,\n+            DiagnosticBag resolutionDiagnostics,\n             out bool hasCircularReference,\n             out int corLibraryIndex)\n         {\n             Debug.Assert(!assemblies.IsDefault);\n \n-            int totalAssemblies = assemblies.Length;\n+            var referenceBindings = ArrayBuilder<AssemblyReferenceBinding[]>.GetInstance();\n+            try\n+            {\n+                // Based on assembly identity, for each assembly, \n+                // bind its references against the other assemblies we have.\n+                for (int i = 0; i < assemblies.Length; i++)\n+                {\n+                    referenceBindings.Add(assemblies[i].BindAssemblyReferences(assemblies, IdentityComparer));\n+                }\n+\n+                if (resolverOpt?.ResolveMissingAssemblies == true)\n+                {\n+                    ResolveAndBindMissingAssemblies(assemblies, referenceBindings, implicitlyResolvedReferences, resolverOpt, importOptions, resolutionDiagnostics, out assemblies);\n+                }\n+\n+                hasCircularReference = CheckCircularReference(referenceBindings);\n+\n+                corLibraryIndex = IndexOfCorLibrary(assemblies);\n+\n+                // For each assembly, locate AssemblySymbol with similar reference resolution\n+                // What does similar mean?\n+                // Similar means: \n+                // 1) The same references are resolved against the assemblies that we are given.\n+                // 2) The same assembly is used as the COR library.\n+\n+                var boundInputs = new BoundInputAssembly[referenceBindings.Count];","path":"src/Compilers/Core/Portable/ReferenceManager/CommonReferenceManager.Binding.cs","position":90,"original_position":90,"commit_id":"1115a3261b1312e3bb24994036aa0b0bdb546a2d","original_commit_id":"1115a3261b1312e3bb24994036aa0b0bdb546a2d","user":{"login":"AlekseyTs","id":10522107,"avatar_url":"https://avatars.githubusercontent.com/u/10522107?v=3","gravatar_id":"","url":"https://api.github.com/users/AlekseyTs","html_url":"https://github.com/AlekseyTs","followers_url":"https://api.github.com/users/AlekseyTs/followers","following_url":"https://api.github.com/users/AlekseyTs/following{/other_user}","gists_url":"https://api.github.com/users/AlekseyTs/gists{/gist_id}","starred_url":"https://api.github.com/users/AlekseyTs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlekseyTs/subscriptions","organizations_url":"https://api.github.com/users/AlekseyTs/orgs","repos_url":"https://api.github.com/users/AlekseyTs/repos","events_url":"https://api.github.com/users/AlekseyTs/events{/privacy}","received_events_url":"https://api.github.com/users/AlekseyTs/received_events","type":"User","site_admin":false},"body":"Are referenceBindings and assemblies supposed to have the same number of elements at this point? Consider asserting if this is a valid expectation.","created_at":"2015-10-01T04:27:49Z","updated_at":"2015-10-01T04:27:49Z","html_url":"https://github.com/dotnet/roslyn/pull/5507#discussion_r40878264","pull_request_url":"https://api.github.com/repos/dotnet/roslyn/pulls/5507","_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/40878264"},"html":{"href":"https://github.com/dotnet/roslyn/pull/5507#discussion_r40878264"},"pull_request":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/5507"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/5507","id":46219288,"html_url":"https://github.com/dotnet/roslyn/pull/5507","diff_url":"https://github.com/dotnet/roslyn/pull/5507.diff","patch_url":"https://github.com/dotnet/roslyn/pull/5507.patch","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/5507","number":5507,"state":"open","locked":false,"title":"Missing assembly resolution","user":{"login":"tmat","id":41759,"avatar_url":"https://avatars.githubusercontent.com/u/41759?v=3","gravatar_id":"","url":"https://api.github.com/users/tmat","html_url":"https://github.com/tmat","followers_url":"https://api.github.com/users/tmat/followers","following_url":"https://api.github.com/users/tmat/following{/other_user}","gists_url":"https://api.github.com/users/tmat/gists{/gist_id}","starred_url":"https://api.github.com/users/tmat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmat/subscriptions","organizations_url":"https://api.github.com/users/tmat/orgs","repos_url":"https://api.github.com/users/tmat/repos","events_url":"https://api.github.com/users/tmat/events{/privacy}","received_events_url":"https://api.github.com/users/tmat/received_events","type":"User","site_admin":false},"body":"Implements eager resolution of missing assemblies.\r\n\r\nCurrently all compilation references have to be specified explicitly and upfront, either via an \"external reference\" passed to a compilation constructor or via a directive reference (#r). This change enables the host to resolve assembly references that are not explicitly specified as they are discovered during reference binding. \r\n\r\nThe main goal is to require less references to be specified by the user in scripts and when executing interactive code. For example, when a portable library is referenced by a Desktop app, the facades need to be referenced as well. With this change the user only needs to #r the library. The compiler will discover that facades are needed and asks the host thru new API on ```MetadataReferenceResolver.ResolveMissingAssembly```. The host can than check whether the required dependency is available at runtime and if so return it to the compiler. Thus not bothering the user with error message like \"A reference to System.Runtime is missing and needs to be added\" when the host actually knows where to find such reference.\r\n\r\nThe resolution is transitive -- all references of the explicit references passed to the compilation are examined and can be potentially loaded by the host. Since this resolution is integrated into the reference binding logic it is semantically indistinguishable from explicitly passing all missing references upfront.\r\n\r\nI have considered resolving the missing dependencies lazily. Delaying the resolution until the missing symbols are actually used is viable however the implementation is much more complex and to avoid versioning issues certain restrictions need to be enforced (such as no missing assemblies can differ in version, a missing assembly can't be added with aliases or NoPia embedding). ","created_at":"2015-09-28T23:08:37Z","updated_at":"2015-10-01T04:27:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7ba8c3674374f2a80853743de75489489127837","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/roslyn/pulls/5507/commits","review_comments_url":"https://api.github.com/repos/dotnet/roslyn/pulls/5507/comments","review_comment_url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/5507/comments","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/1115a3261b1312e3bb24994036aa0b0bdb546a2d","head":{"label":"tmat:EagerMissingAssemblyResolution","ref":"EagerMissingAssemblyResolution","sha":"1115a3261b1312e3bb24994036aa0b0bdb546a2d","user":{"login":"tmat","id":41759,"avatar_url":"https://avatars.githubusercontent.com/u/41759?v=3","gravatar_id":"","url":"https://api.github.com/users/tmat","html_url":"https://github.com/tmat","followers_url":"https://api.github.com/users/tmat/followers","following_url":"https://api.github.com/users/tmat/following{/other_user}","gists_url":"https://api.github.com/users/tmat/gists{/gist_id}","starred_url":"https://api.github.com/users/tmat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmat/subscriptions","organizations_url":"https://api.github.com/users/tmat/orgs","repos_url":"https://api.github.com/users/tmat/repos","events_url":"https://api.github.com/users/tmat/events{/privacy}","received_events_url":"https://api.github.com/users/tmat/received_events","type":"User","site_admin":false},"repo":{"id":30440379,"name":"roslyn","full_name":"tmat/roslyn","owner":{"login":"tmat","id":41759,"avatar_url":"https://avatars.githubusercontent.com/u/41759?v=3","gravatar_id":"","url":"https://api.github.com/users/tmat","html_url":"https://github.com/tmat","followers_url":"https://api.github.com/users/tmat/followers","following_url":"https://api.github.com/users/tmat/following{/other_user}","gists_url":"https://api.github.com/users/tmat/gists{/gist_id}","starred_url":"https://api.github.com/users/tmat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmat/subscriptions","organizations_url":"https://api.github.com/users/tmat/orgs","repos_url":"https://api.github.com/users/tmat/repos","events_url":"https://api.github.com/users/tmat/events{/privacy}","received_events_url":"https://api.github.com/users/tmat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tmat/roslyn","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":true,"url":"https://api.github.com/repos/tmat/roslyn","forks_url":"https://api.github.com/repos/tmat/roslyn/forks","keys_url":"https://api.github.com/repos/tmat/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tmat/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tmat/roslyn/teams","hooks_url":"https://api.github.com/repos/tmat/roslyn/hooks","issue_events_url":"https://api.github.com/repos/tmat/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/tmat/roslyn/events","assignees_url":"https://api.github.com/repos/tmat/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/tmat/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/tmat/roslyn/tags","blobs_url":"https://api.github.com/repos/tmat/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tmat/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tmat/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/tmat/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tmat/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/tmat/roslyn/languages","stargazers_url":"https://api.github.com/repos/tmat/roslyn/stargazers","contributors_url":"https://api.github.com/repos/tmat/roslyn/contributors","subscribers_url":"https://api.github.com/repos/tmat/roslyn/subscribers","subscription_url":"https://api.github.com/repos/tmat/roslyn/subscription","commits_url":"https://api.github.com/repos/tmat/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/tmat/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/tmat/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/tmat/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/tmat/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/tmat/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tmat/roslyn/merges","archive_url":"https://api.github.com/repos/tmat/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tmat/roslyn/downloads","issues_url":"https://api.github.com/repos/tmat/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/tmat/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/tmat/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/tmat/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tmat/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/tmat/roslyn/releases{/id}","created_at":"2015-02-07T01:09:01Z","updated_at":"2015-05-08T18:44:57Z","pushed_at":"2015-09-30T20:03:37Z","git_url":"git://github.com/tmat/roslyn.git","ssh_url":"git@github.com:tmat/roslyn.git","clone_url":"https://github.com/tmat/roslyn.git","svn_url":"https://github.com/tmat/roslyn","homepage":"","size":102442,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"48bbdc5744981c3765c466170a272a0c14d78deb","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":29078997,"name":"roslyn","full_name":"dotnet/roslyn","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/roslyn","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":false,"url":"https://api.github.com/repos/dotnet/roslyn","forks_url":"https://api.github.com/repos/dotnet/roslyn/forks","keys_url":"https://api.github.com/repos/dotnet/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/roslyn/teams","hooks_url":"https://api.github.com/repos/dotnet/roslyn/hooks","issue_events_url":"https://api.github.com/repos/dotnet/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/roslyn/events","assignees_url":"https://api.github.com/repos/dotnet/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/roslyn/tags","blobs_url":"https://api.github.com/repos/dotnet/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/roslyn/languages","stargazers_url":"https://api.github.com/repos/dotnet/roslyn/stargazers","contributors_url":"https://api.github.com/repos/dotnet/roslyn/contributors","subscribers_url":"https://api.github.com/repos/dotnet/roslyn/subscribers","subscription_url":"https://api.github.com/repos/dotnet/roslyn/subscription","commits_url":"https://api.github.com/repos/dotnet/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/roslyn/merges","archive_url":"https://api.github.com/repos/dotnet/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/roslyn/downloads","issues_url":"https://api.github.com/repos/dotnet/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/roslyn/releases{/id}","created_at":"2015-01-11T02:39:03Z","updated_at":"2015-10-01T01:26:00Z","pushed_at":"2015-10-01T04:18:18Z","git_url":"git://github.com/dotnet/roslyn.git","ssh_url":"git@github.com:dotnet/roslyn.git","clone_url":"https://github.com/dotnet/roslyn.git","svn_url":"https://github.com/dotnet/roslyn","homepage":"","size":202786,"stargazers_count":3389,"watchers_count":3389,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":794,"mirror_url":null,"open_issues_count":1498,"forks":794,"open_issues":1498,"watchers":3389,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/5507"},"html":{"href":"https://github.com/dotnet/roslyn/pull/5507"},"issue":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/5507"},"comments":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/5507/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/5507/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/5507/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/roslyn/statuses/1115a3261b1312e3bb24994036aa0b0bdb546a2d"}}}}