{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/Razor/pulls/comments/30751682","id":30751682,"diff_hunk":"@@ -190,81 +190,126 @@ protected virtual string GenerateUniqueId()\n \n         private void RenderBoundHTMLAttributes(\n             IList<KeyValuePair<string, Chunk>> chunkAttributes,\n+            string tagHelperTypeName,\n             string tagHelperVariableName,\n             IEnumerable<TagHelperAttributeDescriptor> attributeDescriptors,\n             Dictionary<string, string> htmlAttributeValues)\n         {\n-            foreach (var attributeDescriptor in attributeDescriptors)\n+            // Track dictionary properties we have confirmed are non-null.\n+            var confirmedDictionaries = new HashSet<string>(StringComparer.Ordinal);\n+\n+            // First attribute wins, even if there are duplicates.\n+            var distinctAttributes = chunkAttributes.Distinct(KeyValuePairKeyComparer.Default);\n+\n+            // Go through the HTML attributes in source order, assigning to properties or indexers as we go.\n+            foreach (var attributeKeyValuePair in distinctAttributes)\n             {\n-                var matchingAttributes = chunkAttributes.Where(\n-                    kvp => string.Equals(kvp.Key, attributeDescriptor.Name, StringComparison.OrdinalIgnoreCase));\n+                var attributeName = attributeKeyValuePair.Key;\n+                var attributeValueChunk = attributeKeyValuePair.Value;\n+                if (attributeValueChunk == null)\n+                {\n+                    // Minimized attributes are not valid for bound attributes. TagHelperBlockRewriter has already\n+                    // logged an error if it was a bound attribute; so we can skip.\n+                    continue;\n+                }\n \n-                if (matchingAttributes.Any())\n+                // Find the matching TagHelperAttributeDescriptor.\n+                var attributeDescriptor = attributeDescriptors.FirstOrDefault(","path":"src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpTagHelperCodeRenderer.cs","position":54,"original_position":54,"commit_id":"7e39476f5659e3d82c4af7077fd21130555b2e17","original_commit_id":"7e39476f5659e3d82c4af7077fd21130555b2e17","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":"Kinda hack since this is relying on the Indexers always being at the end of the attribute descriptors. Is the plan to eventually create an error if multiple attribute descriptors for a single `TagHelperDescriptor` target the same attribute?","created_at":"2015-05-20T21:31:05Z","updated_at":"2015-05-20T21:31:05Z","html_url":"https://github.com/aspnet/Razor/pull/395#discussion_r30751682","pull_request_url":"https://api.github.com/repos/aspnet/Razor/pulls/395","_links":{"self":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/comments/30751682"},"html":{"href":"https://github.com/aspnet/Razor/pull/395#discussion_r30751682"},"pull_request":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/395"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/Razor/pulls/395","id":35659587,"html_url":"https://github.com/aspnet/Razor/pull/395","diff_url":"https://github.com/aspnet/Razor/pull/395.diff","patch_url":"https://github.com/aspnet/Razor/pull/395.patch","issue_url":"https://api.github.com/repos/aspnet/Razor/issues/395","number":395,"state":"open","locked":false,"title":"Add `[HtmlAttributeName(..., DictionaryAttributePrefix=\"prefix\")]` part III","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":"- #89 remainder\r\n- support adding attributes (that aren't otherwise bound) to a tag helper dictionary\r\n - add `ObjectCreationExpression`, `Prefix` and more to `TagHelperAttributeDescriptor`\r\n - handle `Prefix` matches in `TagHelperBlockRewriter`\r\n - generate code for dictionary property initialization and indexer property assignments\r\n- extend handling of invalid attribute names to include `[HtmlAttributeName]`\r\n\r\nknown issue:\r\n- `ObjectCreationExpression` is a C# expression because otherwise generation has\r\n  insufficient information to determine correct constructor.\r\n- no VB or F# (for example) workarounds today\r\n\r\nnits:\r\n- improve `TagHelperDescriptorFactory_InvalidBoundAttributeName` wording\r\n - rename resource to `TagHelperDescriptorFactory_InvalidAttributeNameOrPrefixStart`\r\n- correct order of arguments to `FormatTagHelperDescriptorFactory_InvalidBoundAttributeName`\r\n- correct `TagHelperDescriptorFactoryTest` test names\r\n - remove a few unnecessary `ToArray()` calls","created_at":"2015-05-18T18:20:20Z","updated_at":"2015-05-20T21:31:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"085964579736bb7dce68095d0f13b0a7097a38b2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/Razor/pulls/395/commits","review_comments_url":"https://api.github.com/repos/aspnet/Razor/pulls/395/comments","review_comment_url":"https://api.github.com/repos/aspnet/Razor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/Razor/issues/395/comments","statuses_url":"https://api.github.com/repos/aspnet/Razor/statuses/7e39476f5659e3d82c4af7077fd21130555b2e17","head":{"label":"aspnet:dougbu/dictionary.attributes.89.III","ref":"dougbu/dictionary.attributes.89.III","sha":"7e39476f5659e3d82c4af7077fd21130555b2e17","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-20T13:23:23Z","pushed_at":"2015-05-20T21:07:38Z","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":10547,"stargazers_count":342,"watchers_count":342,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":88,"mirror_url":null,"open_issues_count":76,"forks":88,"open_issues":76,"watchers":342,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"0e296283f947d8d227d6d39582f74094bac7ae0a","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-20T13:23:23Z","pushed_at":"2015-05-20T21:07:38Z","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":10547,"stargazers_count":342,"watchers_count":342,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":88,"mirror_url":null,"open_issues_count":76,"forks":88,"open_issues":76,"watchers":342,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/395"},"html":{"href":"https://github.com/aspnet/Razor/pull/395"},"issue":{"href":"https://api.github.com/repos/aspnet/Razor/issues/395"},"comments":{"href":"https://api.github.com/repos/aspnet/Razor/issues/395/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/395/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/395/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/Razor/statuses/7e39476f5659e3d82c4af7077fd21130555b2e17"}}}}