From a658c1336f050a0d8a0c0dce56003a7864c65c79 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Mon, 1 Dec 2014 16:46:51 -0800 Subject: [PATCH] Added CodeGen for TagHelper content mode redesign. - Modified the CSharpTagHelperCodeRenderer to understand a single line of TagHelper rendering (instead of doing different things based on ContentBehavior). - Modified existing CodeGen output to reflect new content changes. #221 --- .../CSharp/CSharpTagHelperCodeRenderer.cs | 128 +++- .../Generator/GeneratedTagHelperContext.cs | 12 + .../Generator/CSharpTagHelperRenderingTest.cs | 54 +- ...TagHelpers.CustomAttributeCodeGenerator.cs | 152 +++-- .../CS/Output/BasicTagHelpers.DesignTime.cs | 2 +- .../CS/Output/BasicTagHelpers.cs | 152 +++-- .../CS/Output/ComplexTagHelpers.DesignTime.cs | 40 +- .../CS/Output/ComplexTagHelpers.cs | 624 ++++++++++++------ .../CS/Output/SingleTagHelper.cs | 22 +- .../CS/Output/TagHelpersInHelper.cs | 128 +++- .../CS/Output/TagHelpersInSection.cs | 73 +- 11 files changed, 945 insertions(+), 442 deletions(-) diff --git a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpTagHelperCodeRenderer.cs b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpTagHelperCodeRenderer.cs index 20a7129cc0..25be0ecb81 100644 --- a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpTagHelperCodeRenderer.cs +++ b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpTagHelperCodeRenderer.cs @@ -58,7 +58,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp { var tagHelperDescriptors = chunk.Descriptors; - RenderBeginTagHelperScope(chunk.TagName); + RenderBeginTagHelperScope(chunk.TagName, chunk.Children); RenderTagHelpersCreation(chunk); @@ -71,11 +71,15 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp RenderUnboundHTMLAttributes(unboundHTMLAttributes); - // TODO: Modify code generation to handle all content modes - //RenderRunTagHelpers(bufferedBody: false); - //RenderTagOutput(_tagHelperContext.OutputGenerateStartTagMethodName); - //RenderTagHelperBody(chunk.Children, bufferBody: false); - //RenderTagOutput(_tagHelperContext.OutputGenerateEndTagMethodName); + RenderRunTagHelpers(); + + RenderTagOutput(_tagHelperContext.OutputGenerateStartTagMethodName); + RenderTagOutput(_tagHelperContext.OutputGeneratePreContentMethodName); + + RenderTagHelperContent(); + + RenderTagOutput(_tagHelperContext.OutputGeneratePostContentMethodName); + RenderTagOutput(_tagHelperContext.OutputGenerateEndTagMethodName); RenderEndTagHelpersScope(); } @@ -85,11 +89,13 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp return "__" + descriptor.TypeName.Replace('.', '_'); } - private void RenderBeginTagHelperScope(string tagName) + private void RenderBeginTagHelperScope(string tagName, IList children) { // Scopes/execution contexts are a runtime feature. if (_designTimeMode) { + // Render all of the tag helper children inline for IntelliSense. + _bodyVisitor.Accept(children); return; } @@ -104,6 +110,30 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp _writer.WriteStringLiteral(tagName) .WriteParameterSeparator() .WriteStringLiteral(GenerateUniqueId()) + .WriteParameterSeparator(); + + // We remove the target writer so TagHelper authors can retrieve content. + var oldWriter = _context.TargetWriterName; + _context.TargetWriterName = null; + + // Disabling instrumentation inside TagHelper bodies since we never know if it's accurate + var oldInstrumentation = _context.Host.EnableInstrumentation; + _context.Host.EnableInstrumentation = false; + + using (_writer.BuildAsyncLambda(endLine: false)) + { + // Render all of the tag helper children. + _bodyVisitor.Accept(children); + } + + _context.Host.EnableInstrumentation = oldInstrumentation; + + _context.TargetWriterName = oldWriter; + + _writer.WriteParameterSeparator() + .Write(_tagHelperContext.StartWritingScopeMethodName) + .WriteParameterSeparator() + .Write(_tagHelperContext.EndWritingScopeMethodName) .WriteEndMethodInvocation(); } @@ -324,18 +354,74 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp } } - private void RenderTagHelperBody(IList children, bool bufferBody) + private void RenderTagHelperContent() { - // If we want to buffer the body we need to create a writing scope to capture the body content. - if (bufferBody) + // Rendering output is a runtime feature. + if (_designTimeMode) { - // Render all of the tag helper children in a buffered writing scope. - BuildBufferedWritingScope(children); + return; } - else + + _writer.Write("if (") + .Write(ExecutionContextVariableName) + .Write(".") + .Write(_tagHelperContext.ExecutionContextOutputPropertyName) + .Write(".") + .Write(_tagHelperContext.OutputContentSetPropertyName) + .WriteLine(")"); + + // At this point in the codegen, TagHelperOutput.Content is set. We need to use this to render the Content + // instead of executing the child content + using (_writer.BuildScope()) { - // Render all of the tag helper children. - _bodyVisitor.Accept(children); + RenderTagOutput(_tagHelperContext.OutputGenerateContentMethodName); + } + + _writer.Write("else if (") + .Write(ExecutionContextVariableName) + .Write(".") + .Write(_tagHelperContext.ExecutionContextChildContentRetrievedPropertyName) + .WriteLine(")"); + + // Render the body of the else if statement, at this point in the codegen the GetChildContentAsync method + // was invoked but the TagHelperOutput's Content was not set. Call into GetChildContentAsync to retrieve + // the cached value of the content so we don't execute the child content twice. + using (_writer.BuildScope()) + { + CSharpCodeVisitor.RenderPreWriteStart(_writer, _context); + + _writer.WriteInstanceMethodInvocation(ExecutionContextVariableName, + _tagHelperContext.ExecutionContextGetChildContentAsyncMethodName, + endLine: false); + + _writer.Write(".Result") + .WriteEndMethodInvocation(); + } + + _writer.WriteLine("else"); + + // Render the body of the else statement, at this point in the codegen the GetChildContentAsync method + // was not invoked and the TagHelperOutput's Content was not set. Call into ExecuteChildContentAsync to + // to execute and render child content. + using (_writer.BuildScope()) + { + if (!string.IsNullOrEmpty(_context.TargetWriterName)) + { + _writer.WriteMethodInvocation( + _tagHelperContext.StartWritingScopeMethodName, + _context.TargetWriterName); + } + + _writer.WriteInstanceMethodInvocation( + ExecutionContextVariableName, + _tagHelperContext.ExecutionContextExecuteChildContentAsyncMethodName, + endLine: false); + _writer.WriteLine(".Wait();"); + + if (!string.IsNullOrEmpty(_context.TargetWriterName)) + { + _writer.WriteMethodInvocation(_tagHelperContext.EndWritingScopeMethodName); + } } } @@ -370,7 +456,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp .WriteEndMethodInvocation(); } - private void RenderRunTagHelpers(bool bufferedBody) + private void RenderRunTagHelpers() { // No need to run anything in design time mode. if (_designTimeMode) @@ -384,15 +470,9 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp .Write(" = ") .WriteStartInstanceMethodInvocation(RunnerVariableName, _tagHelperContext.RunnerRunAsyncMethodName); - _writer.Write(ExecutionContextVariableName); - if (bufferedBody) - { - _writer.WriteParameterSeparator() - .Write(StringValueBufferVariableName); - } - - _writer.WriteEndMethodInvocation(endLine: false) + _writer.Write(ExecutionContextVariableName) + .WriteEndMethodInvocation(endLine: false) .WriteLine(".Result;"); } diff --git a/src/Microsoft.AspNet.Razor/Generator/GeneratedTagHelperContext.cs b/src/Microsoft.AspNet.Razor/Generator/GeneratedTagHelperContext.cs index e2929205dc..bafd71751f 100644 --- a/src/Microsoft.AspNet.Razor/Generator/GeneratedTagHelperContext.cs +++ b/src/Microsoft.AspNet.Razor/Generator/GeneratedTagHelperContext.cs @@ -23,7 +23,9 @@ namespace Microsoft.AspNet.Razor.Generator OutputGenerateContentMethodName = "GenerateContent"; OutputGeneratePostContentMethodName = "GeneratePostContent"; OutputGenerateEndTagMethodName = "GenerateEndTag"; + ExecutionContextChildContentRetrievedPropertyName = "ChildContentRetrieved"; ExecutionContextExecuteChildContentAsyncMethodName = "ExecuteChildContentAsync"; + ExecutionContextGetChildContentAsyncMethodName = "GetChildContentAsync"; ExecutionContextAddMethodName = "Add"; ExecutionContextAddTagHelperAttributeMethodName = "AddTagHelperAttribute"; ExecutionContextAddHtmlAttributeMethodName = "AddHtmlAttribute"; @@ -89,8 +91,18 @@ namespace Microsoft.AspNet.Razor.Generator /// The name of the method used to get a /// that executes tag helper child content. /// + public string ExecutionContextChildContentRetrievedPropertyName { get; set; } + + /// + /// public string ExecutionContextExecuteChildContentAsyncMethodName { get; set; } + /// + /// The name of the method used to execute and retrieve tag helper + /// child content. + /// + public string ExecutionContextGetChildContentAsyncMethodName { get; set; } + /// /// The name of the method used to add tag helper attributes. /// diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/CSharpTagHelperRenderingTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/CSharpTagHelperRenderingTest.cs index 2803076fc4..a706e68e50 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/CSharpTagHelperRenderingTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/CSharpTagHelperRenderingTest.cs @@ -172,8 +172,8 @@ namespace Microsoft.AspNet.Razor.Test.Generator contentLength: 11), BuildLineMapping(documentAbsoluteIndex: 189, documentLineIndex: 6, - generatedAbsoluteIndex: 1633, - generatedLineIndex: 45, + generatedAbsoluteIndex: 1574, + generatedLineIndex: 44, characterOffsetIndex: 40, contentLength: 4) } @@ -186,31 +186,31 @@ namespace Microsoft.AspNet.Razor.Test.Generator { BuildLineMapping(14, 0, 479, 15, 14, 11), BuildLineMapping(30, 2, 1, 995, 35, 0, 48), - BuildLineMapping(157, 7, 32, 1177, 45, 6, 12), - BuildLineMapping(205, 9, 1260, 50, 0, 12), - BuildLineMapping(218, 9, 13, 1356, 56, 12, 27), - BuildLineMapping(346, 12, 1754, 68, 0, 48), - BuildLineMapping(440, 15, 46, 2004, 78, 6, 8), - BuildLineMapping(457, 15, 2327, 86, 63, 4), - BuildLineMapping(501, 16, 31, 2475, 92, 6, 30), - BuildLineMapping(568, 17, 30, 2824, 101, 0, 10), - BuildLineMapping(601, 17, 63, 2906, 107, 0, 8), - BuildLineMapping(632, 17, 94, 2986, 113, 0, 1), - BuildLineMapping(639, 18, 3240, 122, 0, 15), - BuildLineMapping(685, 20, 17, 3403, 129, 19, 23), - BuildLineMapping(708, 20, 40, 3426, 129, 42, 7), - BuildLineMapping(719, 21, 3504, 134, 0, 12), - BuildLineMapping(733, 21, 3602, 140, 14, 21), - BuildLineMapping(787, 22, 30, 3859, 148, 28, 7), - BuildLineMapping(831, 24, 16, 4015, 154, 19, 8), - BuildLineMapping(840, 24, 25, 4023, 154, 27, 23), - BuildLineMapping(897, 25, 30, 4281, 161, 28, 30), - BuildLineMapping(964, 27, 16, 4460, 167, 19, 30), - BuildLineMapping(1026, 28, 4725, 174, 28, 30), - BuildLineMapping(1094, 30, 18, 4904, 180, 19, 29), - BuildLineMapping(1156, 31, 5168, 187, 28, 3), - BuildLineMapping(1161, 31, 33, 5171, 187, 31, 27), - BuildLineMapping(1189, 31, 61, 5198, 187, 58, 10), + BuildLineMapping(205, 9, 1113, 44, 0, 12), + BuildLineMapping(218, 9, 13, 1209, 50, 12, 27), + BuildLineMapping(346, 12, 1607, 62, 0, 48), + BuildLineMapping(440, 15, 46, 1798, 71, 6, 8), + BuildLineMapping(457, 15, 2121, 79, 63, 4), + BuildLineMapping(501, 16, 31, 2328, 86, 6, 30), + BuildLineMapping(568, 17, 30, 2677, 95, 0, 10), + BuildLineMapping(601, 17, 63, 2759, 101, 0, 8), + BuildLineMapping(632, 17, 94, 2839, 107, 0, 1), + BuildLineMapping(639, 18, 3093, 116, 0, 15), + BuildLineMapping(157, 7, 32, 3242, 123, 6, 12), + BuildLineMapping(719, 21, 3325, 128, 0, 12), + BuildLineMapping(733, 21, 3423, 134, 14, 21), + BuildLineMapping(787, 22, 30, 3680, 142, 28, 7), + BuildLineMapping(685, 20, 17, 3836, 148, 19, 23), + BuildLineMapping(708, 20, 40, 3859, 148, 42, 7), + BuildLineMapping(897, 25, 30, 4101, 155, 28, 30), + BuildLineMapping(831, 24, 16, 4280, 161, 19, 8), + BuildLineMapping(840, 24, 25, 4288, 161, 27, 23), + BuildLineMapping(1026, 28, 4546, 168, 28, 30), + BuildLineMapping(964, 27, 16, 4725, 174, 19, 30), + BuildLineMapping(1156, 31, 4990, 181, 28, 3), + BuildLineMapping(1161, 31, 33, 4993, 181, 31, 27), + BuildLineMapping(1189, 31, 61, 5020, 181, 58, 10), + BuildLineMapping(1094, 30, 18, 5179, 187, 19, 29), BuildLineMapping(1231, 34, 5279, 192, 0, 1), } } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/BasicTagHelpers.CustomAttributeCodeGenerator.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/BasicTagHelpers.CustomAttributeCodeGenerator.cs index 006b0e3410..d1561120b7 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/BasicTagHelpers.CustomAttributeCodeGenerator.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/BasicTagHelpers.CustomAttributeCodeGenerator.cs @@ -27,61 +27,117 @@ namespace TestOutput Instrumentation.BeginContext(27, 49, true); WriteLiteral("\r\n
\r\n "); Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test"); - __PTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__PTagHelper); - __tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World"); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - Instrumentation.BeginContext(99, 10, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test"); - __PTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__PTagHelper); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(116, 10, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test"); - __InputTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper); - __InputTagHelper.Type = **From custom attribute code renderer**: "text"; - __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); - __InputTagHelper2 = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper2); - __InputTagHelper2.Type = __InputTagHelper.Type; - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(147, 10, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test"); - __InputTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper); - __InputTagHelper.Type = **From custom attribute code renderer**: "checkbox"; - __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); - __InputTagHelper2 = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper2); - __InputTagHelper2.Type = __InputTagHelper.Type; + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__PTagHelper); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __InputTagHelper.Type = **From custom attribute code renderer**: "text"; + __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); + __InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper2); + __InputTagHelper2.Type = __InputTagHelper.Type; + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __InputTagHelper.Type = **From custom attribute code renderer**: "checkbox"; + __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); + __InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper2); + __InputTagHelper2.Type = __InputTagHelper.Type; #line 7 "BasicTagHelpers.cshtml" __InputTagHelper2.Checked = **From custom attribute code renderer**: true; #line default #line hidden - __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + , StartWritingScope, EndWritingScope); + __PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__PTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World"); __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(196, 6, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); __tagHelperExecutionContext = __tagHelperScopeManager.End(); Instrumentation.BeginContext(206, 8, true); diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/BasicTagHelpers.DesignTime.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/BasicTagHelpers.DesignTime.cs index 9f057ded04..911e0f75f1 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/BasicTagHelpers.DesignTime.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/BasicTagHelpers.DesignTime.cs @@ -32,7 +32,6 @@ namespace TestOutput #pragma warning disable 1998 public override async Task ExecuteAsync() { - __PTagHelper = CreateTagHelper(); __PTagHelper = CreateTagHelper(); __InputTagHelper = CreateTagHelper(); __InputTagHelper.Type = "text"; @@ -47,6 +46,7 @@ namespace TestOutput #line default #line hidden + __PTagHelper = CreateTagHelper(); } #pragma warning restore 1998 } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/BasicTagHelpers.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/BasicTagHelpers.cs index 5acb09e775..5b14a8f598 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/BasicTagHelpers.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/BasicTagHelpers.cs @@ -28,61 +28,117 @@ namespace TestOutput Instrumentation.BeginContext(27, 49, true); WriteLiteral("\r\n
\r\n "); Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test"); - __PTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__PTagHelper); - __tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World"); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - Instrumentation.BeginContext(99, 10, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test"); - __PTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__PTagHelper); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(116, 10, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test"); - __InputTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper); - __InputTagHelper.Type = "text"; - __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); - __InputTagHelper2 = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper2); - __InputTagHelper2.Type = __InputTagHelper.Type; - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(147, 10, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test"); - __InputTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper); - __InputTagHelper.Type = "checkbox"; - __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); - __InputTagHelper2 = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper2); - __InputTagHelper2.Type = __InputTagHelper.Type; + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__PTagHelper); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __InputTagHelper.Type = "text"; + __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); + __InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper2); + __InputTagHelper2.Type = __InputTagHelper.Type; + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __InputTagHelper.Type = "checkbox"; + __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); + __InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper2); + __InputTagHelper2.Type = __InputTagHelper.Type; #line 7 "BasicTagHelpers.cshtml" __InputTagHelper2.Checked = true; #line default #line hidden - __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + , StartWritingScope, EndWritingScope); + __PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__PTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World"); __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(196, 6, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); __tagHelperExecutionContext = __tagHelperScopeManager.End(); Instrumentation.BeginContext(206, 8, true); diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ComplexTagHelpers.DesignTime.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ComplexTagHelpers.DesignTime.cs index 2dc8547ca5..b63a5d2e8b 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ComplexTagHelpers.DesignTime.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ComplexTagHelpers.DesignTime.cs @@ -41,12 +41,6 @@ if (true) #line default #line hidden - __PTagHelper = CreateTagHelper(); -#line 8 "ComplexTagHelpers.cshtml" -__o = DateTime.Now; - -#line default -#line hidden #line 10 "ComplexTagHelpers.cshtml" @@ -60,11 +54,11 @@ __o = DateTime.Now; #line default #line hidden - __PTagHelper = CreateTagHelper(); __InputTagHelper = CreateTagHelper(); __InputTagHelper.Type = "text"; __InputTagHelper2 = CreateTagHelper(); __InputTagHelper2.Type = __InputTagHelper.Type; + __PTagHelper = CreateTagHelper(); #line 13 "ComplexTagHelpers.cshtml" } else @@ -73,7 +67,6 @@ __o = DateTime.Now; #line default #line hidden - __PTagHelper = CreateTagHelper(); __InputTagHelper = CreateTagHelper(); #line 16 "ComplexTagHelpers.cshtml" __o = checkbox; @@ -88,6 +81,7 @@ __o = checkbox; #line default #line hidden + __PTagHelper = CreateTagHelper(); __InputTagHelper = CreateTagHelper(); #line 17 "ComplexTagHelpers.cshtml" __o = true ? "checkbox" : "anything"; @@ -126,8 +120,8 @@ if(true) { #line hidden __PTagHelper = CreateTagHelper(); -#line 21 "ComplexTagHelpers.cshtml" -__PTagHelper.Age = DateTimeOffset.Now.Year - 1970; +#line 8 "ComplexTagHelpers.cshtml" +__o = DateTime.Now; #line default #line hidden @@ -148,6 +142,19 @@ __PTagHelper.Age = DateTimeOffset.Now.Year - 1970; #line 23 "ComplexTagHelpers.cshtml" __InputTagHelper2.Checked = @object; +#line default +#line hidden + __PTagHelper = CreateTagHelper(); +#line 21 "ComplexTagHelpers.cshtml" +__PTagHelper.Age = DateTimeOffset.Now.Year - 1970; + +#line default +#line hidden + __InputTagHelper = CreateTagHelper(); + __InputTagHelper2 = CreateTagHelper(); +#line 26 "ComplexTagHelpers.cshtml" +__InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014; + #line default #line hidden __PTagHelper = CreateTagHelper(); @@ -158,7 +165,7 @@ __PTagHelper.Age = -1970 + DateTimeOffset.Now.Year; #line hidden __InputTagHelper = CreateTagHelper(); __InputTagHelper2 = CreateTagHelper(); -#line 26 "ComplexTagHelpers.cshtml" +#line 29 "ComplexTagHelpers.cshtml" __InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014; #line default @@ -171,8 +178,8 @@ __PTagHelper.Age = DateTimeOffset.Now.Year - 1970; #line hidden __InputTagHelper = CreateTagHelper(); __InputTagHelper2 = CreateTagHelper(); -#line 29 "ComplexTagHelpers.cshtml" -__InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014; +#line 32 "ComplexTagHelpers.cshtml" +__InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014 ; #line default #line hidden @@ -180,13 +187,6 @@ __InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014; #line 31 "ComplexTagHelpers.cshtml" __PTagHelper.Age = "My age is this long.".Length; -#line default -#line hidden - __InputTagHelper = CreateTagHelper(); - __InputTagHelper2 = CreateTagHelper(); -#line 32 "ComplexTagHelpers.cshtml" -__InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014 ; - #line default #line hidden #line 35 "ComplexTagHelpers.cshtml" diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ComplexTagHelpers.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ComplexTagHelpers.cs index 799b71571c..1d2ce6feb2 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ComplexTagHelpers.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/ComplexTagHelpers.cs @@ -40,23 +40,8 @@ namespace TestOutput Instrumentation.BeginContext(78, 55, true); WriteLiteral("
\r\n "); Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test"); - __PTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__PTagHelper); - StartWritingScope(); - WriteLiteral("Current Time: "); -#line 8 "ComplexTagHelpers.cshtml" -Write(DateTime.Now); - -#line default -#line hidden - __tagHelperStringValueBuffer = EndWritingScope(); - __tagHelperExecutionContext.AddHtmlAttribute("time", __tagHelperStringValueBuffer.ToString()); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - Instrumentation.BeginContext(171, 34, true); - WriteLiteral("\r\n

Set Time:

\r\n"); - Instrumentation.EndContext(); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test", async() => { + WriteLiteral("\r\n

Set Time:

\r\n"); #line 10 "ComplexTagHelpers.cshtml" @@ -70,36 +55,62 @@ Write(DateTime.Now); #line default #line hidden - Instrumentation.BeginContext(245, 16, true); - WriteLiteral(" "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test"); - __PTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__PTagHelper); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - Instrumentation.BeginContext(264, 10, true); - WriteLiteral("New Time: "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test"); - __InputTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper); - __InputTagHelper.Type = "text"; - __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); - __InputTagHelper2 = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper2); - __InputTagHelper2.Type = __InputTagHelper.Type; - __tagHelperExecutionContext.AddHtmlAttribute("value", ""); - __tagHelperExecutionContext.AddHtmlAttribute("placeholder", "Enter in a new time..."); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(344, 2, true); - WriteLiteral("\r\n"); - Instrumentation.EndContext(); + WriteLiteral(" "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test", async() => { + WriteLiteral("New Time: "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __InputTagHelper.Type = "text"; + __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); + __InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper2); + __InputTagHelper2.Type = __InputTagHelper.Type; + __tagHelperExecutionContext.AddHtmlAttribute("value", ""); + __tagHelperExecutionContext.AddHtmlAttribute("placeholder", "Enter in a new time..."); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + , StartWritingScope, EndWritingScope); + __PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__PTagHelper); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); #line 13 "ComplexTagHelpers.cshtml" } else @@ -108,134 +119,203 @@ Write(DateTime.Now); #line default #line hidden - Instrumentation.BeginContext(394, 16, true); - WriteLiteral(" "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test"); - __PTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__PTagHelper); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - Instrumentation.BeginContext(413, 14, true); - WriteLiteral("Current Time: "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test"); - __InputTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper); - StartWritingScope(); + WriteLiteral(" "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test", async() => { + WriteLiteral("Current Time: "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + StartWritingScope(); #line 16 "ComplexTagHelpers.cshtml" Write(checkbox); #line default #line hidden - __tagHelperStringValueBuffer = EndWritingScope(); - __InputTagHelper.Type = __tagHelperStringValueBuffer.ToString(); - __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); - __InputTagHelper2 = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper2); - __InputTagHelper2.Type = __InputTagHelper.Type; + __tagHelperStringValueBuffer = EndWritingScope(); + __InputTagHelper.Type = __tagHelperStringValueBuffer.ToString(); + __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); + __InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper2); + __InputTagHelper2.Type = __InputTagHelper.Type; #line 16 "ComplexTagHelpers.cshtml" __InputTagHelper2.Checked = true; #line default #line hidden - __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(468, 18, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test"); - __InputTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper); - StartWritingScope(); + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + , StartWritingScope, EndWritingScope); + __PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__PTagHelper); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + StartWritingScope(); #line 17 "ComplexTagHelpers.cshtml" Write(true ? "checkbox" : "anything"); #line default #line hidden - __tagHelperStringValueBuffer = EndWritingScope(); - __InputTagHelper.Type = __tagHelperStringValueBuffer.ToString(); - __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); - __InputTagHelper2 = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper2); - __InputTagHelper2.Type = __InputTagHelper.Type; - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(536, 18, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test"); - __InputTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper); - StartWritingScope(); + __tagHelperStringValueBuffer = EndWritingScope(); + __InputTagHelper.Type = __tagHelperStringValueBuffer.ToString(); + __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); + __InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper2); + __InputTagHelper2.Type = __InputTagHelper.Type; + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + StartWritingScope(); #line 18 "ComplexTagHelpers.cshtml" if(true) { #line default #line hidden - WriteLiteral(" checkbox "); + WriteLiteral(" checkbox "); #line 18 "ComplexTagHelpers.cshtml" } else { #line default #line hidden - WriteLiteral(" anything "); + WriteLiteral(" anything "); #line 18 "ComplexTagHelpers.cshtml" } #line default #line hidden - __tagHelperStringValueBuffer = EndWritingScope(); - __InputTagHelper.Type = __tagHelperStringValueBuffer.ToString(); - __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); - __InputTagHelper2 = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper2); - __InputTagHelper2.Type = __InputTagHelper.Type; - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(637, 2, true); - WriteLiteral("\r\n"); - Instrumentation.EndContext(); + __tagHelperStringValueBuffer = EndWritingScope(); + __InputTagHelper.Type = __tagHelperStringValueBuffer.ToString(); + __tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type); + __InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper2); + __InputTagHelper2.Type = __InputTagHelper.Type; + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); #line 19 "ComplexTagHelpers.cshtml" } #line default #line hidden - Instrumentation.BeginContext(654, 8, true); - WriteLiteral(" "); - Instrumentation.EndContext(); + WriteLiteral(" "); + } + , StartWritingScope, EndWritingScope); + __PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__PTagHelper); + StartWritingScope(); + WriteLiteral("Current Time: "); +#line 8 "ComplexTagHelpers.cshtml" +Write(DateTime.Now); + +#line default +#line hidden + __tagHelperStringValueBuffer = EndWritingScope(); + __tagHelperExecutionContext.AddHtmlAttribute("time", __tagHelperStringValueBuffer.ToString()); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); __tagHelperExecutionContext = __tagHelperScopeManager.End(); Instrumentation.BeginContext(666, 10, true); WriteLiteral("\r\n "); Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test"); - __PTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__PTagHelper); -#line 21 "ComplexTagHelpers.cshtml" -__PTagHelper.Age = DateTimeOffset.Now.Year - 1970; - -#line default -#line hidden - __tagHelperExecutionContext.AddTagHelperAttribute("age", __PTagHelper.Age); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - Instrumentation.BeginContext(717, 2, true); - WriteLiteral("\r\n"); - Instrumentation.EndContext(); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test", async() => { + WriteLiteral("\r\n"); #line 22 "ComplexTagHelpers.cshtml" @@ -248,33 +328,106 @@ __PTagHelper.Age = DateTimeOffset.Now.Year - 1970; #line default #line hidden - Instrumentation.BeginContext(755, 14, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test"); - __InputTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper); - __InputTagHelper2 = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper2); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper2); #line 23 "ComplexTagHelpers.cshtml" __InputTagHelper2.Checked = @object; #line default #line hidden - __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + , StartWritingScope, EndWritingScope); + __PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__PTagHelper); +#line 21 "ComplexTagHelpers.cshtml" +__PTagHelper.Age = DateTimeOffset.Now.Year - 1970; + +#line default +#line hidden + __tagHelperExecutionContext.AddTagHelperAttribute("age", __PTagHelper.Age); __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(799, 10, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); __tagHelperExecutionContext = __tagHelperScopeManager.End(); Instrumentation.BeginContext(813, 10, true); WriteLiteral("\r\n "); Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper2); +#line 26 "ComplexTagHelpers.cshtml" +__InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014; + +#line default +#line hidden + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + , StartWritingScope, EndWritingScope); __PTagHelper = CreateTagHelper(); __tagHelperExecutionContext.Add(__PTagHelper); #line 25 "ComplexTagHelpers.cshtml" @@ -285,33 +438,61 @@ __PTagHelper.Age = -1970 + DateTimeOffset.Now.Year; __tagHelperExecutionContext.AddTagHelperAttribute("age", __PTagHelper.Age); __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - Instrumentation.BeginContext(865, 14, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test"); - __InputTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper); - __InputTagHelper2 = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper2); -#line 26 "ComplexTagHelpers.cshtml" -__InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014; - -#line default -#line hidden - __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(932, 10, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); __tagHelperExecutionContext = __tagHelperScopeManager.End(); Instrumentation.BeginContext(946, 10, true); WriteLiteral("\r\n "); Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper2); +#line 29 "ComplexTagHelpers.cshtml" +__InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014; + +#line default +#line hidden + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + , StartWritingScope, EndWritingScope); __PTagHelper = CreateTagHelper(); __tagHelperExecutionContext.Add(__PTagHelper); #line 28 "ComplexTagHelpers.cshtml" @@ -322,33 +503,61 @@ __PTagHelper.Age = DateTimeOffset.Now.Year - 1970; __tagHelperExecutionContext.AddTagHelperAttribute("age", __PTagHelper.Age); __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - Instrumentation.BeginContext(996, 14, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test"); - __InputTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper); - __InputTagHelper2 = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper2); -#line 29 "ComplexTagHelpers.cshtml" -__InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014; - -#line default -#line hidden - __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(1060, 10, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); __tagHelperExecutionContext = __tagHelperScopeManager.End(); Instrumentation.BeginContext(1074, 10, true); WriteLiteral("\r\n "); Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test", async() => { + } + , StartWritingScope, EndWritingScope); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper2); +#line 32 "ComplexTagHelpers.cshtml" +__InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014 ; + +#line default +#line hidden + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + , StartWritingScope, EndWritingScope); __PTagHelper = CreateTagHelper(); __tagHelperExecutionContext.Add(__PTagHelper); #line 31 "ComplexTagHelpers.cshtml" @@ -359,27 +568,20 @@ __PTagHelper.Age = "My age is this long.".Length; __tagHelperExecutionContext.AddTagHelperAttribute("age", __PTagHelper.Age); __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - Instrumentation.BeginContext(1126, 14, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test"); - __InputTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper); - __InputTagHelper2 = CreateTagHelper(); - __tagHelperExecutionContext.Add(__InputTagHelper2); -#line 32 "ComplexTagHelpers.cshtml" -__InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014 ; - -#line default -#line hidden - __tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(1203, 10, true); - WriteLiteral("\r\n "); - Instrumentation.EndContext(); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); __tagHelperExecutionContext = __tagHelperScopeManager.End(); Instrumentation.BeginContext(1217, 14, true); diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/SingleTagHelper.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/SingleTagHelper.cs index cb4fa34851..4fb7796615 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/SingleTagHelper.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/SingleTagHelper.cs @@ -26,7 +26,10 @@ namespace TestOutput Instrumentation.BeginContext(27, 2, true); WriteLiteral("\r\n"); Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test", async() => { + WriteLiteral("Body of Tag"); + } + , StartWritingScope, EndWritingScope); __PTagHelper = CreateTagHelper(); __tagHelperExecutionContext.Add(__PTagHelper); #line 3 "SingleTagHelper.cshtml" @@ -38,9 +41,20 @@ namespace TestOutput __tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World"); __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - Instrumentation.BeginContext(63, 11, true); - WriteLiteral("Body of Tag"); - Instrumentation.EndContext(); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); __tagHelperExecutionContext = __tagHelperScopeManager.End(); } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/TagHelpersInHelper.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/TagHelpersInHelper.cs index 4f5ab8a234..9259ead1c9 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/TagHelpersInHelper.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/TagHelpersInHelper.cs @@ -24,7 +24,40 @@ MyHelper(string val) Instrumentation.BeginContext(62, 19, true); WriteLiteralTo(__razor_helper_writer, "
\r\n "); Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", "test"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", "test", async() => { + WriteLiteral("\r\n In None ContentBehavior.\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper", "test", async() => { + WriteLiteral("Some buffered values with a value of "); +#line 8 "TagHelpersInHelper.cshtml" + Write(val); + +#line default +#line hidden + } + , StartWritingScope, EndWritingScope); + __NestedTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__NestedTagHelper); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + , StartWritingScope, EndWritingScope); __MyTagHelper = CreateTagHelper(); __tagHelperExecutionContext.Add(__MyTagHelper); StartWritingScope(); @@ -48,28 +81,22 @@ Write(DateTime.Now); __tagHelperExecutionContext.AddHtmlAttribute("unboundproperty", __tagHelperStringValueBuffer.ToString()); __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateStartTag()); - Instrumentation.BeginContext(184, 52, true); - WriteLiteralTo(__razor_helper_writer, "\r\n In None ContentBehavior.\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper", "test"); - __NestedTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__NestedTagHelper); - StartWritingScope(); - WriteLiteral("Some buffered values with a value of "); -#line 8 "TagHelpersInHelper.cshtml" - Write(val); - -#line default -#line hidden - __tagHelperStringValueBuffer = EndWritingScope(); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext, __tagHelperStringValueBuffer).Result; - WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateContent()); - WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(312, 10, true); - WriteLiteralTo(__razor_helper_writer, "\r\n "); - Instrumentation.EndContext(); + WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + StartWritingScope(__razor_helper_writer); + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + EndWritingScope(); + } + WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GeneratePostContent()); WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateEndTag()); __tagHelperExecutionContext = __tagHelperScopeManager.End(); Instrumentation.BeginContext(336, 14, true); @@ -108,23 +135,33 @@ Write(DateTime.Now); Instrumentation.BeginContext(27, 2, true); WriteLiteral("\r\n"); Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", "test"); - __MyTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__MyTagHelper); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); - Instrumentation.BeginContext(367, 9, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", "test", async() => { #line 12 "TagHelpersInHelper.cshtml" Write(MyHelper(item => new Template((__razor_template_writer) => { - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper", "test"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper", "test", async() => { + WriteLiteral("Custom Value"); + } + , StartWritingScope, EndWritingScope); __NestedTagHelper = CreateTagHelper(); __tagHelperExecutionContext.Add(__NestedTagHelper); - StartWritingScope(); - WriteLiteral("Custom Value"); - __tagHelperStringValueBuffer = EndWritingScope(); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext, __tagHelperStringValueBuffer).Result; + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateContent()); + WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + StartWritingScope(__razor_template_writer); + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + EndWritingScope(); + } + WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GeneratePostContent()); WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateEndTag()); __tagHelperExecutionContext = __tagHelperScopeManager.End(); } @@ -133,7 +170,26 @@ Write(MyHelper(item => new Template((__razor_template_writer) => { #line default #line hidden - Instrumentation.EndContext(); + } + , StartWritingScope, EndWritingScope); + __MyTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__MyTagHelper); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); __tagHelperExecutionContext = __tagHelperScopeManager.End(); Instrumentation.BeginContext(439, 2, true); diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/TagHelpersInSection.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/TagHelpersInSection.cs index 3867c58b59..5763367a13 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/TagHelpersInSection.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/TagHelpersInSection.cs @@ -40,7 +40,40 @@ namespace TestOutput Instrumentation.BeginContext(87, 21, true); WriteLiteralTo(__razor_template_writer, "\r\n
\r\n "); Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", "test"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", "test", async() => { + WriteLiteral("\r\n In None ContentBehavior.\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper", "test", async() => { + WriteLiteral("Some buffered values with "); +#line 11 "TagHelpersInSection.cshtml" + Write(code); + +#line default +#line hidden + } + , StartWritingScope, EndWritingScope); + __NestedTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__NestedTagHelper); + __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; + WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteral(__tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + } + WriteLiteral(__tagHelperExecutionContext.Output.GeneratePostContent()); + WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + , StartWritingScope, EndWritingScope); __MyTagHelper = CreateTagHelper(); __tagHelperExecutionContext.Add(__MyTagHelper); StartWritingScope(); @@ -64,28 +97,22 @@ Write(DateTime.Now); __tagHelperExecutionContext.AddHtmlAttribute("unboundproperty", __tagHelperStringValueBuffer.ToString()); __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateStartTag()); - Instrumentation.BeginContext(211, 52, true); - WriteLiteralTo(__razor_template_writer, "\r\n In None ContentBehavior.\r\n "); - Instrumentation.EndContext(); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper", "test"); - __NestedTagHelper = CreateTagHelper(); - __tagHelperExecutionContext.Add(__NestedTagHelper); - StartWritingScope(); - WriteLiteral("Some buffered values with "); -#line 11 "TagHelpersInSection.cshtml" - Write(code); - -#line default -#line hidden - __tagHelperStringValueBuffer = EndWritingScope(); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext, __tagHelperStringValueBuffer).Result; - WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateStartTag()); - WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateContent()); - WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateEndTag()); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - Instrumentation.BeginContext(329, 10, true); - WriteLiteralTo(__razor_template_writer, "\r\n "); - Instrumentation.EndContext(); + WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GeneratePreContent()); + if (__tagHelperExecutionContext.Output.ContentSet) + { + WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateContent()); + } + else if (__tagHelperExecutionContext.ChildContentRetrieved) + { + WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.GetChildContentAsync().Result); + } + else + { + StartWritingScope(__razor_template_writer); + __tagHelperExecutionContext.ExecuteChildContentAsync().Wait(); + EndWritingScope(); + } + WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GeneratePostContent()); WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateEndTag()); __tagHelperExecutionContext = __tagHelperScopeManager.End(); Instrumentation.BeginContext(353, 14, true);