From c6150ba2878d827b23b1b6f31d2cfe299c88e6b5 Mon Sep 17 00:00:00 2001
From: "N. Taylor Mullen"
Date: Wed, 14 Dec 2016 17:17:50 -0800
Subject: [PATCH] Move section support into IR.
- Previously we'd special case `@section` at code generation time; now we transform the directive into an IR node.
- Changed the expectations of `DefineSection` to not take in a section writer. It's now expected to modify what `Write`, `WriteLiteral` etc. write to when inside of the lambda. This is done today in TagHelpers via `StartTagHelperWritingScope`.
- Updated baseline files to reflect new `DefineSection` expectations.
- Updated IR tests since we no longer leave around `DirectiveIRNode`s.
#901
---
.../DefaultDirectiveIRPass.cs | 56 ++++++++-
.../DefaultRazorRuntimeCSharpLoweringPhase.cs | 24 ----
.../Properties/Resources.Designer.cs | 16 +++
.../RazorIRPassBase.cs | 67 ++++++++++
.../Resources.resx | 3 +
.../DefaultDirectiveIRPassTest.cs | 118 ++++++++++++++++--
.../RuntimeCodeGenerationIntegrationTest.cs | 9 +-
...oft.AspNetCore.Razor.Evolution.Test.csproj | 12 +-
.../DesignTime.codegen.cs | 11 +-
.../InlineBlocks.codegen.cs | 5 +-
.../Sections.codegen.cs | 41 +++---
.../StringLiterals.codegen.cs | 18 ++-
12 files changed, 280 insertions(+), 100 deletions(-)
create mode 100644 src/Microsoft.AspNetCore.Razor.Evolution/RazorIRPassBase.cs
diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/DefaultDirectiveIRPass.cs b/src/Microsoft.AspNetCore.Razor.Evolution/DefaultDirectiveIRPass.cs
index 06d02202eb..ee2e6540b2 100644
--- a/src/Microsoft.AspNetCore.Razor.Evolution/DefaultDirectiveIRPass.cs
+++ b/src/Microsoft.AspNetCore.Razor.Evolution/DefaultDirectiveIRPass.cs
@@ -8,16 +8,25 @@ using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution
{
- internal class DefaultDirectiveIRPass : IRazorIRPass
+ internal class DefaultDirectiveIRPass : RazorIRPassBase
{
- public RazorEngine Engine { get; set; }
+ RazorParserOptions _parserOptions;
- public int Order => 150;
+ public override int Order => 150;
- public DocumentIRNode Execute(RazorCodeDocument codeDocument, DocumentIRNode irDocument)
+ protected override void OnIntialized(RazorCodeDocument codeDocument)
{
- var walker = new DirectiveWalker();
- walker.VisitDefault(irDocument);
+ var syntaxTree = codeDocument.GetSyntaxTree();
+ ThrowForMissingDocumentDependency(syntaxTree);
+
+ _parserOptions = syntaxTree.Options;
+ }
+
+ public override DocumentIRNode ExecuteCore(DocumentIRNode irDocument)
+ {
+ var designTime = _parserOptions.DesignTimeMode;
+ var walker = new DirectiveWalker(designTime);
+ walker.VisitDocument(irDocument);
return irDocument;
}
@@ -25,6 +34,12 @@ namespace Microsoft.AspNetCore.Razor.Evolution
private class DirectiveWalker : RazorIRNodeWalker
{
private ClassDeclarationIRNode _classNode;
+ private readonly bool _designTime;
+
+ public DirectiveWalker(bool designTime)
+ {
+ _designTime = designTime;
+ }
public override void VisitClass(ClassDeclarationIRNode node)
{
@@ -40,6 +55,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution
{
if (string.Equals(node.Name, CSharpCodeParser.FunctionsDirectiveDescriptor.Name, StringComparison.Ordinal))
{
+ node.Parent.Children.Remove(node);
+
foreach (var child in node.Children.Except(node.Tokens))
{
child.Parent = _classNode;
@@ -48,6 +65,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution
}
else if (string.Equals(node.Name, CSharpCodeParser.InheritsDirectiveDescriptor.Name, StringComparison.Ordinal))
{
+ node.Parent.Children.Remove(node);
+
var token = node.Tokens.FirstOrDefault();
if (token != null)
@@ -55,6 +74,31 @@ namespace Microsoft.AspNetCore.Razor.Evolution
_classNode.BaseType = token.Content;
}
}
+ else if (string.Equals(node.Name, CSharpCodeParser.SectionDirectiveDescriptor.Name, StringComparison.Ordinal))
+ {
+ var sectionIndex = node.Parent.Children.IndexOf(node);
+ node.Parent.Children.Remove(node);
+
+ var defineSectionEndStatement = new CSharpStatementIRNode()
+ {
+ Content = "});",
+ };
+ node.Parent.Children.Insert(sectionIndex, defineSectionEndStatement);
+
+ foreach (var child in node.Children.Except(node.Tokens).Reverse())
+ {
+ node.Parent.Children.Insert(sectionIndex, child);
+ }
+
+ var lambdaContent = _designTime ? "__razor_section_writer" : string.Empty;
+ var sectionName = node.Tokens.FirstOrDefault()?.Content;
+ var defineSectionStartStatement = new CSharpStatementIRNode()
+ {
+ Content = /* ORIGINAL: DefineSectionMethodName */ $"DefineSection(\"{sectionName}\", async ({lambdaContent}) => {{",
+ };
+
+ node.Parent.Children.Insert(sectionIndex, defineSectionStartStatement);
+ }
}
}
}
diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/DefaultRazorRuntimeCSharpLoweringPhase.cs b/src/Microsoft.AspNetCore.Razor.Evolution/DefaultRazorRuntimeCSharpLoweringPhase.cs
index e3837b3503..69e97628ce 100644
--- a/src/Microsoft.AspNetCore.Razor.Evolution/DefaultRazorRuntimeCSharpLoweringPhase.cs
+++ b/src/Microsoft.AspNetCore.Razor.Evolution/DefaultRazorRuntimeCSharpLoweringPhase.cs
@@ -436,30 +436,6 @@ namespace Microsoft.AspNetCore.Razor.Evolution
linePragma?.Dispose();
}
- public override void VisitDirective(DirectiveIRNode node)
- {
- if (string.Equals(node.Name, CSharpCodeParser.SectionDirectiveDescriptor.Name, StringComparison.Ordinal))
- {
- const string SectionWriterName = "__razor_section_writer";
-
- Context.Writer
- .WriteStartMethodInvocation("DefineSection" /* ORIGINAL: DefineSectionMethodName */)
- .WriteStringLiteral(node.Tokens.FirstOrDefault()?.Content)
- .WriteParameterSeparator();
-
- var initialRenderingConventions = Context.RenderingConventions;
- var redirectConventions = new CSharpRedirectRenderingConventions(SectionWriterName, Context.Writer);
- Context.RenderingConventions = redirectConventions;
- using (Context.Writer.BuildAsyncLambda(endLine: false, parameterNames: SectionWriterName))
- {
- VisitDefault(node);
- }
- Context.RenderingConventions = initialRenderingConventions;
-
- Context.Writer.WriteEndMethodInvocation();
- }
- }
-
public override void VisitCSharpStatement(CSharpStatementIRNode node)
{
if (string.IsNullOrWhiteSpace(node.Content))
diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Razor.Evolution/Properties/Resources.Designer.cs
index 77c8e4b569..65cf6f06b2 100644
--- a/src/Microsoft.AspNetCore.Razor.Evolution/Properties/Resources.Designer.cs
+++ b/src/Microsoft.AspNetCore.Razor.Evolution/Properties/Resources.Designer.cs
@@ -10,6 +10,22 @@ namespace Microsoft.AspNetCore.Razor.Evolution
private static readonly ResourceManager _resourceManager
= new ResourceManager("Microsoft.AspNetCore.Razor.Evolution.Resources", typeof(Resources).GetTypeInfo().Assembly);
+ ///
+ /// The '{0}' feature requires a '{1}' provided by the '{2}'.
+ ///
+ internal static string FeatureDependencyMissing
+ {
+ get { return GetString("FeatureDependencyMissing"); }
+ }
+
+ ///
+ /// The '{0}' feature requires a '{1}' provided by the '{2}'.
+ ///
+ internal static string FormatFeatureDependencyMissing(object p0, object p1, object p2)
+ {
+ return string.Format(CultureInfo.CurrentCulture, GetString("FeatureDependencyMissing"), p0, p1, p2);
+ }
+
///
/// The '{0}' operation is not valid when the builder is empty.
///
diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/RazorIRPassBase.cs b/src/Microsoft.AspNetCore.Razor.Evolution/RazorIRPassBase.cs
new file mode 100644
index 0000000000..aafc76dc18
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Razor.Evolution/RazorIRPassBase.cs
@@ -0,0 +1,67 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using Microsoft.AspNetCore.Razor.Evolution.Intermediate;
+
+namespace Microsoft.AspNetCore.Razor.Evolution
+{
+ internal abstract class RazorIRPassBase : IRazorIRPass
+ {
+ public RazorEngine Engine { get; set; }
+
+ public virtual int Order => 0;
+
+ protected void ThrowForMissingDocumentDependency(TDocumentDependency value)
+ {
+ if (value == null)
+ {
+ throw new InvalidOperationException(
+ Resources.FormatFeatureDependencyMissing(
+ GetType().Name,
+ typeof(TDocumentDependency).Name,
+ typeof(RazorEngine).Name));
+ }
+ }
+
+ protected void ThrowForMissingEngineDependency(TEngineDependency value)
+ {
+ if (value == null)
+ {
+ throw new InvalidOperationException(
+ Resources.FormatFeatureDependencyMissing(
+ GetType().Name,
+ typeof(TEngineDependency).Name,
+ typeof(RazorCodeDocument).Name));
+ }
+ }
+
+ protected virtual void OnIntialized(RazorCodeDocument codeDocument)
+ {
+ }
+
+ public DocumentIRNode Execute(RazorCodeDocument codeDocument, DocumentIRNode irDocument)
+ {
+ if (codeDocument == null)
+ {
+ throw new ArgumentNullException(nameof(codeDocument));
+ }
+
+ if (irDocument == null)
+ {
+ throw new ArgumentNullException(nameof(irDocument));
+ }
+
+ if (Engine == null)
+ {
+ throw new InvalidOperationException(Resources.FormatPhaseMustBeInitialized(nameof(Engine)));
+ }
+
+ OnIntialized(codeDocument);
+
+ return ExecuteCore(irDocument);
+ }
+
+ public abstract DocumentIRNode ExecuteCore(DocumentIRNode irDocument);
+ }
+}
diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Resources.resx b/src/Microsoft.AspNetCore.Razor.Evolution/Resources.resx
index 0de8a0f668..d893797c8d 100644
--- a/src/Microsoft.AspNetCore.Razor.Evolution/Resources.resx
+++ b/src/Microsoft.AspNetCore.Razor.Evolution/Resources.resx
@@ -117,6 +117,9 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ The '{0}' feature requires a '{1}' provided by the '{2}'.
+
The '{0}' operation is not valid when the builder is empty.
diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/DefaultDirectiveIRPassTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/DefaultDirectiveIRPassTest.cs
index 3e05843f80..3a9717d99d 100644
--- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/DefaultDirectiveIRPassTest.cs
+++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/DefaultDirectiveIRPassTest.cs
@@ -18,11 +18,17 @@ namespace Microsoft.AspNetCore.Razor.Evolution
@functions {
var value = true;
}";
- var originalIRDocument = Lower(content);
- var pass = new DefaultDirectiveIRPass();
+ var sourceDocument = TestRazorSourceDocument.Create(content);
+ var codeDocument = RazorCodeDocument.Create(sourceDocument);
+ var originalIRDocument = Lower(codeDocument);
+ var defaultEngine = RazorEngine.Create();
+ var pass = new DefaultDirectiveIRPass()
+ {
+ Engine = defaultEngine,
+ };
// Act
- var irDocument = pass.Execute(codeDocument: null, irDocument: originalIRDocument);
+ var irDocument = pass.Execute(codeDocument, originalIRDocument);
// Assert
Assert.Same(originalIRDocument, irDocument);
@@ -33,11 +39,17 @@ namespace Microsoft.AspNetCore.Razor.Evolution
{
// Arrange
var content = "@inherits Hello";
- var originalIRDocument = Lower(content);
- var pass = new DefaultDirectiveIRPass();
+ var sourceDocument = TestRazorSourceDocument.Create(content);
+ var codeDocument = RazorCodeDocument.Create(sourceDocument);
+ var originalIRDocument = Lower(codeDocument);
+ var defaultEngine = RazorEngine.Create();
+ var pass = new DefaultDirectiveIRPass()
+ {
+ Engine = defaultEngine,
+ };
// Act
- var irDocument = pass.Execute(codeDocument: null, irDocument: originalIRDocument);
+ var irDocument = pass.Execute(codeDocument, originalIRDocument);
// Assert
Children(irDocument,
@@ -53,15 +65,21 @@ namespace Microsoft.AspNetCore.Razor.Evolution
}
[Fact]
- public void Execute_Functions_ExistsAtClassDeclarationAndMethodLevel()
+ public void Execute_Functions_MovesStatementToClassLevel()
{
// Arrange
var content = "@functions { var value = true; }";
- var originalIRDocument = Lower(content);
- var pass = new DefaultDirectiveIRPass();
+ var sourceDocument = TestRazorSourceDocument.Create(content);
+ var codeDocument = RazorCodeDocument.Create(sourceDocument);
+ var originalIRDocument = Lower(codeDocument);
+ var defaultEngine = RazorEngine.Create();
+ var pass = new DefaultDirectiveIRPass()
+ {
+ Engine = defaultEngine,
+ };
// Act
- var irDocument = pass.Execute(codeDocument: null, irDocument: originalIRDocument);
+ var irDocument = pass.Execute(codeDocument, originalIRDocument);
// Assert
Children(irDocument,
@@ -79,17 +97,91 @@ namespace Microsoft.AspNetCore.Razor.Evolution
var method = (RazorMethodDeclarationIRNode)@class.Children[0];
Children(method,
node => Html(string.Empty, node),
- node => Directive("functions", node,
- directiveChild => CSharpStatement(" var value = true; ", directiveChild)),
node => Html(string.Empty, node));
}
- private static DocumentIRNode Lower(string content)
+ [Fact]
+ public void Execute_Section_WrapsStatementInDefineSection()
{
+ // Arrange
+ var content = "@section Header { Hello World
}";
var sourceDocument = TestRazorSourceDocument.Create(content);
var codeDocument = RazorCodeDocument.Create(sourceDocument);
+ var originalIRDocument = Lower(codeDocument);
+ var defaultEngine = RazorEngine.Create();
+ var pass = new DefaultDirectiveIRPass()
+ {
+ Engine = defaultEngine,
+ };
+
+ // Act
+ var irDocument = pass.Execute(codeDocument, originalIRDocument);
+
+ // Assert
+ Children(irDocument,
+ node => Assert.IsType(node),
+ node => Assert.IsType(node));
+ var @namespace = irDocument.Children[1];
+ Children(@namespace,
+ node => Assert.IsType(node),
+ node => Assert.IsType(node),
+ node => Assert.IsType(node));
+ var @class = @namespace.Children[2];
+ var method = SingleChild(@class);
+ Children(method,
+ node => Html(string.Empty, node),
+ node => CSharpStatement("DefineSection(\"Header\", async () => {", node),
+ node => Html(" Hello World
", node),
+ node => CSharpStatement("});", node),
+ node => Html(string.Empty, node));
+ }
+
+ [Fact]
+ public void Execute_Section_DesignTime_WrapsStatementInBackwardsCompatibleDefineSection()
+ {
+ // Arrange
+ var content = "@section Header { Hello World
}";
+ var designTimeEngine = RazorEngine.CreateDesignTime();
+ var sourceDocument = TestRazorSourceDocument.Create(content);
+ var codeDocument = RazorCodeDocument.Create(sourceDocument);
+ var originalIRDocument = Lower(codeDocument, designTimeEngine);
+ var defaultEngine = RazorEngine.Create();
+ var pass = new DefaultDirectiveIRPass()
+ {
+ Engine = defaultEngine,
+ };
+
+ // Act
+ var irDocument = pass.Execute(codeDocument, originalIRDocument);
+
+ // Assert
+ Children(irDocument,
+ node => Assert.IsType(node),
+ node => Assert.IsType(node));
+ var @namespace = irDocument.Children[1];
+ Children(@namespace,
+ node => Assert.IsType(node),
+ node => Assert.IsType(node),
+ node => Assert.IsType(node));
+ var @class = @namespace.Children[2];
+ var method = SingleChild(@class);
+ Children(method,
+ node => Html(string.Empty, node),
+ node => CSharpStatement("DefineSection(\"Header\", async (__razor_section_writer) => {", node),
+ node => Html(" Hello World
", node),
+ node => CSharpStatement("});", node),
+ node => Html(string.Empty, node));
+ }
+
+ private static DocumentIRNode Lower(RazorCodeDocument codeDocument)
+ {
var engine = RazorEngine.Create();
+ return Lower(codeDocument, engine);
+ }
+
+ private static DocumentIRNode Lower(RazorCodeDocument codeDocument, RazorEngine engine)
+ {
for (var i = 0; i < engine.Phases.Count; i++)
{
var phase = engine.Phases[i];
diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/RuntimeCodeGenerationIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/RuntimeCodeGenerationIntegrationTest.cs
index d4fec979b3..29a69bfe17 100644
--- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/RuntimeCodeGenerationIntegrationTest.cs
+++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/RuntimeCodeGenerationIntegrationTest.cs
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Evolution.Intermediate;
using Microsoft.AspNetCore.Testing.xunit;
@@ -556,13 +557,9 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests
AssertCSharpDocumentMatchesBaseline(document.GetCSharpDocument());
}
- private class ApiSetsIRTestAdapter : IRazorIRPass
+ private class ApiSetsIRTestAdapter : RazorIRPassBase
{
- public RazorEngine Engine { get; set; }
-
- public int Order { get; set; }
-
- public DocumentIRNode Execute(RazorCodeDocument codeDocument, DocumentIRNode irDocument)
+ public override DocumentIRNode ExecuteCore(DocumentIRNode irDocument)
{
var walker = new ApiSetsIRWalker();
walker.Visit(irDocument);
diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Microsoft.AspNetCore.Razor.Evolution.Test.csproj b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Microsoft.AspNetCore.Razor.Evolution.Test.csproj
index 40e82f1916..b28819ae05 100644
--- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Microsoft.AspNetCore.Razor.Evolution.Test.csproj
+++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Microsoft.AspNetCore.Razor.Evolution.Test.csproj
@@ -1,22 +1,17 @@
-
-
+
-
netcoreapp1.0;net451
$(DefineConstants);__RemoveThisBitTo__GENERATE_BASELINES
-
-
-
@@ -24,16 +19,13 @@
-
-
-
-
+
\ No newline at end of file
diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/DesignTime.codegen.cs
index d90e829afd..e0e1e9d8db 100644
--- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/DesignTime.codegen.cs
+++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/DesignTime.codegen.cs
@@ -51,16 +51,15 @@ WriteTo(__razor_template_writer, baz);
#line default
#line hidden
WriteLiteral("\r\n
\r\n\r\n");
- DefineSection("Footer", async(__razor_section_writer) => {
- WriteLiteralTo(__razor_section_writer, "\r\n Foo
\r\n ");
+ DefineSection("Footer", async () => {
+ WriteLiteral("\r\n Foo
\r\n ");
#line 14 "TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/DesignTime.cshtml"
-WriteTo(__razor_section_writer, bar);
+Write(bar);
#line default
#line hidden
- WriteLiteralTo(__razor_section_writer, "\r\n");
- }
- );
+ WriteLiteral("\r\n");
+ });
}
#pragma warning restore 1998
}
diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/InlineBlocks.codegen.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/InlineBlocks.codegen.cs
index 1fd7e79869..edffd8c7a4 100644
--- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/InlineBlocks.codegen.cs
+++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/InlineBlocks.codegen.cs
@@ -9,9 +9,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
#pragma warning disable 1998
public async System.Threading.Tasks.Task ExecuteAsync()
{
- DefineSection("Link", async(__razor_section_writer) => {
- }
- );
+ DefineSection("Link", async () => {
+ });
WriteLiteral("(string link) {\r\n {
diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/Sections.codegen.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/Sections.codegen.cs
index b60fd24b14..9c976e77e1 100644
--- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/Sections.codegen.cs
+++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/Sections.codegen.cs
@@ -17,49 +17,46 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
#line default
#line hidden
WriteLiteral("\r\nThis is in the Body>\r\n\r\n");
- DefineSection("Section2", async(__razor_section_writer) => {
- WriteLiteralTo(__razor_section_writer, "\r\n
{
+ WriteLiteral("\r\n
This is in Section 2
\r\n");
- }
- );
+ EndWriteAttribute();
+ WriteLiteral(">This is in Section 2
\r\n");
+ });
WriteLiteral("\r\n");
- DefineSection("Section1", async(__razor_section_writer) => {
- WriteLiteralTo(__razor_section_writer, "\r\n
This is in Section 1
\r\n");
- }
- );
+ DefineSection("Section1", async () => {
+ WriteLiteral("\r\n
This is in Section 1
\r\n");
+ });
+ WriteLiteral("\r\n");
+ DefineSection("NestedDelegates", async () => {
WriteLiteral("\r\n");
- DefineSection("NestedDelegates", async(__razor_section_writer) => {
- WriteLiteralTo(__razor_section_writer, "\r\n");
#line 16 "TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/Sections.cshtml"
Func
f =
#line default
#line hidden
- item => new HelperResult(async(__razor_template_writer) => {
- WriteLiteralTo(__razor_template_writer, "");
+ item => new HelperResult(async(__razor_template_writer) => {
+ WriteLiteralTo(__razor_template_writer, "");
#line 16 "TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/Sections.cshtml"
WriteTo(__razor_template_writer, item);
#line default
#line hidden
- WriteLiteralTo(__razor_template_writer, "");
- }
- )
+ WriteLiteralTo(__razor_template_writer, "");
+ }
+ )
#line 16 "TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/Sections.cshtml"
;
#line default
#line hidden
- }
- );
+ });
}
#pragma warning restore 1998
}
diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/StringLiterals.codegen.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/StringLiterals.codegen.cs
index e66f6eac50..5e40fc0fb3 100644
--- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/StringLiterals.codegen.cs
+++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/RuntimeCodeGenerationIntegrationTest/StringLiterals.codegen.cs
@@ -96,8 +96,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
This is line 84
");
- DefineSection("WriteLiteralsToInHere", async(__razor_section_writer) => {
- WriteLiteralTo(__razor_section_writer, @"
+ DefineSection("WriteLiteralsToInHere", async () => {
+ WriteLiteral(@"
This is line 1 nested
This is line 2 nested
This is line 3 nested
@@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
This is line 28 nested
This is line 29 nested
This is l");
- WriteLiteralTo(__razor_section_writer, @"ine 30 nested
+ WriteLiteral(@"ine 30 nested
This is line 31 nested
This is line 32 nested
This is line 33 nested
@@ -158,7 +158,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
This is line 57 nested
This is line 58 nested
This is line 59 ne");
- WriteLiteralTo(__razor_section_writer, @"sted
+ WriteLiteral(@"sted
This is line 60 nested
This is line 61 nested
This is line 62 nested
@@ -176,8 +176,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
This is line 74 nested
This is line 75 nested
");
- }
- );
+ });
WriteLiteral(@"This is line 1
This is line 2
This is line 3
@@ -222,8 +221,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
This is line 42
This is line 43
hi!");
WriteLiteral("\r\n");
- DefineSection("WriteLiteralsToInHereAlso", async(__razor_section_writer) => {
- WriteLiteralTo(__razor_section_writer, @"
+ DefineSection("WriteLiteralsToInHereAlso", async () => {
+ WriteLiteral(@"
This is line 1 nested
This is line 2 nested
This is line 3 nested
@@ -255,8 +254,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
This is line 29 nested
30
");
- }
- );
+ });
WriteLiteral("!");
}
#pragma warning restore 1998