diff --git a/src/Microsoft.AspNetCore.Razor/CodeGenerators/Visitors/CSharpCodeVisitor.cs b/src/Microsoft.AspNetCore.Razor/CodeGenerators/Visitors/CSharpCodeVisitor.cs index 2317168d9c..52d5fa6872 100644 --- a/src/Microsoft.AspNetCore.Razor/CodeGenerators/Visitors/CSharpCodeVisitor.cs +++ b/src/Microsoft.AspNetCore.Razor/CodeGenerators/Visitors/CSharpCodeVisitor.cs @@ -15,6 +15,7 @@ namespace Microsoft.AspNetCore.Razor.CodeGenerators.Visitors private const string ItemParameterName = "item"; private const string ValueWriterName = "__razor_attribute_value_writer"; private const string TemplateWriterName = "__razor_template_writer"; + private const string SectionWriterName = "__razor_section_writer"; private const int MaxStringLiteralLength = 1024; private CSharpPaddingBuilder _paddingBuilder; @@ -377,9 +378,9 @@ namespace Microsoft.AspNetCore.Razor.CodeGenerators.Visitors .WriteParameterSeparator(); var currentTargetWriterName = Context.TargetWriterName; - Context.TargetWriterName = TemplateWriterName; + Context.TargetWriterName = SectionWriterName; - using (Writer.BuildAsyncLambda(endLine: false, parameterNames: TemplateWriterName)) + using (Writer.BuildAsyncLambda(endLine: false, parameterNames: SectionWriterName)) { Accept(chunk.Children); } diff --git a/test/Microsoft.AspNetCore.Razor.Test/CodeGenerators/CSharpRazorChunkGeneratorTest.cs b/test/Microsoft.AspNetCore.Razor.Test/CodeGenerators/CSharpRazorChunkGeneratorTest.cs index b71773f3e1..68aa820afd 100644 --- a/test/Microsoft.AspNetCore.Razor.Test/CodeGenerators/CSharpRazorChunkGeneratorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Test/CodeGenerators/CSharpRazorChunkGeneratorTest.cs @@ -397,7 +397,7 @@ namespace Microsoft.AspNetCore.Razor.Test.Generator documentAbsoluteIndex: 204, documentLineIndex: 13, documentCharacterOffsetIndex: 5, - generatedAbsoluteIndex: 1197, + generatedAbsoluteIndex: 1196, generatedLineIndex: 60, generatedCharacterOffsetIndex: 6, contentLength: 3), diff --git a/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/DesignTime.cs b/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/DesignTime.cs index f56d6c3a82..ab5c840087 100644 --- a/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/DesignTime.cs +++ b/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/DesignTime.cs @@ -56,7 +56,7 @@ __o = Foo(item => new Template(async(__razor_template_writer) => { #line default #line hidden - DefineSection("Footer", async(__razor_template_writer) => { + DefineSection("Footer", async(__razor_section_writer) => { #line 14 "DesignTime.cshtml" __o = bar; diff --git a/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/InlineBlocks.cs b/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/InlineBlocks.cs index 919ab4b1b9..b998570ff4 100644 --- a/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/InlineBlocks.cs +++ b/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/InlineBlocks.cs @@ -14,7 +14,7 @@ namespace TestOutput #pragma warning disable 1998 public override async Task ExecuteAsync() { - DefineSection("Link", async(__razor_template_writer) => { + DefineSection("Link", async(__razor_section_writer) => { } ); Instrumentation.BeginContext(13, 23, true); diff --git a/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/Sections.cs b/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/Sections.cs index 65b5664e29..2f4c60a1ca 100644 --- a/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/Sections.cs +++ b/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/Sections.cs @@ -1,4 +1,4 @@ -#pragma checksum "Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "19b065ba387522fb8b9b4aea4820b3752d898d0a" +#pragma checksum "Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "bf45c2508895b4b9b3579bc193e7a0167ccdbdfb" namespace TestOutput { using System; @@ -24,21 +24,64 @@ namespace TestOutput Instrumentation.BeginContext(49, 31, true); WriteLiteral("\r\n
This is line 1 nested
This is line 2 nested
This is line 3 nested
@@ -136,7 +136,7 @@ namespace TestOutputThis is line 28 nested
This is line 29 nested
This is l"); - WriteLiteralTo(__razor_template_writer, @"ine 30 nested
+ WriteLiteralTo(__razor_section_writer, @"ine 30 nestedThis is line 31 nested
This is line 32 nested
This is line 33 nested
@@ -166,7 +166,7 @@ namespace TestOutputThis is line 57 nested
This is line 58 nested
This is line 59 ne"); - WriteLiteralTo(__razor_template_writer, @"sted
+ WriteLiteralTo(__razor_section_writer, @"stedThis is line 60 nested
This is line 61 nested
This is line 62 nested
@@ -233,9 +233,9 @@ namespace TestOutputThis is line 43
hi!"); WriteLiteral("\r\n"); Instrumentation.EndContext(); - DefineSection("WriteLiteralsToInHereAlso", async(__razor_template_writer) => { + DefineSection("WriteLiteralsToInHereAlso", async(__razor_section_writer) => { Instrumentation.BeginContext(5728, 1023, true); - WriteLiteralTo(__razor_template_writer, @" + WriteLiteralTo(__razor_section_writer, @"This is line 1 nested
This is line 2 nested
This is line 3 nested
diff --git a/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/TagHelpersInSection.cs b/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/TagHelpersInSection.cs index 666d7c0ddc..ae13a380f8 100644 --- a/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/TagHelpersInSection.cs +++ b/test/Microsoft.AspNetCore.Razor.Test/TestFiles/CodeGenerator/Output/TagHelpersInSection.cs @@ -37,9 +37,9 @@ namespace TestOutput Instrumentation.BeginContext(69, 2, true); WriteLiteral("\r\n"); Instrumentation.EndContext(); - DefineSection("MySection", async(__razor_template_writer) => { + DefineSection("MySection", async(__razor_section_writer) => { Instrumentation.BeginContext(91, 21, true); - WriteLiteralTo(__razor_template_writer, "\r\n