{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/Razor/pulls/comments/30356516","id":30356516,"diff_hunk":"@@ -0,0 +1,84 @@\n+﻿// Copyright (c) .NET Foundation. All rights reserved.\n+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\n+\n+using System;\n+using System.Collections.Generic;\n+using System.Linq;\n+using Microsoft.Framework.Internal;\n+\n+namespace Microsoft.AspNet.Razor.TagHelpers\n+{\n+    /// <summary>\n+    /// Helper methods related to <see cref=\"TagHelperDescriptor\"/> and related classes.\n+    /// </summary>\n+    public static class TagHelperDescriptorMatcher\n+    {\n+        /// <summary>\n+        /// Determine the full name of the <see cref=\"Type\"/> of the property corresponding to an attribute named\n+        /// <paramref name=\"name\"/>.\n+        /// </summary>\n+        /// <param name=\"name\">Name of the attribute.</param>\n+        /// <param name=\"descriptors\">\n+        /// Collection of <see cref=\"TagHelperDescriptor\"/>s targeting the containing element in the Razor source.\n+        /// </param>\n+        /// <returns>\n+        /// The full name of the <see cref=\"Type\"/> of the property corresponding to an attribute named\n+        /// <paramref name=\"name\"/>. <c>null</c> if the attribute is not bound.\n+        /// </returns>\n+        /// <remarks>\n+        /// This method cannot use Reflection to generally determine the most specific <see cref=\"Type\"/> when\n+        /// multiple tag helpers bind the attribute. However when it can determine an attribute is bound to a\n+        /// <see cref=\"string\"/> property or dictionary value, it always returns <c>\"System.String\"</c>. Otherwise it\n+        /// returns the full <see cref=\"Type\"/> name for the first binding it finds, if any.\n+        /// </remarks>\n+        public static string GetPropertyType(\n+            [NotNull] string name,\n+            [NotNull] IEnumerable<TagHelperDescriptor> descriptors)\n+        {\n+            // Find first TagHelperAttributeDescriptor matching this name.\n+            var firstBoundAttribute = descriptors\n+                .SelectMany(descriptor => descriptor.Attributes)\n+                .FirstOrDefault(attribute => string.Equals(attribute.Name, name, StringComparison.OrdinalIgnoreCase));\n+            if (firstBoundAttribute == null)\n+            {\n+                return null;\n+            }\n+\n+            if (!IsBoundNonStringAttribute(name, descriptors))\n+            {\n+                // Must have been a string attribute since we know it is bound. Use that type.\n+                return typeof(string).FullName;\n+            }\n+\n+            // Attribute is bound but never to a string property.\n+            return firstBoundAttribute.TypeName;\n+        }\n+\n+        /// <summary>\n+        /// Determines whether an attribute named <paramref name=\"name\"/> is bound exclusively to\n+        /// non-<see cref=\"string\"/> tag helper properties.\n+        /// </summary>\n+        /// <param name=\"name\">Name of the attribute.</param>\n+        /// <param name=\"descriptors\">\n+        /// Collection of <see cref=\"TagHelperDescriptor\"/>s targeting the containing element in the Razor source.\n+        /// </param>\n+        /// <returns>\n+        /// <c>true</c> if the attribute named <paramref name=\"name\"/> is bound and no associated property has\n+        /// <see cref=\"Type\"/> <see cref=\"string\"/>. <c>false</c> otherwise e.g. if the property is not bound.\n+        /// </returns>\n+        public static bool IsBoundNonStringAttribute(","path":"src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDescriptorMatcher.cs","position":69,"original_position":69,"commit_id":"74a2f1c204de565e16cd1eeb87ba6b16009fc498","original_commit_id":"74a2f1c204de565e16cd1eeb87ba6b16009fc498","user":{"login":"NTaylorMullen","id":2008729,"avatar_url":"https://avatars.githubusercontent.com/u/2008729?v=3","gravatar_id":"","url":"https://api.github.com/users/NTaylorMullen","html_url":"https://github.com/NTaylorMullen","followers_url":"https://api.github.com/users/NTaylorMullen/followers","following_url":"https://api.github.com/users/NTaylorMullen/following{/other_user}","gists_url":"https://api.github.com/users/NTaylorMullen/gists{/gist_id}","starred_url":"https://api.github.com/users/NTaylorMullen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NTaylorMullen/subscriptions","organizations_url":"https://api.github.com/users/NTaylorMullen/orgs","repos_url":"https://api.github.com/users/NTaylorMullen/repos","events_url":"https://api.github.com/users/NTaylorMullen/events{/privacy}","received_events_url":"https://api.github.com/users/NTaylorMullen/received_events","type":"User","site_admin":false},"body":"Might be nice to have an overload that takes `IEnumerable<TagHelperAttributeDescriptor>` that this one calls into so above we don't have to redo the `SelectMany`","created_at":"2015-05-14T19:57:46Z","updated_at":"2015-05-14T19:57:46Z","html_url":"https://github.com/aspnet/Razor/pull/390#discussion_r30356516","pull_request_url":"https://api.github.com/repos/aspnet/Razor/pulls/390","_links":{"self":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/comments/30356516"},"html":{"href":"https://github.com/aspnet/Razor/pull/390#discussion_r30356516"},"pull_request":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/390"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/Razor/pulls/390","id":35396468,"html_url":"https://github.com/aspnet/Razor/pull/390","diff_url":"https://github.com/aspnet/Razor/pull/390.diff","patch_url":"https://github.com/aspnet/Razor/pull/390.patch","issue_url":"https://api.github.com/repos/aspnet/Razor/issues/390","number":390,"state":"open","locked":false,"title":"Add `[HtmlAttributeName(..., DictionaryAttributePrefix=\"prefix\")]` part II","user":{"login":"dougbu","id":6431421,"avatar_url":"https://avatars.githubusercontent.com/u/6431421?v=3","gravatar_id":"","url":"https://api.github.com/users/dougbu","html_url":"https://github.com/dougbu","followers_url":"https://api.github.com/users/dougbu/followers","following_url":"https://api.github.com/users/dougbu/following{/other_user}","gists_url":"https://api.github.com/users/dougbu/gists{/gist_id}","starred_url":"https://api.github.com/users/dougbu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dougbu/subscriptions","organizations_url":"https://api.github.com/users/dougbu/orgs","repos_url":"https://api.github.com/users/dougbu/repos","events_url":"https://api.github.com/users/dougbu/events{/privacy}","received_events_url":"https://api.github.com/users/dougbu/received_events","type":"User","site_admin":false},"body":"- relates to #89 because that changes `string` property checks and needs this refactor\r\n- determine `string`-ness when creating `TagHelperAttributeDescriptor`s\r\n - add `TagHelperAttributeDescriptor.IsStringProperty`\r\n - avoid repeated `string` comparisons and be more explicit\r\n- calculate `string`-ness for a bound attribute using all `TagHelperAttributeDescriptor`s\r\n - use most specific type when multiple tag helpers bind same attribute to e.g. `object` and `string`\r\n - produce same error for empty attribute values regardless of `TagHelperDescriptor` order\r\n - generate same code regardless of `TagHelperDescriptor` order\r\n- test all of it\r\n\r\nminor:\r\n- fix `TagHelperBlockRewriter.TryParseBlock()` end quote removal when tag is malformed\r\n\r\nnits:\r\n- refactor `CSharpTagHelperCodeRenderer` to allow reuse of core attribute value rendering\r\n- add `TagHelperHelper` though it's fairly simple at this point","created_at":"2015-05-14T06:06:45Z","updated_at":"2015-05-14T19:57:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"18732249f6e6d87dd7090ddc70d93fb9a8f66478","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/Razor/pulls/390/commits","review_comments_url":"https://api.github.com/repos/aspnet/Razor/pulls/390/comments","review_comment_url":"https://api.github.com/repos/aspnet/Razor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/Razor/issues/390/comments","statuses_url":"https://api.github.com/repos/aspnet/Razor/statuses/74a2f1c204de565e16cd1eeb87ba6b16009fc498","head":{"label":"aspnet:dougbu/dictionary.attributes.89.II","ref":"dougbu/dictionary.attributes.89.II","sha":"74a2f1c204de565e16cd1eeb87ba6b16009fc498","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","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":15835991,"name":"Razor","full_name":"aspnet/Razor","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","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/Razor","description":"Parser and code generator for CSHTML files used in view pages for MVC web apps.","fork":false,"url":"https://api.github.com/repos/aspnet/Razor","forks_url":"https://api.github.com/repos/aspnet/Razor/forks","keys_url":"https://api.github.com/repos/aspnet/Razor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Razor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Razor/teams","hooks_url":"https://api.github.com/repos/aspnet/Razor/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Razor/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Razor/events","assignees_url":"https://api.github.com/repos/aspnet/Razor/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Razor/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Razor/tags","blobs_url":"https://api.github.com/repos/aspnet/Razor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Razor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Razor/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Razor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Razor/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Razor/languages","stargazers_url":"https://api.github.com/repos/aspnet/Razor/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Razor/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Razor/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Razor/subscription","commits_url":"https://api.github.com/repos/aspnet/Razor/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Razor/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Razor/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Razor/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Razor/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Razor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Razor/merges","archive_url":"https://api.github.com/repos/aspnet/Razor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Razor/downloads","issues_url":"https://api.github.com/repos/aspnet/Razor/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Razor/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Razor/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Razor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Razor/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Razor/releases{/id}","created_at":"2014-01-12T03:52:46Z","updated_at":"2015-05-14T06:41:48Z","pushed_at":"2015-05-14T19:02:41Z","git_url":"git://github.com/aspnet/Razor.git","ssh_url":"git@github.com:aspnet/Razor.git","clone_url":"https://github.com/aspnet/Razor.git","svn_url":"https://github.com/aspnet/Razor","homepage":"","size":9752,"stargazers_count":341,"watchers_count":341,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":88,"mirror_url":null,"open_issues_count":77,"forks":88,"open_issues":77,"watchers":341,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"add8b07d3251f9b74027381c31ce5e09b079005c","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","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":15835991,"name":"Razor","full_name":"aspnet/Razor","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","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/Razor","description":"Parser and code generator for CSHTML files used in view pages for MVC web apps.","fork":false,"url":"https://api.github.com/repos/aspnet/Razor","forks_url":"https://api.github.com/repos/aspnet/Razor/forks","keys_url":"https://api.github.com/repos/aspnet/Razor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Razor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Razor/teams","hooks_url":"https://api.github.com/repos/aspnet/Razor/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Razor/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Razor/events","assignees_url":"https://api.github.com/repos/aspnet/Razor/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Razor/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Razor/tags","blobs_url":"https://api.github.com/repos/aspnet/Razor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Razor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Razor/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Razor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Razor/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Razor/languages","stargazers_url":"https://api.github.com/repos/aspnet/Razor/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Razor/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Razor/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Razor/subscription","commits_url":"https://api.github.com/repos/aspnet/Razor/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Razor/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Razor/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Razor/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Razor/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Razor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Razor/merges","archive_url":"https://api.github.com/repos/aspnet/Razor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Razor/downloads","issues_url":"https://api.github.com/repos/aspnet/Razor/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Razor/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Razor/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Razor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Razor/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Razor/releases{/id}","created_at":"2014-01-12T03:52:46Z","updated_at":"2015-05-14T06:41:48Z","pushed_at":"2015-05-14T19:02:41Z","git_url":"git://github.com/aspnet/Razor.git","ssh_url":"git@github.com:aspnet/Razor.git","clone_url":"https://github.com/aspnet/Razor.git","svn_url":"https://github.com/aspnet/Razor","homepage":"","size":9752,"stargazers_count":341,"watchers_count":341,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":88,"mirror_url":null,"open_issues_count":77,"forks":88,"open_issues":77,"watchers":341,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/390"},"html":{"href":"https://github.com/aspnet/Razor/pull/390"},"issue":{"href":"https://api.github.com/repos/aspnet/Razor/issues/390"},"comments":{"href":"https://api.github.com/repos/aspnet/Razor/issues/390/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/390/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/390/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/Razor/statuses/74a2f1c204de565e16cd1eeb87ba6b16009fc498"}}}}