{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/Routing/pulls/comments/204915660","pull_request_review_id":140084934,"id":204915660,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNDkxNTY2MA==","diff_hunk":"@@ -72,31 +82,60 @@ public Endpoint SelectBestCandidate(HttpContext context, IReadOnlyList<Endpoint>\n             }\n         }\n \n-        private IReadOnlyList<Endpoint> EvaluateEndpointConstraints(\n+        private IReadOnlyList<EndpointSelectorCandidate> EvaluateEndpointConstraints(\n             HttpContext context,\n-            IReadOnlyList<Endpoint> endpoints)\n+            CandidateSet candidateSet)\n         {\n             var candidates = new List<EndpointSelectorCandidate>();\n \n             // Perf: Avoid allocations\n-            for (var i = 0; i < endpoints.Count; i++)\n+            for (var i = 0; i < candidateSet.Count; i++)\n             {\n-                var endpoint = endpoints[i];\n-                var constraints = _endpointConstraintCache.GetEndpointConstraints(context, endpoint);\n-                candidates.Add(new EndpointSelectorCandidate(endpoint, constraints));\n+                if (candidateSet[i].IsValidCandidate)","path":"src/Microsoft.AspNetCore.Routing/EndpointConstraints/EndpointConstraintEndpointSelector.cs","position":114,"original_position":114,"commit_id":"49a6e743b37d9bef6acc3b7b1d17a03978957884","original_commit_id":"49a6e743b37d9bef6acc3b7b1d17a03978957884","user":{"login":"JamesNK","id":303201,"node_id":"MDQ6VXNlcjMwMzIwMQ==","avatar_url":"https://avatars2.githubusercontent.com/u/303201?v=4","gravatar_id":"","url":"https://api.github.com/users/JamesNK","html_url":"https://github.com/JamesNK","followers_url":"https://api.github.com/users/JamesNK/followers","following_url":"https://api.github.com/users/JamesNK/following{/other_user}","gists_url":"https://api.github.com/users/JamesNK/gists{/gist_id}","starred_url":"https://api.github.com/users/JamesNK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JamesNK/subscriptions","organizations_url":"https://api.github.com/users/JamesNK/orgs","repos_url":"https://api.github.com/users/JamesNK/repos","events_url":"https://api.github.com/users/JamesNK/events{/privacy}","received_events_url":"https://api.github.com/users/JamesNK/received_events","type":"User","site_admin":false},"body":"Assign candidateSet[i] to variable?","created_at":"2018-07-24T21:21:52Z","updated_at":"2018-07-24T21:41:42Z","html_url":"https://github.com/aspnet/Routing/pull/646#discussion_r204915660","pull_request_url":"https://api.github.com/repos/aspnet/Routing/pulls/646","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/aspnet/Routing/pulls/comments/204915660"},"html":{"href":"https://github.com/aspnet/Routing/pull/646#discussion_r204915660"},"pull_request":{"href":"https://api.github.com/repos/aspnet/Routing/pulls/646"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/Routing/pulls/646","id":203045063,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzMDQ1MDYz","html_url":"https://github.com/aspnet/Routing/pull/646","diff_url":"https://github.com/aspnet/Routing/pull/646.diff","patch_url":"https://github.com/aspnet/Routing/pull/646.patch","issue_url":"https://api.github.com/repos/aspnet/Routing/issues/646","number":646,"state":"open","locked":false,"title":"Implement EndpointSelector and MatcherPolicy","user":{"login":"rynowak","id":1430011,"node_id":"MDQ6VXNlcjE0MzAwMTE=","avatar_url":"https://avatars1.githubusercontent.com/u/1430011?v=4","gravatar_id":"","url":"https://api.github.com/users/rynowak","html_url":"https://github.com/rynowak","followers_url":"https://api.github.com/users/rynowak/followers","following_url":"https://api.github.com/users/rynowak/following{/other_user}","gists_url":"https://api.github.com/users/rynowak/gists{/gist_id}","starred_url":"https://api.github.com/users/rynowak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rynowak/subscriptions","organizations_url":"https://api.github.com/users/rynowak/orgs","repos_url":"https://api.github.com/users/rynowak/repos","events_url":"https://api.github.com/users/rynowak/events{/privacy}","received_events_url":"https://api.github.com/users/rynowak/received_events","type":"User","site_admin":false},"body":"**TODO**\r\n- [x] unit test `DefaultEndpointSelector`\r\n- [x] unit test `HttpMethodMatcherPolicy`\r\n- [x] e2e test matcher + `HttpMethodMatcherPolicy`\r\n- [x] unit test `DfaMatcherBuilder.CreateCandidates` + `Score`\r\n- [x] unit test `CandidateSet`\r\n- [x] unit test `DfaMatcherBuilder.BuildDfaTree` + policy nodes\r\n- [x] unit test `EndpointMetadataComparer`\r\n- [x] unit test `MatcherEndpointComparer`\r\n\r\nThis change makes the EndpointSelector API more concrete, and is the\r\nbeggining of removing EndpointConstraint by making it obsolete.\r\n\r\nTo that end, I'm introducing MatcherPolicy, which is a\r\nfeature-collection API for registering policies that interact with the\r\nDfaMatcher. The two policies that we'll need to start are:\r\n- ability to order endpoints\r\n- ability to append 'policy' nodes to the graph\r\n\r\nThese two concepts together replace EndpointConstraint. Extending our\r\ngraph representation is a really efficient way to processing most common\r\nscenarios.\r\n\r\n---\r\n\r\nIn general this helps with common cases where 4 or so endpoints match\r\nthe URL, but with different HTTP methods supported on each. Today we\r\nhave to process route values and call into some 'policy' to make a\r\ndecision about which one is the winner. This change pushes this\r\nknowledge down into the graph so that it's roughly as cheap as a\r\ndictionary lookup, and can be done allocation-free.\r\n\r\nThe big savings here is ability to remove more candidates *before*\r\ncollecting route data.\r\n\r\n---\r\n\r\nAlong with this change, I also built 'rejection' into the DFA node\r\nmodel, you can see an example with the HTTP Method handling that I\r\nimplemented. I implemented a policy that can treat failure to resolve an\r\nHTTP method as a 405 response by returning a failure endpoint. This is\r\nat the heart of much of the feedback we've gotten in this area around\r\nversioning and http method handling. We also have a version of this\r\nfeature in MVC for [Consumes].\r\n\r\n\r\n## TLDR\r\n![image](https://user-images.githubusercontent.com/1430011/43043493-dd29ba78-8d49-11e8-8b52-cbcce3b62c52.png)\r\n","created_at":"2018-07-22T07:55:31Z","updated_at":"2018-07-24T21:41:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b367bdacf87dd355f29ce2b55756079307cbcc32","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/Routing/pulls/646/commits","review_comments_url":"https://api.github.com/repos/aspnet/Routing/pulls/646/comments","review_comment_url":"https://api.github.com/repos/aspnet/Routing/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/Routing/issues/646/comments","statuses_url":"https://api.github.com/repos/aspnet/Routing/statuses/49a6e743b37d9bef6acc3b7b1d17a03978957884","head":{"label":"aspnet:rynowak/policy-graph","ref":"rynowak/policy-graph","sha":"49a6e743b37d9bef6acc3b7b1d17a03978957884","user":{"login":"aspnet","id":6476660,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY0NzY2NjA=","avatar_url":"https://avatars3.githubusercontent.com/u/6476660?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":16300347,"node_id":"MDEwOlJlcG9zaXRvcnkxNjMwMDM0Nw==","name":"Routing","full_name":"aspnet/Routing","owner":{"login":"aspnet","id":6476660,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY0NzY2NjA=","avatar_url":"https://avatars3.githubusercontent.com/u/6476660?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Routing","description":"Middleware for routing requests to application logic.","fork":false,"url":"https://api.github.com/repos/aspnet/Routing","forks_url":"https://api.github.com/repos/aspnet/Routing/forks","keys_url":"https://api.github.com/repos/aspnet/Routing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Routing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Routing/teams","hooks_url":"https://api.github.com/repos/aspnet/Routing/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Routing/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Routing/events","assignees_url":"https://api.github.com/repos/aspnet/Routing/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Routing/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Routing/tags","blobs_url":"https://api.github.com/repos/aspnet/Routing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Routing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Routing/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Routing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Routing/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Routing/languages","stargazers_url":"https://api.github.com/repos/aspnet/Routing/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Routing/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Routing/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Routing/subscription","commits_url":"https://api.github.com/repos/aspnet/Routing/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Routing/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Routing/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Routing/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Routing/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Routing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Routing/merges","archive_url":"https://api.github.com/repos/aspnet/Routing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Routing/downloads","issues_url":"https://api.github.com/repos/aspnet/Routing/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Routing/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Routing/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Routing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Routing/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Routing/releases{/id}","deployments_url":"https://api.github.com/repos/aspnet/Routing/deployments","created_at":"2014-01-28T02:50:39Z","updated_at":"2018-07-24T19:15:01Z","pushed_at":"2018-07-24T20:41:48Z","git_url":"git://github.com/aspnet/Routing.git","ssh_url":"git@github.com:aspnet/Routing.git","clone_url":"https://github.com/aspnet/Routing.git","svn_url":"https://github.com/aspnet/Routing","homepage":"","size":3652,"stargazers_count":247,"watchers_count":247,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":112,"mirror_url":null,"archived":false,"open_issues_count":34,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":112,"open_issues":34,"watchers":247,"default_branch":"release/2.2"}},"base":{"label":"aspnet:release/2.2","ref":"release/2.2","sha":"b9df95831d6a8f3d6c155a6d6ddfcc6ab8688538","user":{"login":"aspnet","id":6476660,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY0NzY2NjA=","avatar_url":"https://avatars3.githubusercontent.com/u/6476660?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":16300347,"node_id":"MDEwOlJlcG9zaXRvcnkxNjMwMDM0Nw==","name":"Routing","full_name":"aspnet/Routing","owner":{"login":"aspnet","id":6476660,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY0NzY2NjA=","avatar_url":"https://avatars3.githubusercontent.com/u/6476660?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Routing","description":"Middleware for routing requests to application logic.","fork":false,"url":"https://api.github.com/repos/aspnet/Routing","forks_url":"https://api.github.com/repos/aspnet/Routing/forks","keys_url":"https://api.github.com/repos/aspnet/Routing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Routing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Routing/teams","hooks_url":"https://api.github.com/repos/aspnet/Routing/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Routing/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Routing/events","assignees_url":"https://api.github.com/repos/aspnet/Routing/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Routing/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Routing/tags","blobs_url":"https://api.github.com/repos/aspnet/Routing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Routing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Routing/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Routing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Routing/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Routing/languages","stargazers_url":"https://api.github.com/repos/aspnet/Routing/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Routing/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Routing/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Routing/subscription","commits_url":"https://api.github.com/repos/aspnet/Routing/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Routing/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Routing/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Routing/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Routing/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Routing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Routing/merges","archive_url":"https://api.github.com/repos/aspnet/Routing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Routing/downloads","issues_url":"https://api.github.com/repos/aspnet/Routing/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Routing/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Routing/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Routing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Routing/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Routing/releases{/id}","deployments_url":"https://api.github.com/repos/aspnet/Routing/deployments","created_at":"2014-01-28T02:50:39Z","updated_at":"2018-07-24T19:15:01Z","pushed_at":"2018-07-24T20:41:48Z","git_url":"git://github.com/aspnet/Routing.git","ssh_url":"git@github.com:aspnet/Routing.git","clone_url":"https://github.com/aspnet/Routing.git","svn_url":"https://github.com/aspnet/Routing","homepage":"","size":3652,"stargazers_count":247,"watchers_count":247,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":112,"mirror_url":null,"archived":false,"open_issues_count":34,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":112,"open_issues":34,"watchers":247,"default_branch":"release/2.2"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/Routing/pulls/646"},"html":{"href":"https://github.com/aspnet/Routing/pull/646"},"issue":{"href":"https://api.github.com/repos/aspnet/Routing/issues/646"},"comments":{"href":"https://api.github.com/repos/aspnet/Routing/issues/646/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/Routing/pulls/646/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/Routing/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/Routing/pulls/646/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/Routing/statuses/49a6e743b37d9bef6acc3b7b1d17a03978957884"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"JamesNK"}}