{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/Razor/pulls/comments/23032367","id":23032367,"diff_hunk":"@@ -340,18 +332,72 @@ private void RenderUnboundHTMLAttributes(IEnumerable<KeyValuePair<string, Chunk>\n             }\n         }\n \n-        private void RenderTagHelperBody(IList<Chunk> children, bool bufferBody)\n+        private void RenderTagHelperContent()\n         {\n-            // If we want to buffer the body we need to create a writing scope to capture the body content.\n-            if (bufferBody)\n+            // Rendering output is a runtime feature.\n+            if (_designTimeMode)\n             {\n-                // Render all of the tag helper children in a buffered writing scope.\n-                BuildBufferedWritingScope(children);\n+                return;\n             }\n-            else\n+\n+            _writer.Write(\"if (\")\n+                   .Write(ExecutionContextVariableName)\n+                   .Write(\".\")\n+                   .Write(_tagHelperContext.ExecutionContextOutputPropertyName)\n+                   .Write(\".\")\n+                   .Write(_tagHelperContext.OutputContentSetPropertyName)\n+                   .WriteLine(\")\");\n+\n+            // Render the body of the if statement, at this point in the codegen the TagHelperOutput's Content was set\n+            // so we should just render its Content, no need to forcefully execute the child content.\n+            using (_writer.BuildScope())\n             {\n-                // Render all of the tag helper children.\n-                _bodyVisitor.Accept(children);\n+                RenderTagOutput(_tagHelperContext.OutputGenerateContentMethodName);\n+            }\n+\n+            _writer.Write(\"else if (\")\n+                   .Write(ExecutionContextVariableName)\n+                   .Write(\".\")\n+                   .Write(_tagHelperContext.ExecutionContextChildContentRetrievedPropertyName)\n+                   .WriteLine(\")\");\n+\n+            // Render the body of the else if statement, at this point in the codegen the GetChildContentAsync method \n+            // was invoked but the TagHelperOutput's Content was not set. Call into GetChildContentAsync to retrieve\n+            // the cached value of the content so we don't execute the child content twice.\n+            using (_writer.BuildScope())\n+            {\n+                CSharpCodeVisitor.RenderPreWriteStart(_writer, _context);\n+\n+                _writer.WriteInstanceMethodInvocation(ExecutionContextVariableName,\n+                                                      _tagHelperContext.ExecutionContextGetChildContentAsyncMethodName,\n+                                                      endLine: false);\n+\n+                _writer.Write(\".Result\")\n+                       .WriteEndMethodInvocation();\n+            }\n+\n+            _writer.WriteLine(\"else\");\n+\n+            // Render the body of the else statement, at this point in the codegen the GetChildContentAsync method \n+            // was not invoked and the TagHelperOutput's Content was not set. Call into ExecuteChildContentAsync to\n+            // to execute and render child content.\n+            using (_writer.BuildScope())\n+            {\n+                if (!string.IsNullOrEmpty(_context.TargetWriterName))\n+                {\n+                    _writer.WriteMethodInvocation(_tagHelperContext.StartWritingScopeMethodName, _context.TargetWriterName);\n+                }\n+\n+                _writer.WriteInstanceMethodInvocation(\n+                    ExecutionContextVariableName,\n+                    _tagHelperContext.ExecutionContextExecuteChildContentAsyncMethodName,\n+                    endLine: false);\n+                _writer.WriteLine(\".Wait();\");","path":"src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpTagHelperCodeRenderer.cs","position":186,"original_position":186,"commit_id":"52d8a806a0da5053f0682e1607a9d3325af0900a","original_commit_id":"cf7f3b1102f23b497ab9033eebf9ec6b7cfebde9","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":"Would if I could :cry: : https://github.com/aspnet/Razor/issues/169","created_at":"2015-01-15T18:43:40Z","updated_at":"2015-01-15T18:43:40Z","html_url":"https://github.com/aspnet/Razor/pull/261#discussion_r23032367","pull_request_url":"https://api.github.com/repos/aspnet/Razor/pulls/261","_links":{"self":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/comments/23032367"},"html":{"href":"https://github.com/aspnet/Razor/pull/261#discussion_r23032367"},"pull_request":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/261"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/Razor/pulls/261","id":26486114,"html_url":"https://github.com/aspnet/Razor/pull/261","diff_url":"https://github.com/aspnet/Razor/pull/261.diff","patch_url":"https://github.com/aspnet/Razor/pull/261.patch","issue_url":"https://api.github.com/repos/aspnet/Razor/issues/261","number":261,"state":"closed","locked":false,"title":"Redesign TagHelper content modes.","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":"**Removed ContentBehavior**\r\n- Removed all tests and instances of ContentBehavior in preparation for moving to a non-ContentBehavior based design.\r\n- Removed ContentBehavior specific CodeGeneration.\r\n\r\n**Re-design TagHelperOutput and runtime dependencies to allow all content modes.**\r\n- Added PreContent, PostContent and ContentSet properties to TagHelperOutput.\r\n- Added GeneratePreContent, GeneratePostContent and SupressOutput methods to TagHelperOutput.\r\n- Added multile ExecuteChildContentAsync and GetChildContentAsync to the rendering phase, ultimately only exposing GetChildContentAsync to a TagHelper author.\r\n- Added more knowledge of StartWritingScope and EndWritingScope to the TagHelper runtime components. This is to enable the runtime components to utilize the RazorPage's infrastructure to render a delegate to a writer and retrieve its value to ultimately expose it to the user.\r\n\r\n**Modify tests to allow new content mode design for runtime components.**\r\n- Added a new internal ctor for TagHelperExecutionContext since it's used in multiple tests to allow for less friction testing.\r\n\r\n**Added CodeGen for TagHelper content mode redesign.**\r\n- Modified the CSharpTagHelperCodeRenderer to understand a single line of TagHelper rendering (instead of doing different things based on ContentBehavior).\r\n- Modified existing CodeGen output to reflect new content changes.\r\n\r\n#221\r\n\r\n/cc @dougbu @pranavkm ","created_at":"2014-12-22T22:50:53Z","updated_at":"2015-01-15T18:43:40Z","closed_at":"2015-01-14T20:27:11Z","merged_at":null,"merge_commit_sha":"1dc66bf9897c464110805f01170fba6b7618a5b0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/Razor/pulls/261/commits","review_comments_url":"https://api.github.com/repos/aspnet/Razor/pulls/261/comments","review_comment_url":"https://api.github.com/repos/aspnet/Razor/pulls/comments/{number}","comments_url":"https://api.github.com/repos/aspnet/Razor/issues/261/comments","statuses_url":"https://api.github.com/repos/aspnet/Razor/statuses/52d8a806a0da5053f0682e1607a9d3325af0900a","head":{"label":"aspnet:thcontentmode.221","ref":"thcontentmode.221","sha":"52d8a806a0da5053f0682e1607a9d3325af0900a","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-01-15T16:19:31Z","pushed_at":"2015-01-15T06:03:30Z","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":5699,"stargazers_count":261,"watchers_count":261,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":56,"mirror_url":null,"open_issues_count":70,"forks":56,"open_issues":70,"watchers":261,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"8c47f6a67ecd3da91635c251770a6b872ee33f0b","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-01-15T16:19:31Z","pushed_at":"2015-01-15T06:03:30Z","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":5699,"stargazers_count":261,"watchers_count":261,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":56,"mirror_url":null,"open_issues_count":70,"forks":56,"open_issues":70,"watchers":261,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/261"},"html":{"href":"https://github.com/aspnet/Razor/pull/261"},"issue":{"href":"https://api.github.com/repos/aspnet/Razor/issues/261"},"comments":{"href":"https://api.github.com/repos/aspnet/Razor/issues/261/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/261/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/aspnet/Razor/pulls/261/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/Razor/statuses/52d8a806a0da5053f0682e1607a9d3325af0900a"}}}}