Made section 1.X compatibility only apply at design time.

#1637
This commit is contained in:
N. Taylor Mullen 2017-08-22 17:37:09 -07:00
parent 5104e8c806
commit 6e42c8d0e4
6 changed files with 20 additions and 10 deletions

View File

@ -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);

View File

@ -51,7 +51,7 @@ namespace AspNetCore
BeginContext(117, 26, true);
WriteLiteral("\r\n<div>Some body</div>\r\n\r\n");
EndContext();
DefineSection("Section1", async(__razor_section_writer) => {
DefineSection("Section1", async() => {
BeginContext(162, 43, true);
WriteLiteral("\r\n <div>This is in Section 1</div>\r\n ");
EndContext();

View File

@ -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
}
);

View File

@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
#line default
#line hidden
WriteLiteral("\r\n<div>This is in the Body>\r\n\r\n");
DefineSection("Section2", async(__razor_section_writer) => {
DefineSection("Section2", async() => {
WriteLiteral("\r\n <div");
BeginWriteAttribute("class", " class=\"", 109, "\"", 128, 2);
WriteAttributeValue("", 117, "some", 117, 4, true);
@ -30,12 +30,12 @@ WriteAttributeValue(" ", 121, thing, 122, 6, false);
}
);
WriteLiteral("\r\n");
DefineSection("Section1", async(__razor_section_writer) => {
DefineSection("Section1", async() => {
WriteLiteral("\r\n <div>This is in Section 1</div>\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<dynamic, object> f =

View File

@ -96,7 +96,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
<p>This is line 84</p><br>
");
DefineSection("WriteLiteralsToInHere", async(__razor_section_writer) => {
DefineSection("WriteLiteralsToInHere", async() => {
WriteLiteral(@"
<p>This is line 1 nested</p>
<p>This is line 2 nested</p>
@ -222,7 +222,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
<p>This is line 42</p>
<p>This is line 43</p>hi!");
WriteLiteral("\r\n");
DefineSection("WriteLiteralsToInHereAlso", async(__razor_section_writer) => {
DefineSection("WriteLiteralsToInHereAlso", async() => {
WriteLiteral(@"
<p>This is line 1 nested</p>
<p>This is line 2 nested</p>

View File

@ -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 <div>\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => {
WriteLiteral("\r\n In None ContentBehavior.\r\n ");