{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corert/pulls/comments/106072151","pull_request_review_id":26957915,"id":106072151,"diff_hunk":"@@ -0,0 +1,205 @@\n+﻿// Licensed to the .NET Foundation under one or more agreements.\n+// The .NET Foundation licenses this file to you under the MIT license.\n+// See the LICENSE file in the project root for more information.\n+\n+using System;\n+using Internal.IL.Stubs;\n+using Internal.TypeSystem.Interop;\n+using Debug = System.Diagnostics.Debug;\n+\n+namespace Internal.TypeSystem\n+{\n+    /// <summary>\n+    /// This class manages and caches  interop state information\n+    /// </summary>\n+    public sealed class InteropStateManager\n+    {\n+        private readonly ModuleDesc _generatedAssembly;\n+        private readonly NativeStructTypeHashtable _nativeStructHashtable;\n+        private readonly StructMarshallingThunkHashTable _structMarshallingThunkHashtable;\n+\n+\n+        public InteropStateManager(ModuleDesc generatedAssembly)\n+        {\n+            _generatedAssembly = generatedAssembly;\n+            _structMarshallingThunkHashtable = new StructMarshallingThunkHashTable(this);\n+            _nativeStructHashtable = new NativeStructTypeHashtable(this);\n+        }\n+\n+        //\n+        //  Struct Marshalling \n+        //  To support struct marshalling compiler needs to generate a native type which\n+        //  imitates the original struct being passed to managed side with corresponding \n+        //  fields of marshalled types. Additionally it needs to generate three thunks\n+        //      1. Managed to Native Thunk: For forward marshalling\n+        //      2. Native to Managed Thunk: For reverse marshalling\n+        //      3. Cleanup Thunk: for cleaning up any allocated resources\n+        //\n+        /// <summary>\n+        /// Generates a Native struct type which imitates the managed struct\n+        /// </summary>\n+        internal NativeStructType GetStructMarshallingNativeType(TypeDesc managedType)\n+        {\n+            if (managedType is ByRefType)\n+            {\n+                managedType = ((ByRefType)managedType).GetParameterType();\n+            }\n+\n+            Debug.Assert(managedType is MetadataType);\n+\n+            var typeKey = new NativeStructTypeHashtableKey((MetadataType)managedType, _generatedAssembly);","path":"src/Common/src/TypeSystem/Interop/InteropStateManager.cs","position":50,"original_position":50,"commit_id":"891ba9faac806d2fe4b1bf820a7a7958b9fbd9ca","original_commit_id":"cb73525db428f46d009bbc7c6e90777d78db2b2c","user":{"login":"yizhang82","id":6903744,"avatar_url":"https://avatars2.githubusercontent.com/u/6903744?v=3","gravatar_id":"","url":"https://api.github.com/users/yizhang82","html_url":"https://github.com/yizhang82","followers_url":"https://api.github.com/users/yizhang82/followers","following_url":"https://api.github.com/users/yizhang82/following{/other_user}","gists_url":"https://api.github.com/users/yizhang82/gists{/gist_id}","starred_url":"https://api.github.com/users/yizhang82/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yizhang82/subscriptions","organizations_url":"https://api.github.com/users/yizhang82/orgs","repos_url":"https://api.github.com/users/yizhang82/repos","events_url":"https://api.github.com/users/yizhang82/events{/privacy}","received_events_url":"https://api.github.com/users/yizhang82/received_events","type":"User","site_admin":false},"body":"Why is _generatedAssembly part of the key?","created_at":"2017-03-15T02:08:36Z","updated_at":"2017-03-15T02:44:25Z","html_url":"https://github.com/dotnet/corert/pull/2943#discussion_r106072151","pull_request_url":"https://api.github.com/repos/dotnet/corert/pulls/2943","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corert/pulls/comments/106072151"},"html":{"href":"https://github.com/dotnet/corert/pull/2943#discussion_r106072151"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corert/pulls/2943"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corert/pulls/2943","id":110215944,"html_url":"https://github.com/dotnet/corert/pull/2943","diff_url":"https://github.com/dotnet/corert/pull/2943.diff","patch_url":"https://github.com/dotnet/corert/pull/2943.patch","issue_url":"https://api.github.com/repos/dotnet/corert/issues/2943","number":2943,"state":"open","locked":false,"title":"Struct Marshalling - initial implementation","user":{"login":"shrah","id":15021838,"avatar_url":"https://avatars2.githubusercontent.com/u/15021838?v=3","gravatar_id":"","url":"https://api.github.com/users/shrah","html_url":"https://github.com/shrah","followers_url":"https://api.github.com/users/shrah/followers","following_url":"https://api.github.com/users/shrah/following{/other_user}","gists_url":"https://api.github.com/users/shrah/gists{/gist_id}","starred_url":"https://api.github.com/users/shrah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shrah/subscriptions","organizations_url":"https://api.github.com/users/shrah/orgs","repos_url":"https://api.github.com/users/shrah/repos","events_url":"https://api.github.com/users/shrah/events{/privacy}","received_events_url":"https://api.github.com/users/shrah/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-03-10T21:49:33Z","updated_at":"2017-03-15T02:44:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"32e2ffeeb9b0059094ee6c8a05f4c9af8e170918","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corert/pulls/2943/commits","review_comments_url":"https://api.github.com/repos/dotnet/corert/pulls/2943/comments","review_comment_url":"https://api.github.com/repos/dotnet/corert/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corert/issues/2943/comments","statuses_url":"https://api.github.com/repos/dotnet/corert/statuses/891ba9faac806d2fe4b1bf820a7a7958b9fbd9ca","head":{"label":"shrah:struct","ref":"struct","sha":"891ba9faac806d2fe4b1bf820a7a7958b9fbd9ca","user":{"login":"shrah","id":15021838,"avatar_url":"https://avatars2.githubusercontent.com/u/15021838?v=3","gravatar_id":"","url":"https://api.github.com/users/shrah","html_url":"https://github.com/shrah","followers_url":"https://api.github.com/users/shrah/followers","following_url":"https://api.github.com/users/shrah/following{/other_user}","gists_url":"https://api.github.com/users/shrah/gists{/gist_id}","starred_url":"https://api.github.com/users/shrah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shrah/subscriptions","organizations_url":"https://api.github.com/users/shrah/orgs","repos_url":"https://api.github.com/users/shrah/repos","events_url":"https://api.github.com/users/shrah/events{/privacy}","received_events_url":"https://api.github.com/users/shrah/received_events","type":"User","site_admin":false},"repo":{"id":56826127,"name":"corert","full_name":"shrah/corert","owner":{"login":"shrah","id":15021838,"avatar_url":"https://avatars2.githubusercontent.com/u/15021838?v=3","gravatar_id":"","url":"https://api.github.com/users/shrah","html_url":"https://github.com/shrah","followers_url":"https://api.github.com/users/shrah/followers","following_url":"https://api.github.com/users/shrah/following{/other_user}","gists_url":"https://api.github.com/users/shrah/gists{/gist_id}","starred_url":"https://api.github.com/users/shrah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shrah/subscriptions","organizations_url":"https://api.github.com/users/shrah/orgs","repos_url":"https://api.github.com/users/shrah/repos","events_url":"https://api.github.com/users/shrah/events{/privacy}","received_events_url":"https://api.github.com/users/shrah/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shrah/corert","description":"This repo contains CoreRT, a .NET Core runtime optimized for AOT (ahead of time compilation) scenarios, with the accompanying .NET Native compiler toolchain.","fork":true,"url":"https://api.github.com/repos/shrah/corert","forks_url":"https://api.github.com/repos/shrah/corert/forks","keys_url":"https://api.github.com/repos/shrah/corert/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shrah/corert/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shrah/corert/teams","hooks_url":"https://api.github.com/repos/shrah/corert/hooks","issue_events_url":"https://api.github.com/repos/shrah/corert/issues/events{/number}","events_url":"https://api.github.com/repos/shrah/corert/events","assignees_url":"https://api.github.com/repos/shrah/corert/assignees{/user}","branches_url":"https://api.github.com/repos/shrah/corert/branches{/branch}","tags_url":"https://api.github.com/repos/shrah/corert/tags","blobs_url":"https://api.github.com/repos/shrah/corert/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shrah/corert/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shrah/corert/git/refs{/sha}","trees_url":"https://api.github.com/repos/shrah/corert/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shrah/corert/statuses/{sha}","languages_url":"https://api.github.com/repos/shrah/corert/languages","stargazers_url":"https://api.github.com/repos/shrah/corert/stargazers","contributors_url":"https://api.github.com/repos/shrah/corert/contributors","subscribers_url":"https://api.github.com/repos/shrah/corert/subscribers","subscription_url":"https://api.github.com/repos/shrah/corert/subscription","commits_url":"https://api.github.com/repos/shrah/corert/commits{/sha}","git_commits_url":"https://api.github.com/repos/shrah/corert/git/commits{/sha}","comments_url":"https://api.github.com/repos/shrah/corert/comments{/number}","issue_comment_url":"https://api.github.com/repos/shrah/corert/issues/comments{/number}","contents_url":"https://api.github.com/repos/shrah/corert/contents/{+path}","compare_url":"https://api.github.com/repos/shrah/corert/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shrah/corert/merges","archive_url":"https://api.github.com/repos/shrah/corert/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shrah/corert/downloads","issues_url":"https://api.github.com/repos/shrah/corert/issues{/number}","pulls_url":"https://api.github.com/repos/shrah/corert/pulls{/number}","milestones_url":"https://api.github.com/repos/shrah/corert/milestones{/number}","notifications_url":"https://api.github.com/repos/shrah/corert/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shrah/corert/labels{/name}","releases_url":"https://api.github.com/repos/shrah/corert/releases{/id}","deployments_url":"https://api.github.com/repos/shrah/corert/deployments","created_at":"2016-04-22T04:26:41Z","updated_at":"2016-04-22T04:26:47Z","pushed_at":"2017-03-15T01:26:02Z","git_url":"git://github.com/shrah/corert.git","ssh_url":"git@github.com:shrah/corert.git","clone_url":"https://github.com/shrah/corert.git","svn_url":"https://github.com/shrah/corert","homepage":"http://dotnet.github.io/","size":15478,"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":"fdcf891a5aa7dc925fa77b1e5b0f5b8adfdd89fd","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars3.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":42552143,"name":"corert","full_name":"dotnet/corert","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars3.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/corert","description":"This repo contains CoreRT, a .NET Core runtime optimized for AOT (ahead of time compilation) scenarios, with the accompanying .NET Native compiler toolchain.","fork":false,"url":"https://api.github.com/repos/dotnet/corert","forks_url":"https://api.github.com/repos/dotnet/corert/forks","keys_url":"https://api.github.com/repos/dotnet/corert/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corert/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corert/teams","hooks_url":"https://api.github.com/repos/dotnet/corert/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corert/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corert/events","assignees_url":"https://api.github.com/repos/dotnet/corert/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corert/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corert/tags","blobs_url":"https://api.github.com/repos/dotnet/corert/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corert/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corert/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corert/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corert/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corert/languages","stargazers_url":"https://api.github.com/repos/dotnet/corert/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corert/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corert/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corert/subscription","commits_url":"https://api.github.com/repos/dotnet/corert/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corert/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corert/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corert/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corert/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corert/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corert/merges","archive_url":"https://api.github.com/repos/dotnet/corert/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corert/downloads","issues_url":"https://api.github.com/repos/dotnet/corert/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corert/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corert/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corert/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corert/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corert/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/corert/deployments","created_at":"2015-09-15T23:10:53Z","updated_at":"2017-03-14T16:37:18Z","pushed_at":"2017-03-15T01:47:36Z","git_url":"git://github.com/dotnet/corert.git","ssh_url":"git@github.com:dotnet/corert.git","clone_url":"https://github.com/dotnet/corert.git","svn_url":"https://github.com/dotnet/corert","homepage":"http://dot.net","size":15458,"stargazers_count":560,"watchers_count":560,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":194,"mirror_url":null,"open_issues_count":195,"forks":194,"open_issues":195,"watchers":560,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corert/pulls/2943"},"html":{"href":"https://github.com/dotnet/corert/pull/2943"},"issue":{"href":"https://api.github.com/repos/dotnet/corert/issues/2943"},"comments":{"href":"https://api.github.com/repos/dotnet/corert/issues/2943/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corert/pulls/2943/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corert/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corert/pulls/2943/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corert/statuses/891ba9faac806d2fe4b1bf820a7a7958b9fbd9ca"}}}}
{"actor":{"display_login":"yizhang82"}}