{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/34073603","id":34073603,"diff_hunk":"@@ -2713,61 +2713,66 @@ public override int GetHashCode()\n     /// </summary>\n     public struct NamespaceDefinitionHandle : IEquatable<NamespaceDefinitionHandle>\n     {\n-        // At this time, IsVirtual is always false because namespace names come from type definitions \n-        // and type forwarders only, which never get their namespaces projected.\n-        // \n-        // For Namespace, the offset is to the null-terminated full name of the \n-        // namespace in the #String heap.\n+        // Non-virtual (namespace having at least one type or forwarder of its own) \n+        // heap offset is to the null-terminated full name of the namespace in the \n+        // #String heap.\n         //\n-        // For SyntheticNamespace, the offset points to the dot-terminated simple name of the namespace\n-        // in the #String heap. This is used to represent namespaces that are parents of other namespaces\n-        // but no type definitions or forwarders of their own.\n+        // Virtual (namespace having child namespaces but no types of its own) \n+        // the virtual index is an auto-incremented value and serves solely to \n+        // create unique values for indexing into the NamespaceCache.\n \n         // bits:\n-        //     31: IsVirtual (0)\n-        // 29..31: type (non-virtual: Namespace, SyntheticNamespace)\n+        //     31: IsVirtual\n+        // 29..31: 0\n         //  0..28: Heap offset or Virtual index\n         private readonly uint _value;\n \n         private NamespaceDefinitionHandle(uint value)\n         {\n-            // note: no virtual namespaces allowed\n-            Debug.Assert((value & HeapHandleType.TypeMask) == NamespaceHandleType.Namespace ||\n-                         (value & HeapHandleType.TypeMask) == NamespaceHandleType.SyntheticNamespace);\n-\n             _value = value;\n         }\n \n         internal static NamespaceDefinitionHandle FromFullNameOffset(int stringHeapOffset)\n         {\n-            return new NamespaceDefinitionHandle(NamespaceHandleType.Namespace | (uint)stringHeapOffset);\n+            return new NamespaceDefinitionHandle((uint)stringHeapOffset);\n         }\n \n-        internal static NamespaceDefinitionHandle FromSimpleNameOffset(int stringHeapOffset)\n+        internal static NamespaceDefinitionHandle FromVirtualIndex(uint virtualIndex)\n         {\n-            return new NamespaceDefinitionHandle(NamespaceHandleType.SyntheticNamespace | (uint)stringHeapOffset);\n+            // we arbitrarily disallow 0 virtual index to simplify nil check.\n+            Debug.Assert(virtualIndex != 0); \n+\n+            if (!HeapHandleType.IsValidHeapOffset(virtualIndex))\n+            {\n+                // only a pathological assembly would hit this, but it must fit in 29 bits.\n+                ThrowTooManySubnamespaces();\n+            }\n+\n+            return new NamespaceDefinitionHandle(TokenTypeIds.VirtualBit | virtualIndex);\n+        }\n+\n+        [MethodImpl(MethodImplOptions.NoInlining)]","path":"src/System.Reflection.Metadata/src/System/Reflection/Metadata/Handles.cs","position":59,"original_position":59,"commit_id":"a4ecef2c659586922512a9b6ce43e6091ebf6a94","original_commit_id":"a4ecef2c659586922512a9b6ce43e6091ebf6a94","user":{"login":"nguerrera","id":75470,"avatar_url":"https://avatars.githubusercontent.com/u/75470?v=3","gravatar_id":"","url":"https://api.github.com/users/nguerrera","html_url":"https://github.com/nguerrera","followers_url":"https://api.github.com/users/nguerrera/followers","following_url":"https://api.github.com/users/nguerrera/following{/other_user}","gists_url":"https://api.github.com/users/nguerrera/gists{/gist_id}","starred_url":"https://api.github.com/users/nguerrera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguerrera/subscriptions","organizations_url":"https://api.github.com/users/nguerrera/orgs","repos_url":"https://api.github.com/users/nguerrera/repos","events_url":"https://api.github.com/users/nguerrera/events{/privacy}","received_events_url":"https://api.github.com/users/nguerrera/received_events","type":"User","site_admin":false},"body":"Yes. Either that or FromVirtualIndex gets inlined but uses unnecessary space in its caller. A similar pattern applied to BlobReader made a very measurable difference. With that said, this case is not very highly travelled and it probably doesn't matter here.  I find it easier to keep the whole library consistent than to decide on each throw on a case-by-case basis. \r\n\r\nI've filed #2261 to re-organize so that the approach is centralized and documented.\r\n","created_at":"2015-07-07T18:31:08Z","updated_at":"2015-07-07T18:31:08Z","html_url":"https://github.com/dotnet/corefx/pull/2245#discussion_r34073603","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/2245","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/34073603"},"html":{"href":"https://github.com/dotnet/corefx/pull/2245#discussion_r34073603"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2245"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/2245","id":39203337,"html_url":"https://github.com/dotnet/corefx/pull/2245","diff_url":"https://github.com/dotnet/corefx/pull/2245.diff","patch_url":"https://github.com/dotnet/corefx/pull/2245.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/2245","number":2245,"state":"open","locked":false,"title":" Fix issue with multiple namespaces having same suffix ","user":{"login":"nguerrera","id":75470,"avatar_url":"https://avatars.githubusercontent.com/u/75470?v=3","gravatar_id":"","url":"https://api.github.com/users/nguerrera","html_url":"https://github.com/nguerrera","followers_url":"https://api.github.com/users/nguerrera/followers","following_url":"https://api.github.com/users/nguerrera/following{/other_user}","gists_url":"https://api.github.com/users/nguerrera/gists{/gist_id}","starred_url":"https://api.github.com/users/nguerrera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguerrera/subscriptions","organizations_url":"https://api.github.com/users/nguerrera/orgs","repos_url":"https://api.github.com/users/nguerrera/repos","events_url":"https://api.github.com/users/nguerrera/events{/privacy}","received_events_url":"https://api.github.com/users/nguerrera/received_events","type":"User","site_admin":false},"body":"For so-called synthetic namespaces (which have no types of their own,\r\nonly child namespaces), we were using the string heap offset to its\r\ndot-terminated name as a unique handle value. However, compilers are\r\nsmart in the case where namespace overlap such as\r\nFxResources.Microsoft.CSharp and Microsoft.CSharp and re-use the same\r\nbytes in the string heap. As such, the value is not unique.\r\n\r\nIt turns out that we don't actually retrieve the simple name from the\r\nhandle so the fix is to use an auto-incrementing counter instead of the\r\nsimple name offset as the handle value.","created_at":"2015-07-04T06:06:18Z","updated_at":"2015-07-07T18:31:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a1a6195e37b80d802742a8030030127be2b64bbc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/2245/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/2245/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/2245/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/a4ecef2c659586922512a9b6ce43e6091ebf6a94","head":{"label":"nguerrera:namespace-crash","ref":"namespace-crash","sha":"a4ecef2c659586922512a9b6ce43e6091ebf6a94","user":{"login":"nguerrera","id":75470,"avatar_url":"https://avatars.githubusercontent.com/u/75470?v=3","gravatar_id":"","url":"https://api.github.com/users/nguerrera","html_url":"https://github.com/nguerrera","followers_url":"https://api.github.com/users/nguerrera/followers","following_url":"https://api.github.com/users/nguerrera/following{/other_user}","gists_url":"https://api.github.com/users/nguerrera/gists{/gist_id}","starred_url":"https://api.github.com/users/nguerrera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguerrera/subscriptions","organizations_url":"https://api.github.com/users/nguerrera/orgs","repos_url":"https://api.github.com/users/nguerrera/repos","events_url":"https://api.github.com/users/nguerrera/events{/privacy}","received_events_url":"https://api.github.com/users/nguerrera/received_events","type":"User","site_admin":false},"repo":{"id":26595340,"name":"corefx","full_name":"nguerrera/corefx","owner":{"login":"nguerrera","id":75470,"avatar_url":"https://avatars.githubusercontent.com/u/75470?v=3","gravatar_id":"","url":"https://api.github.com/users/nguerrera","html_url":"https://github.com/nguerrera","followers_url":"https://api.github.com/users/nguerrera/followers","following_url":"https://api.github.com/users/nguerrera/following{/other_user}","gists_url":"https://api.github.com/users/nguerrera/gists{/gist_id}","starred_url":"https://api.github.com/users/nguerrera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguerrera/subscriptions","organizations_url":"https://api.github.com/users/nguerrera/orgs","repos_url":"https://api.github.com/users/nguerrera/repos","events_url":"https://api.github.com/users/nguerrera/events{/privacy}","received_events_url":"https://api.github.com/users/nguerrera/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nguerrera/corefx","description":"This repository contains the foundational libraries that make up the .NET Core development stack.","fork":true,"url":"https://api.github.com/repos/nguerrera/corefx","forks_url":"https://api.github.com/repos/nguerrera/corefx/forks","keys_url":"https://api.github.com/repos/nguerrera/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nguerrera/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nguerrera/corefx/teams","hooks_url":"https://api.github.com/repos/nguerrera/corefx/hooks","issue_events_url":"https://api.github.com/repos/nguerrera/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/nguerrera/corefx/events","assignees_url":"https://api.github.com/repos/nguerrera/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/nguerrera/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/nguerrera/corefx/tags","blobs_url":"https://api.github.com/repos/nguerrera/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nguerrera/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nguerrera/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/nguerrera/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nguerrera/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/nguerrera/corefx/languages","stargazers_url":"https://api.github.com/repos/nguerrera/corefx/stargazers","contributors_url":"https://api.github.com/repos/nguerrera/corefx/contributors","subscribers_url":"https://api.github.com/repos/nguerrera/corefx/subscribers","subscription_url":"https://api.github.com/repos/nguerrera/corefx/subscription","commits_url":"https://api.github.com/repos/nguerrera/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/nguerrera/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/nguerrera/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/nguerrera/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/nguerrera/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/nguerrera/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nguerrera/corefx/merges","archive_url":"https://api.github.com/repos/nguerrera/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nguerrera/corefx/downloads","issues_url":"https://api.github.com/repos/nguerrera/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/nguerrera/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/nguerrera/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/nguerrera/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nguerrera/corefx/labels{/name}","releases_url":"https://api.github.com/repos/nguerrera/corefx/releases{/id}","created_at":"2014-11-13T15:55:24Z","updated_at":"2015-05-06T15:18:24Z","pushed_at":"2015-07-07T17:29:03Z","git_url":"git://github.com/nguerrera/corefx.git","ssh_url":"git@github.com:nguerrera/corefx.git","clone_url":"https://github.com/nguerrera/corefx.git","svn_url":"https://github.com/nguerrera/corefx","homepage":"","size":23992,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"9f89acbc8ae5f3ecd5affe44ca07820e252f2c5f","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":26295345,"name":"corefx","full_name":"dotnet/corefx","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/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":false,"url":"https://api.github.com/repos/dotnet/corefx","forks_url":"https://api.github.com/repos/dotnet/corefx/forks","keys_url":"https://api.github.com/repos/dotnet/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corefx/teams","hooks_url":"https://api.github.com/repos/dotnet/corefx/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corefx/events","assignees_url":"https://api.github.com/repos/dotnet/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corefx/tags","blobs_url":"https://api.github.com/repos/dotnet/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corefx/languages","stargazers_url":"https://api.github.com/repos/dotnet/corefx/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corefx/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corefx/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corefx/subscription","commits_url":"https://api.github.com/repos/dotnet/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corefx/merges","archive_url":"https://api.github.com/repos/dotnet/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corefx/downloads","issues_url":"https://api.github.com/repos/dotnet/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corefx/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corefx/releases{/id}","created_at":"2014-11-06T23:42:48Z","updated_at":"2015-07-07T18:22:56Z","pushed_at":"2015-07-07T18:28:00Z","git_url":"git://github.com/dotnet/corefx.git","ssh_url":"git@github.com:dotnet/corefx.git","clone_url":"https://github.com/dotnet/corefx.git","svn_url":"https://github.com/dotnet/corefx","homepage":"http://dotnet.github.io/core/","size":50103,"stargazers_count":8012,"watchers_count":8012,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1655,"mirror_url":null,"open_issues_count":462,"forks":1655,"open_issues":462,"watchers":8012,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2245"},"html":{"href":"https://github.com/dotnet/corefx/pull/2245"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/2245"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/2245/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2245/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2245/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/a4ecef2c659586922512a9b6ce43e6091ebf6a94"}}}}