diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionTargetExtension.cs
index e99c1598f3..ba1f637ad6 100644
--- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionTargetExtension.cs
+++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionTargetExtension.cs
@@ -22,9 +22,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
.Write(node.SectionName)
.Write("\", ");
- using (context.CodeWriter.BuildAsyncLambda(DefaultWriterName))
+ if (context.Options.DesignTime)
{
- context.RenderChildren(node);
+ using (context.CodeWriter.BuildAsyncLambda(DefaultWriterName))
+ {
+ context.RenderChildren(node);
+ }
+ }
+ else
+ {
+ using (context.CodeWriter.BuildAsyncLambda())
+ {
+ context.RenderChildren(node);
+ }
}
context.CodeWriter.WriteEndMethodInvocation(endLine: true);
diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs
index 95aa1a96a8..ba56f04308 100644
--- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs
+++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs
@@ -51,7 +51,7 @@ namespace AspNetCore
BeginContext(117, 26, true);
WriteLiteral("\r\n
Some body
\r\n\r\n");
EndContext();
- DefineSection("Section1", async(__razor_section_writer) => {
+ DefineSection("Section1", async() => {
BeginContext(162, 43, true);
WriteLiteral("\r\n This is in Section 1
\r\n ");
EndContext();
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/SectionTargetExtensionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/SectionTargetExtensionTest.cs
index bfeb71ffb7..16288b3117 100644
--- a/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/SectionTargetExtensionTest.cs
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Extensions/SectionTargetExtensionTest.cs
@@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
extension.WriteSection(context, node);
// Assert
- var expected = @"CreateSection(""MySection"", async(__razor_section_writer) => {
+ var expected = @"CreateSection(""MySection"", async() => {
Render Children
}
);
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs
index 179aa5c3d8..128b60701f 100644
--- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs
@@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
#line default
#line hidden
WriteLiteral("\r\nThis is in the Body>\r\n\r\n");
- DefineSection("Section2", async(__razor_section_writer) => {
+ DefineSection("Section2", async() => {
WriteLiteral("\r\n
{
+ DefineSection("Section1", async() => {
WriteLiteral("\r\n
This is in Section 1
\r\n");
}
);
WriteLiteral("\r\n");
- DefineSection("NestedDelegates", async(__razor_section_writer) => {
+ DefineSection("NestedDelegates", async() => {
WriteLiteral("\r\n");
#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml"
Func
f =
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs
index e3770e0570..ba174de703 100644
--- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs
@@ -96,7 +96,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
This is line 84
");
- DefineSection("WriteLiteralsToInHere", async(__razor_section_writer) => {
+ DefineSection("WriteLiteralsToInHere", async() => {
WriteLiteral(@"
This is line 1 nested
This is line 2 nested
@@ -222,7 +222,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
This is line 42
This is line 43
hi!");
WriteLiteral("\r\n");
- DefineSection("WriteLiteralsToInHereAlso", async(__razor_section_writer) => {
+ DefineSection("WriteLiteralsToInHereAlso", async() => {
WriteLiteral(@"
This is line 1 nested
This is line 2 nested
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs
index d8924cbaab..1d3fbf2f83 100644
--- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs
@@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
#line default
#line hidden
WriteLiteral("\r\n");
- DefineSection("MySection", async(__razor_section_writer) => {
+ DefineSection("MySection", async() => {
WriteLiteral("\r\n \r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => {
WriteLiteral("\r\n In None ContentBehavior.\r\n ");