{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/142393750","pull_request_review_id":66747378,"id":142393750,"diff_hunk":"@@ -0,0 +1,64 @@\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 System.Collections.Generic;\n+using System.Net.Security;\n+using System.Runtime.InteropServices;\n+\n+internal static partial class Interop\n+{\n+    [StructLayout(LayoutKind.Sequential, Pack = 1)]\n+    internal struct Sec_Application_Protocols\n+    {\n+        private static readonly int ProtocolListOffset = Marshal.SizeOf<Sec_Application_Protocols>();\n+        private static readonly int ProtocolListConstSize = ProtocolListOffset - (int)Marshal.OffsetOf<Sec_Application_Protocols>(nameof(ProtocolExtenstionType));\n+        public uint ProtocolListsSize;\n+        public ApplicationProtocolNegotiationExt ProtocolExtenstionType;\n+        public short ProtocolListSize;\n+\n+        public static unsafe byte[] ToByteArray(IList<SslApplicationProtocol> applicationProtocols)\n+        {\n+            long protocolListSize = 0;\n+            foreach (SslApplicationProtocol protocol in applicationProtocols)\n+            {\n+                if (protocol.Protocol.Length == 0 || protocol.Protocol.Length > byte.MaxValue)\n+                {\n+                    throw new ArgumentException(SR.net_ssl_app_protocols_invalid, nameof(applicationProtocols));\n+                }\n+\n+                protocolListSize += protocol.Protocol.Length + 1;\n+\n+                if (protocolListSize > short.MaxValue)\n+                {\n+                    throw new ArgumentException(SR.net_ssl_app_protocols_invalid, nameof(applicationProtocols));\n+                }\n+            }\n+\n+            Sec_Application_Protocols protocols = new Sec_Application_Protocols();\n+            protocols.ProtocolListsSize = (uint)(ProtocolListConstSize + protocolListSize);\n+            protocols.ProtocolExtenstionType = ApplicationProtocolNegotiationExt.ALPN;\n+            protocols.ProtocolListSize = (short)protocolListSize;\n+\n+            byte[] buffer = new byte[ProtocolListOffset + protocolListSize];\n+            fixed (byte* bufferPtr = buffer)\n+            {\n+                Marshal.StructureToPtr(protocols, new IntPtr(bufferPtr), false);\n+                byte* protocolList = bufferPtr + ProtocolListOffset;\n+                foreach (SslApplicationProtocol applicationProtocol in applicationProtocols)\n+                {\n+                    *(protocolList++) = (byte)applicationProtocol.Protocol.Length;\n+                    fixed (byte* p = applicationProtocol.Protocol.ToArray())\n+                    {\n+                        Buffer.MemoryCopy(p, protocolList, buffer.Length, applicationProtocol.Protocol.Length);\n+                    }\n+\n+                    protocolList += applicationProtocol.Protocol.Length;\n+                }\n+            }\n+\n+            return buffer;\n+        }\n+    }","path":"src/Common/src/Interop/Windows/SChannel/Interop.Sec_Application_Protocols.cs","position":63,"original_position":63,"commit_id":"b9dc6f32d0215cf92c75a554d1fd12d5ed7691da","original_commit_id":"b9dc6f32d0215cf92c75a554d1fd12d5ed7691da","user":{"login":"stephentoub","id":2642209,"avatar_url":"https://avatars0.githubusercontent.com/u/2642209?v=4","gravatar_id":"","url":"https://api.github.com/users/stephentoub","html_url":"https://github.com/stephentoub","followers_url":"https://api.github.com/users/stephentoub/followers","following_url":"https://api.github.com/users/stephentoub/following{/other_user}","gists_url":"https://api.github.com/users/stephentoub/gists{/gist_id}","starred_url":"https://api.github.com/users/stephentoub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephentoub/subscriptions","organizations_url":"https://api.github.com/users/stephentoub/orgs","repos_url":"https://api.github.com/users/stephentoub/repos","events_url":"https://api.github.com/users/stephentoub/events{/privacy}","received_events_url":"https://api.github.com/users/stephentoub/received_events","type":"User","site_admin":false},"body":"There's a lot of allocation happening in these conversion routines: enumerators, byte arrays, etc.  Not to block this PR, but it'd be good subsequently to see what kind of impact that has and whether there are ways to reduce it.","created_at":"2017-10-03T13:03:55Z","updated_at":"2017-10-03T13:03:55Z","html_url":"https://github.com/dotnet/corefx/pull/24389#discussion_r142393750","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/24389","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/142393750"},"html":{"href":"https://github.com/dotnet/corefx/pull/24389#discussion_r142393750"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/24389"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/24389","id":144310370,"html_url":"https://github.com/dotnet/corefx/pull/24389","diff_url":"https://github.com/dotnet/corefx/pull/24389.diff","patch_url":"https://github.com/dotnet/corefx/pull/24389.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/24389","number":24389,"state":"open","locked":false,"title":"Add ALPN support for SslStream.","user":{"login":"Priya91","id":7853870,"avatar_url":"https://avatars3.githubusercontent.com/u/7853870?v=4","gravatar_id":"","url":"https://api.github.com/users/Priya91","html_url":"https://github.com/Priya91","followers_url":"https://api.github.com/users/Priya91/followers","following_url":"https://api.github.com/users/Priya91/following{/other_user}","gists_url":"https://api.github.com/users/Priya91/gists{/gist_id}","starred_url":"https://api.github.com/users/Priya91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Priya91/subscriptions","organizations_url":"https://api.github.com/users/Priya91/orgs","repos_url":"https://api.github.com/users/Priya91/repos","events_url":"https://api.github.com/users/Priya91/events{/privacy}","received_events_url":"https://api.github.com/users/Priya91/received_events","type":"User","site_admin":false},"body":"cc @stephentoub @bartonjs @geoffkizer @wfurt @karelz @Drawaes @Tratcher \r\n\r\nfixes #23177 \r\n\r\nIn this PR, only ALPN support is added. This PR does not include:\r\n\r\n1. CancellationToken implementation\r\n2. AllowRenegotiation\r\n3. SNI\r\n\r\nI'll file issues separately for followup on above items at the time of merging this PR. ","created_at":"2017-10-02T23:54:48Z","updated_at":"2017-10-03T13:03:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0168df45ce2da3c11e5bf0fb07274d081d59476c","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/24389/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/24389/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/24389/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/b9dc6f32d0215cf92c75a554d1fd12d5ed7691da","head":{"label":"Priya91:tlsextension","ref":"tlsextension","sha":"b9dc6f32d0215cf92c75a554d1fd12d5ed7691da","user":{"login":"Priya91","id":7853870,"avatar_url":"https://avatars3.githubusercontent.com/u/7853870?v=4","gravatar_id":"","url":"https://api.github.com/users/Priya91","html_url":"https://github.com/Priya91","followers_url":"https://api.github.com/users/Priya91/followers","following_url":"https://api.github.com/users/Priya91/following{/other_user}","gists_url":"https://api.github.com/users/Priya91/gists{/gist_id}","starred_url":"https://api.github.com/users/Priya91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Priya91/subscriptions","organizations_url":"https://api.github.com/users/Priya91/orgs","repos_url":"https://api.github.com/users/Priya91/repos","events_url":"https://api.github.com/users/Priya91/events{/privacy}","received_events_url":"https://api.github.com/users/Priya91/received_events","type":"User","site_admin":false},"repo":{"id":27062349,"name":"corefx-1","full_name":"Priya91/corefx-1","owner":{"login":"Priya91","id":7853870,"avatar_url":"https://avatars3.githubusercontent.com/u/7853870?v=4","gravatar_id":"","url":"https://api.github.com/users/Priya91","html_url":"https://github.com/Priya91","followers_url":"https://api.github.com/users/Priya91/followers","following_url":"https://api.github.com/users/Priya91/following{/other_user}","gists_url":"https://api.github.com/users/Priya91/gists{/gist_id}","starred_url":"https://api.github.com/users/Priya91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Priya91/subscriptions","organizations_url":"https://api.github.com/users/Priya91/orgs","repos_url":"https://api.github.com/users/Priya91/repos","events_url":"https://api.github.com/users/Priya91/events{/privacy}","received_events_url":"https://api.github.com/users/Priya91/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Priya91/corefx-1","description":"This repository contains the foundational libraries that make up the .NET Core development stack.","fork":true,"url":"https://api.github.com/repos/Priya91/corefx-1","forks_url":"https://api.github.com/repos/Priya91/corefx-1/forks","keys_url":"https://api.github.com/repos/Priya91/corefx-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Priya91/corefx-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Priya91/corefx-1/teams","hooks_url":"https://api.github.com/repos/Priya91/corefx-1/hooks","issue_events_url":"https://api.github.com/repos/Priya91/corefx-1/issues/events{/number}","events_url":"https://api.github.com/repos/Priya91/corefx-1/events","assignees_url":"https://api.github.com/repos/Priya91/corefx-1/assignees{/user}","branches_url":"https://api.github.com/repos/Priya91/corefx-1/branches{/branch}","tags_url":"https://api.github.com/repos/Priya91/corefx-1/tags","blobs_url":"https://api.github.com/repos/Priya91/corefx-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Priya91/corefx-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Priya91/corefx-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/Priya91/corefx-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Priya91/corefx-1/statuses/{sha}","languages_url":"https://api.github.com/repos/Priya91/corefx-1/languages","stargazers_url":"https://api.github.com/repos/Priya91/corefx-1/stargazers","contributors_url":"https://api.github.com/repos/Priya91/corefx-1/contributors","subscribers_url":"https://api.github.com/repos/Priya91/corefx-1/subscribers","subscription_url":"https://api.github.com/repos/Priya91/corefx-1/subscription","commits_url":"https://api.github.com/repos/Priya91/corefx-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/Priya91/corefx-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/Priya91/corefx-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/Priya91/corefx-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/Priya91/corefx-1/contents/{+path}","compare_url":"https://api.github.com/repos/Priya91/corefx-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Priya91/corefx-1/merges","archive_url":"https://api.github.com/repos/Priya91/corefx-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Priya91/corefx-1/downloads","issues_url":"https://api.github.com/repos/Priya91/corefx-1/issues{/number}","pulls_url":"https://api.github.com/repos/Priya91/corefx-1/pulls{/number}","milestones_url":"https://api.github.com/repos/Priya91/corefx-1/milestones{/number}","notifications_url":"https://api.github.com/repos/Priya91/corefx-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Priya91/corefx-1/labels{/name}","releases_url":"https://api.github.com/repos/Priya91/corefx-1/releases{/id}","deployments_url":"https://api.github.com/repos/Priya91/corefx-1/deployments","created_at":"2014-11-24T05:35:16Z","updated_at":"2016-03-15T18:06:54Z","pushed_at":"2017-10-02T23:52:02Z","git_url":"git://github.com/Priya91/corefx-1.git","ssh_url":"git@github.com:Priya91/corefx-1.git","clone_url":"https://github.com/Priya91/corefx-1.git","svn_url":"https://github.com/Priya91/corefx-1","homepage":"","size":157084,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_projects":true,"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":"b9676be62166e90a07763f070330a9ffc8ef6cc7","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","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://avatars0.githubusercontent.com/u/9141961?v=4","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. We welcome contributions.","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}","deployments_url":"https://api.github.com/repos/dotnet/corefx/deployments","created_at":"2014-11-06T23:42:48Z","updated_at":"2017-10-03T12:22:48Z","pushed_at":"2017-10-03T11:59:12Z","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":"https://github.com/dotnet/core","size":157904,"stargazers_count":12571,"watchers_count":12571,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3498,"mirror_url":null,"open_issues_count":2001,"forks":3498,"open_issues":2001,"watchers":12571,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/24389"},"html":{"href":"https://github.com/dotnet/corefx/pull/24389"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/24389"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/24389/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/24389/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/24389/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/b9dc6f32d0215cf92c75a554d1fd12d5ed7691da"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"stephentoub"}}