diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs
index ae4d3ec872..6acb3d4bf4 100644
--- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs
+++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs
@@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.IntegrationTests
: base(generateBaselines: null, projectDirectoryHint: "Microsoft.AspNetCore.Mvc.Razor.Extensions")
{
Configuration = RazorConfiguration.Create(
- RazorLanguageVersion.Version_3_0,
+ RazorLanguageVersion.Latest,
"MVC-3.0",
new[] { new AssemblyExtension("MVC-3.0", typeof(ExtensionInitializer).Assembly) });
}
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentWhitespacePass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentWhitespacePass.cs
index 34febfbf9a..29e2dd9c9d 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentWhitespacePass.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentWhitespacePass.cs
@@ -39,17 +39,38 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
return;
}
- // Respect @preservewhitespace directives
- if (PreserveWhitespaceIsEnabled(documentNode))
+ var razorLanguageVersion = codeDocument.GetParserOptions().Version;
+ var useLegacyBehavior = razorLanguageVersion.CompareTo(RazorLanguageVersion.Version_5_0) < 0;
+ if (useLegacyBehavior)
{
- return;
- }
+ // Prior to 5.0, the whitespace pass only applied to the BuildRenderTree method, and
+ // only removed the top-level leading and trailing whitespace
- var @class = documentNode.FindPrimaryClass();
- if (@class != null)
+ var method = documentNode.FindPrimaryMethod();
+ if (method != null)
+ {
+ RemoveContiguousWhitespace(method.Children, TraversalDirection.Forwards);
+ RemoveContiguousWhitespace(method.Children, TraversalDirection.Backwards);
+ }
+ }
+ else
{
- var visitor = new Visitor();
- visitor.Visit(@class);
+ // From 5.0 onwards, the whitespace pass applies as broadly as possible. It removes leading
+ // and trailing whitespace from all methods, elements, and child component blocks. There's
+ // also a directive that can disable it.
+
+ // Respect @preservewhitespace directives
+ if (PreserveWhitespaceIsEnabled(documentNode))
+ {
+ return;
+ }
+
+ var @class = documentNode.FindPrimaryClass();
+ if (@class != null)
+ {
+ var visitor = new Visitor();
+ visitor.Visit(@class);
+ }
}
}
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
index c0b3fd708e..8f23ea01ec 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
@@ -4768,6 +4768,240 @@ namespace Test
int Foo = 18;
}
+");
+
+ // Assert
+ AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
+ AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
+ CompileToAssembly(generated);
+ }
+
+ #endregion
+
+ #region Legacy 3.1 Whitespace
+
+ [Fact]
+ public void Legacy_3_1_LeadingWhiteSpace_WithDirective()
+ {
+ // Arrange/Act
+ _configuration = RazorConfiguration.Create(
+ RazorLanguageVersion.Version_3_0,
+ base.Configuration.ConfigurationName,
+ base.Configuration.Extensions);
+
+ var generated = CompileToCSharp(@"
+
+@using System
+
+
Hello
");
+
+ // Assert
+ AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
+ AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
+ CompileToAssembly(generated);
+ }
+
+ [Fact]
+ public void Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression()
+ {
+ // Arrange/Act
+ _configuration = RazorConfiguration.Create(
+ RazorLanguageVersion.Version_3_0,
+ base.Configuration.ConfigurationName,
+ base.Configuration.Extensions);
+
+ var generated = CompileToCSharp(@"
+
+@(""My value"")
+
+Hello
");
+
+ // Assert
+ AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
+ AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
+ CompileToAssembly(generated);
+ }
+
+ [Fact]
+ public void Legacy_3_1_LeadingWhiteSpace_WithComponent()
+ {
+ // Arrange
+ _configuration = RazorConfiguration.Create(
+ RazorLanguageVersion.Version_3_0,
+ base.Configuration.ConfigurationName,
+ base.Configuration.Extensions);
+
+ AdditionalSyntaxTrees.Add(Parse(@"
+using Microsoft.AspNetCore.Components;
+
+namespace Test
+{
+ public class SomeOtherComponent : ComponentBase
+ {
+ [Parameter] public RenderFragment ChildContent { get; set; }
+ }
+}
+"));
+
+ // Act
+ var generated = CompileToCSharp(@"
+
+ Child content at @DateTime.Now
+ Very @(""good"")
+
+
+Hello
");
+
+ // Assert
+ AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
+ AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
+ CompileToAssembly(generated);
+ }
+
+ [Fact]
+ public void Legacy_3_1_TrailingWhiteSpace_WithDirective()
+ {
+ // Arrange/Act
+ _configuration = RazorConfiguration.Create(
+ RazorLanguageVersion.Version_3_0,
+ base.Configuration.ConfigurationName,
+ base.Configuration.Extensions);
+
+ var generated = CompileToCSharp(@"
+Hello
+
+@page ""/my/url""
+
+");
+
+ // Assert
+ AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
+ AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
+ CompileToAssembly(generated);
+ }
+
+ [Fact]
+ public void Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression()
+ {
+ // Arrange/Act
+ _configuration = RazorConfiguration.Create(
+ RazorLanguageVersion.Version_3_0,
+ base.Configuration.ConfigurationName,
+ base.Configuration.Extensions);
+
+ var generated = CompileToCSharp(@"
+Hello
+
+@(""My value"")
+
+");
+
+ // Assert
+ AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
+ AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
+ CompileToAssembly(generated);
+ }
+
+ [Fact]
+ public void Legacy_3_1_TrailingWhiteSpace_WithComponent()
+ {
+ // Arrange
+ _configuration = RazorConfiguration.Create(
+ RazorLanguageVersion.Version_3_0,
+ base.Configuration.ConfigurationName,
+ base.Configuration.Extensions);
+
+ AdditionalSyntaxTrees.Add(Parse(@"
+using Microsoft.AspNetCore.Components;
+
+namespace Test
+{
+ public class SomeOtherComponent : ComponentBase
+ {
+ }
+}
+"));
+
+ // Act
+ var generated = CompileToCSharp(@"
+Hello
+
+
+
+");
+
+ // Assert
+ AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
+ AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
+ CompileToAssembly(generated);
+ }
+
+ [Fact]
+ public void Legacy_3_1_Whitespace_BetweenElementAndFunctions()
+ {
+ // Arrange
+ _configuration = RazorConfiguration.Create(
+ RazorLanguageVersion.Version_3_0,
+ base.Configuration.ConfigurationName,
+ base.Configuration.Extensions);
+
+ // Act
+ var generated = CompileToCSharp(@"
+
+ @code {
+ int Foo = 18;
+ }
+");
+
+ // Assert
+ AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
+ AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
+ CompileToAssembly(generated);
+ }
+
+ [Fact]
+ public void Legacy_3_1_WhiteSpace_InsideAttribute_InMarkupBlock()
+ {
+ // Arrange
+ _configuration = RazorConfiguration.Create(
+ RazorLanguageVersion.Version_3_0,
+ base.Configuration.ConfigurationName,
+ base.Configuration.Extensions);
+
+ // Act
+ var generated = CompileToCSharp(@"Hello
");
+
+ // Assert
+ AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
+ AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
+ CompileToAssembly(generated);
+ }
+
+ [Fact]
+ public void Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock()
+ {
+ // Arrange
+ _configuration = RazorConfiguration.Create(
+ RazorLanguageVersion.Version_3_0,
+ base.Configuration.ConfigurationName,
+ base.Configuration.Extensions);
+
+ // Act
+ var generated = CompileToCSharp(@"
+@using Microsoft.AspNetCore.Components.Rendering
+@code {
+ void MyMethod(RenderTreeBuilder __builder)
+ {
+
+ @for (var i = 0; i < 100; i++)
+ {
+ -
+ @i
+
+ }
+
+ }
+}
");
// Assert
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs
new file mode 100644
index 0000000000..7bd71349a9
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs
@@ -0,0 +1,34 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 219
+ private void __RazorDirectiveTokenHelpers__() {
+ }
+ #pragma warning restore 219
+ #pragma warning disable 0414
+ private static System.Object __o = null;
+ #pragma warning restore 0414
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+__o = "My value";
+
+#line default
+#line hidden
+#nullable disable
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt
new file mode 100644
index 0000000000..492a34771b
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt
@@ -0,0 +1,23 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [12] ) - System
+ UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [17] ) - System.Linq
+ UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ DesignTimeDirective -
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning disable 0414
+ CSharpCode -
+ IntermediateToken - - CSharp - private static System.Object __o = null;
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning restore 0414
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ CSharpExpression - (2:0,2 [10] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (2:0,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "My value"
+ HtmlContent - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
+ MarkupElement - (17:2,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1
+ HtmlContent - (21:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (21:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.mappings.txt
new file mode 100644
index 0000000000..b37b592b3a
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.mappings.txt
@@ -0,0 +1,5 @@
+Source Location: (2:0,2 [10] x:\dir\subdir\Test\TestComponent.cshtml)
+|"My value"|
+Generated Location: (858:24,6 [10] )
+|"My value"|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs
new file mode 100644
index 0000000000..f71ec2143d
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs
@@ -0,0 +1,51 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 219
+ private void __RazorDirectiveTokenHelpers__() {
+ }
+ #pragma warning restore 219
+ #pragma warning disable 0414
+ private static System.Object __o = null;
+ #pragma warning restore 0414
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ __builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => {
+#nullable restore
+#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
+ __o = DateTime.Now;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+ __o = "good";
+
+#line default
+#line hidden
+#nullable disable
+ }
+ ));
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+__o = typeof(SomeOtherComponent);
+
+#line default
+#line hidden
+#nullable disable
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.ir.txt
new file mode 100644
index 0000000000..e49244d1ba
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.ir.txt
@@ -0,0 +1,39 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [12] ) - System
+ UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [17] ) - System.Linq
+ UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ DesignTimeDirective -
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning disable 0414
+ CSharpCode -
+ IntermediateToken - - CSharp - private static System.Object __o = null;
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning restore 0414
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ Component - (0:0,0 [115] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent
+ ComponentChildContent - - ChildContent - context
+ HtmlContent - (20:0,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (20:0,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ MarkupElement - (26:1,4 [39] x:\dir\subdir\Test\TestComponent.cshtml) - h1
+ HtmlContent - (30:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (30:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Child content at
+ CSharpExpression - (48:1,26 [12] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (48:1,26 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - DateTime.Now
+ HtmlContent - (65:1,43 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (65:1,43 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ MarkupElement - (71:2,4 [21] x:\dir\subdir\Test\TestComponent.cshtml) - p
+ HtmlContent - (74:2,7 [5] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (74:2,7 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Very
+ CSharpExpression - (81:2,14 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (81:2,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "good"
+ HtmlContent - (92:2,25 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (92:2,25 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ HtmlContent - (115:3,21 [4] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (115:3,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
+ MarkupElement - (119:5,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1
+ HtmlContent - (123:5,4 [5] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (123:5,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.mappings.txt
new file mode 100644
index 0000000000..11d74d7703
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.mappings.txt
@@ -0,0 +1,10 @@
+Source Location: (48:1,26 [12] x:\dir\subdir\Test\TestComponent.cshtml)
+|DateTime.Now|
+Generated Location: (1001:25,26 [12] )
+|DateTime.Now|
+
+Source Location: (81:2,14 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+|"good"|
+Generated Location: (1150:32,14 [6] )
+|"good"|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs
new file mode 100644
index 0000000000..80e09bdef9
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs
@@ -0,0 +1,33 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+using System;
+
+#line default
+#line hidden
+#nullable disable
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 219
+ private void __RazorDirectiveTokenHelpers__() {
+ }
+ #pragma warning restore 219
+ #pragma warning disable 0414
+ private static System.Object __o = null;
+ #pragma warning restore 0414
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.ir.txt
new file mode 100644
index 0000000000..f8c813d706
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.ir.txt
@@ -0,0 +1,21 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [17] ) - System.Linq
+ UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
+ UsingDirective - (1:0,1 [12] x:\dir\subdir\Test\TestComponent.cshtml) - System
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ DesignTimeDirective -
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning disable 0414
+ CSharpCode -
+ IntermediateToken - - CSharp - private static System.Object __o = null;
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning restore 0414
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ HtmlContent - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
+ MarkupElement - (17:2,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1
+ HtmlContent - (21:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (21:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.mappings.txt
new file mode 100644
index 0000000000..22790fa130
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.mappings.txt
@@ -0,0 +1,5 @@
+Source Location: (1:0,1 [12] x:\dir\subdir\Test\TestComponent.cshtml)
+|using System|
+Generated Location: (301:11,0 [12] )
+|using System|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs
new file mode 100644
index 0000000000..a0284c7ec0
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs
@@ -0,0 +1,34 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 219
+ private void __RazorDirectiveTokenHelpers__() {
+ }
+ #pragma warning restore 219
+ #pragma warning disable 0414
+ private static System.Object __o = null;
+ #pragma warning restore 0414
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+#nullable restore
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+__o = "My value";
+
+#line default
+#line hidden
+#nullable disable
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt
new file mode 100644
index 0000000000..02c4136873
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt
@@ -0,0 +1,25 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [12] ) - System
+ UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [17] ) - System.Linq
+ UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ DesignTimeDirective -
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning disable 0414
+ CSharpCode -
+ IntermediateToken - - CSharp - private static System.Object __o = null;
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning restore 0414
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ MarkupElement - (0:0,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1
+ HtmlContent - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
+ HtmlContent - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
+ CSharpExpression - (20:2,2 [10] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (20:2,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "My value"
+ HtmlContent - (31:2,13 [4] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (31:2,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.mappings.txt
new file mode 100644
index 0000000000..fd50a6b5eb
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.mappings.txt
@@ -0,0 +1,5 @@
+Source Location: (20:2,2 [10] x:\dir\subdir\Test\TestComponent.cshtml)
+|"My value"|
+Generated Location: (858:24,6 [10] )
+|"My value"|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs
new file mode 100644
index 0000000000..49d1e8750a
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs
@@ -0,0 +1,37 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 219
+ private void __RazorDirectiveTokenHelpers__() {
+ }
+ #pragma warning restore 219
+ #pragma warning disable 0414
+ private static System.Object __o = null;
+ #pragma warning restore 0414
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ __builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => {
+ }
+ ));
+#nullable restore
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+__o = typeof(SomeOtherComponent);
+
+#line default
+#line hidden
+#nullable disable
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithComponent/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithComponent/TestComponent.ir.txt
new file mode 100644
index 0000000000..8b10bd47fc
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithComponent/TestComponent.ir.txt
@@ -0,0 +1,24 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [12] ) - System
+ UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [17] ) - System.Linq
+ UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ DesignTimeDirective -
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning disable 0414
+ CSharpCode -
+ IntermediateToken - - CSharp - private static System.Object __o = null;
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning restore 0414
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ MarkupElement - (0:0,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1
+ HtmlContent - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
+ HtmlContent - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
+ Component - (18:2,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent
+ HtmlContent - (40:2,22 [4] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (40:2,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs
new file mode 100644
index 0000000000..8c93eba3be
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs
@@ -0,0 +1,38 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ [Microsoft.AspNetCore.Components.RouteAttribute("/my/url")]
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 219
+ private void __RazorDirectiveTokenHelpers__() {
+ ((System.Action)(() => {
+#nullable restore
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+global::System.Object __typeHelper = "/my/url";
+
+#line default
+#line hidden
+#nullable disable
+ }
+ ))();
+ }
+ #pragma warning restore 219
+ #pragma warning disable 0414
+ private static System.Object __o = null;
+ #pragma warning restore 0414
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.ir.txt
new file mode 100644
index 0000000000..8ce85ab1b8
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.ir.txt
@@ -0,0 +1,25 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [12] ) - System
+ UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [17] ) - System.Linq
+ UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
+ RouteAttributeExtensionNode - - /my/url
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ DesignTimeDirective -
+ DirectiveToken - (24:2,6 [9] x:\dir\subdir\Test\TestComponent.cshtml) - "/my/url"
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning disable 0414
+ CSharpCode -
+ IntermediateToken - - CSharp - private static System.Object __o = null;
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning restore 0414
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ MarkupElement - (0:0,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1
+ HtmlContent - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
+ HtmlContent - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
+ HtmlContent - (35:3,0 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (35:3,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.mappings.txt
new file mode 100644
index 0000000000..583d309981
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.mappings.txt
@@ -0,0 +1,5 @@
+Source Location: (24:2,6 [9] x:\dir\subdir\Test\TestComponent.cshtml)
+|"/my/url"|
+Generated Location: (645:18,37 [9] )
+|"/my/url"|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.codegen.cs
new file mode 100644
index 0000000000..f1c70de444
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.codegen.cs
@@ -0,0 +1,76 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+using Microsoft.AspNetCore.Components.Rendering;
+
+#line default
+#line hidden
+#nullable disable
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 219
+ private void __RazorDirectiveTokenHelpers__() {
+ }
+ #pragma warning restore 219
+ #pragma warning disable 0414
+ private static System.Object __o = null;
+ #pragma warning restore 0414
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ }
+ #pragma warning restore 1998
+#nullable restore
+#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ void MyMethod(RenderTreeBuilder __builder)
+ {
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 6 "x:\dir\subdir\Test\TestComponent.cshtml"
+ for (var i = 0; i < 100; i++)
+ {
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 9 "x:\dir\subdir\Test\TestComponent.cshtml"
+ __o = i;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 10 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ }
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 12 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ }
+
+#line default
+#line hidden
+#nullable disable
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.ir.txt
new file mode 100644
index 0000000000..20ec455410
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.ir.txt
@@ -0,0 +1,41 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [12] ) - System
+ UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [17] ) - System.Linq
+ UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
+ UsingDirective - (1:0,1 [47] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components.Rendering
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ DesignTimeDirective -
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning disable 0414
+ CSharpCode -
+ IntermediateToken - - CSharp - private static System.Object __o = null;
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning restore 0414
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ HtmlContent - (48:0,48 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (48:0,48 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ HtmlContent - (294:13,1 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (294:13,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (57:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (57:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void MyMethod(RenderTreeBuilder __builder)\n {\n
+ MarkupElement - (122:4,8 [162] x:\dir\subdir\Test\TestComponent.cshtml) - ul
+ HtmlContent - (126:4,12 [14] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (126:4,12 [14] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (141:5,13 [62] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (141:5,13 [62] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - for (var i = 0; i < 100; i++)\n {\n
+ MarkupElement - (203:7,16 [51] x:\dir\subdir\Test\TestComponent.cshtml) - li
+ HtmlContent - (207:7,20 [22] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (207:7,20 [22] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpExpression - (230:8,21 [1] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (230:8,21 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - i
+ HtmlContent - (231:8,22 [18] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (231:8,22 [18] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (254:9,21 [15] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (254:9,21 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n }
+ HtmlContent - (269:10,13 [10] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (269:10,13 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (284:11,13 [9] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (284:11,13 [9] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n }\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.mappings.txt
new file mode 100644
index 0000000000..28c9068715
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.mappings.txt
@@ -0,0 +1,46 @@
+Source Location: (1:0,1 [47] x:\dir\subdir\Test\TestComponent.cshtml)
+|using Microsoft.AspNetCore.Components.Rendering|
+Generated Location: (320:12,0 [47] )
+|using Microsoft.AspNetCore.Components.Rendering|
+
+Source Location: (57:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ void MyMethod(RenderTreeBuilder __builder)
+ {
+ |
+Generated Location: (1078:33,7 [65] )
+|
+ void MyMethod(RenderTreeBuilder __builder)
+ {
+ |
+
+Source Location: (141:5,13 [62] x:\dir\subdir\Test\TestComponent.cshtml)
+|for (var i = 0; i < 100; i++)
+ {
+ |
+Generated Location: (1278:43,13 [62] )
+|for (var i = 0; i < 100; i++)
+ {
+ |
+
+Source Location: (230:8,21 [1] x:\dir\subdir\Test\TestComponent.cshtml)
+|i|
+Generated Location: (1483:52,21 [1] )
+|i|
+
+Source Location: (254:9,21 [15] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ }|
+Generated Location: (1629:59,21 [15] )
+|
+ }|
+
+Source Location: (284:11,13 [9] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ }
+|
+Generated Location: (1780:67,13 [9] )
+|
+ }
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InsideAttribute_InMarkupBlock/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InsideAttribute_InMarkupBlock/TestComponent.codegen.cs
new file mode 100644
index 0000000000..6c09e3f0cf
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InsideAttribute_InMarkupBlock/TestComponent.codegen.cs
@@ -0,0 +1,27 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 219
+ private void __RazorDirectiveTokenHelpers__() {
+ }
+ #pragma warning restore 219
+ #pragma warning disable 0414
+ private static System.Object __o = null;
+ #pragma warning restore 0414
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InsideAttribute_InMarkupBlock/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InsideAttribute_InMarkupBlock/TestComponent.ir.txt
new file mode 100644
index 0000000000..63d0aa8093
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InsideAttribute_InMarkupBlock/TestComponent.ir.txt
@@ -0,0 +1,24 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [12] ) - System
+ UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [17] ) - System.Linq
+ UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ DesignTimeDirective -
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning disable 0414
+ CSharpCode -
+ IntermediateToken - - CSharp - private static System.Object __o = null;
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning restore 0414
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ MarkupElement - (0:0,0 [37] x:\dir\subdir\Test\TestComponent.cshtml) - div
+ HtmlAttribute - (4:0,4 [21] x:\dir\subdir\Test\TestComponent.cshtml) - class=" - "
+ HtmlAttributeValue - (12:0,12 [5] x:\dir\subdir\Test\TestComponent.cshtml) -
+ LazyIntermediateToken - (12:0,12 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - first
+ HtmlAttributeValue - (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) -
+ LazyIntermediateToken - (18:0,18 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - second
+ HtmlContent - (26:0,26 [5] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (26:0,26 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.codegen.cs
new file mode 100644
index 0000000000..710c047fb0
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.codegen.cs
@@ -0,0 +1,45 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 219
+ private void __RazorDirectiveTokenHelpers__() {
+ }
+ #pragma warning restore 219
+ #pragma warning disable 0414
+ private static System.Object __o = null;
+ #pragma warning restore 0414
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ __o =
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+ Foo
+
+#line default
+#line hidden
+#nullable disable
+ ;
+ }
+ #pragma warning restore 1998
+#nullable restore
+#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ int Foo = 18;
+
+
+#line default
+#line hidden
+#nullable disable
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.ir.txt
new file mode 100644
index 0000000000..896b52c665
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.ir.txt
@@ -0,0 +1,26 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [12] ) - System
+ UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [17] ) - System.Linq
+ UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ DesignTimeDirective -
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning disable 0414
+ CSharpCode -
+ IntermediateToken - - CSharp - private static System.Object __o = null;
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning restore 0414
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ MarkupElement - (0:0,0 [18] x:\dir\subdir\Test\TestComponent.cshtml) - elem
+ HtmlAttribute - (5:0,5 [10] x:\dir\subdir\Test\TestComponent.cshtml) - attr= -
+ CSharpExpressionAttributeValue - (11:0,11 [4] x:\dir\subdir\Test\TestComponent.cshtml) -
+ LazyIntermediateToken - (12:0,12 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo
+ HtmlContent - (18:0,18 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (18:0,18 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ HtmlContent - (61:3,5 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (61:3,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (31:1,11 [29] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (31:1,11 [29] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n int Foo = 18;\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.mappings.txt
new file mode 100644
index 0000000000..05e9ef8676
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.mappings.txt
@@ -0,0 +1,14 @@
+Source Location: (12:0,12 [3] x:\dir\subdir\Test\TestComponent.cshtml)
+|Foo|
+Generated Location: (884:25,12 [3] )
+|Foo|
+
+Source Location: (31:1,11 [29] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ int Foo = 18;
+ |
+Generated Location: (1084:35,11 [29] )
+|
+ int Foo = 18;
+ |
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs
new file mode 100644
index 0000000000..121ad727ab
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs
@@ -0,0 +1,31 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ __builder.AddContent(0,
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+ "My value"
+
+#line default
+#line hidden
+#nullable disable
+ );
+ __builder.AddMarkupContent(1, "\r\n\r\n");
+ __builder.AddMarkupContent(2, "Hello
");
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt
new file mode 100644
index 0000000000..798b59c005
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt
@@ -0,0 +1,14 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [14] ) - System
+ UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [19] ) - System.Linq
+ UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ CSharpExpression - (2:0,2 [10] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (2:0,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "My value"
+ HtmlContent - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
+ MarkupBlock - - Hello
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs
new file mode 100644
index 0000000000..b19d4dc73c
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs
@@ -0,0 +1,54 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ __builder.OpenComponent(0);
+ __builder.AddAttribute(1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => {
+ __builder2.AddMarkupContent(2, "\r\n ");
+ __builder2.OpenElement(3, "h1");
+ __builder2.AddContent(4, "Child content at ");
+ __builder2.AddContent(5,
+#nullable restore
+#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
+ DateTime.Now
+
+#line default
+#line hidden
+#nullable disable
+ );
+ __builder2.CloseElement();
+ __builder2.AddMarkupContent(6, "\r\n ");
+ __builder2.OpenElement(7, "p");
+ __builder2.AddContent(8, "Very ");
+ __builder2.AddContent(9,
+#nullable restore
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+ "good"
+
+#line default
+#line hidden
+#nullable disable
+ );
+ __builder2.CloseElement();
+ __builder2.AddMarkupContent(10, "\r\n");
+ }
+ ));
+ __builder.CloseComponent();
+ __builder.AddMarkupContent(11, "\r\n\r\n");
+ __builder.AddMarkupContent(12, "Hello
");
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.ir.txt
new file mode 100644
index 0000000000..c2bb53da85
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithComponent/TestComponent.ir.txt
@@ -0,0 +1,30 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [14] ) - System
+ UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [19] ) - System.Linq
+ UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ Component - (0:0,0 [115] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent
+ ComponentChildContent - - ChildContent - context
+ HtmlContent - (20:0,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (20:0,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ MarkupElement - (26:1,4 [39] x:\dir\subdir\Test\TestComponent.cshtml) - h1
+ HtmlContent - (30:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (30:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Child content at
+ CSharpExpression - (48:1,26 [12] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (48:1,26 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - DateTime.Now
+ HtmlContent - (65:1,43 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (65:1,43 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ MarkupElement - (71:2,4 [21] x:\dir\subdir\Test\TestComponent.cshtml) - p
+ HtmlContent - (74:2,7 [5] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (74:2,7 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Very
+ CSharpExpression - (81:2,14 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (81:2,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "good"
+ HtmlContent - (92:2,25 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (92:2,25 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ HtmlContent - (115:3,21 [4] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (115:3,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
+ MarkupBlock - - Hello
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs
new file mode 100644
index 0000000000..3c19ffe010
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs
@@ -0,0 +1,27 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+using System;
+
+#line default
+#line hidden
+#nullable disable
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ __builder.AddMarkupContent(0, "Hello
");
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.ir.txt
new file mode 100644
index 0000000000..652c51b282
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_LeadingWhiteSpace_WithDirective/TestComponent.ir.txt
@@ -0,0 +1,10 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [19] ) - System.Linq
+ UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
+ UsingDirective - (1:0,1 [14] x:\dir\subdir\Test\TestComponent.cshtml) - System
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ MarkupBlock - - Hello
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs
new file mode 100644
index 0000000000..f5ef41e3b8
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs
@@ -0,0 +1,30 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ __builder.AddMarkupContent(0, "Hello
\r\n\r\n");
+ __builder.AddContent(1,
+#nullable restore
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+ "My value"
+
+#line default
+#line hidden
+#nullable disable
+ );
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt
new file mode 100644
index 0000000000..1075211103
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt
@@ -0,0 +1,12 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [14] ) - System
+ UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [19] ) - System.Linq
+ UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ MarkupBlock - - Hello
\n\n
+ CSharpExpression - (20:2,2 [10] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (20:2,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "My value"
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs
new file mode 100644
index 0000000000..d1804d339d
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs
@@ -0,0 +1,23 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ __builder.AddMarkupContent(0, "Hello
\r\n\r\n");
+ __builder.OpenComponent(1);
+ __builder.CloseComponent();
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithComponent/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithComponent/TestComponent.ir.txt
new file mode 100644
index 0000000000..5705f5828c
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithComponent/TestComponent.ir.txt
@@ -0,0 +1,11 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [14] ) - System
+ UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [19] ) - System.Linq
+ UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ MarkupBlock - - Hello
\n\n
+ Component - (18:2,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs
new file mode 100644
index 0000000000..d319c30c28
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs
@@ -0,0 +1,22 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ [Microsoft.AspNetCore.Components.RouteAttribute("/my/url")]
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ __builder.AddMarkupContent(0, "Hello
");
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.ir.txt
new file mode 100644
index 0000000000..5be8a555b9
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_TrailingWhiteSpace_WithDirective/TestComponent.ir.txt
@@ -0,0 +1,11 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [14] ) - System
+ UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [19] ) - System.Linq
+ UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
+ RouteAttributeExtensionNode - - /my/url
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ MarkupBlock - - Hello
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.codegen.cs
new file mode 100644
index 0000000000..a6d59b4752
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.codegen.cs
@@ -0,0 +1,79 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+using Microsoft.AspNetCore.Components.Rendering;
+
+#line default
+#line hidden
+#nullable disable
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ }
+ #pragma warning restore 1998
+#nullable restore
+#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ void MyMethod(RenderTreeBuilder __builder)
+ {
+
+#line default
+#line hidden
+#nullable disable
+ __builder.AddContent(0, " ");
+ __builder.OpenElement(1, "ul");
+ __builder.AddMarkupContent(2, "\r\n");
+#nullable restore
+#line 6 "x:\dir\subdir\Test\TestComponent.cshtml"
+ for (var i = 0; i < 100; i++)
+ {
+
+#line default
+#line hidden
+#nullable disable
+ __builder.AddContent(3, " ");
+ __builder.OpenElement(4, "li");
+ __builder.AddMarkupContent(5, "\r\n ");
+ __builder.AddContent(6,
+#nullable restore
+#line 9 "x:\dir\subdir\Test\TestComponent.cshtml"
+ i
+
+#line default
+#line hidden
+#nullable disable
+ );
+ __builder.AddMarkupContent(7, "\r\n ");
+ __builder.CloseElement();
+ __builder.AddMarkupContent(8, "\r\n");
+#nullable restore
+#line 11 "x:\dir\subdir\Test\TestComponent.cshtml"
+ }
+
+#line default
+#line hidden
+#nullable disable
+ __builder.AddContent(9, " ");
+ __builder.CloseElement();
+ __builder.AddMarkupContent(10, "\r\n");
+#nullable restore
+#line 13 "x:\dir\subdir\Test\TestComponent.cshtml"
+ }
+
+#line default
+#line hidden
+#nullable disable
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.ir.txt
new file mode 100644
index 0000000000..a7b11b1cf9
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.ir.txt
@@ -0,0 +1,41 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [14] ) - System
+ UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [19] ) - System.Linq
+ UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
+ UsingDirective - (1:0,1 [49] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components.Rendering
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ CSharpCode - (57:1,7 [57] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (57:1,7 [57] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void MyMethod(RenderTreeBuilder __builder)\n {\n
+ HtmlContent - (114:4,0 [8] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (114:4,0 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html -
+ MarkupElement - (122:4,8 [162] x:\dir\subdir\Test\TestComponent.cshtml) - ul
+ HtmlContent - (126:4,12 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (126:4,12 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (128:5,0 [12] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (128:5,0 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp -
+ CSharpCode - (141:5,13 [46] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (141:5,13 [46] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - for (var i = 0; i < 100; i++)\n {\n
+ HtmlContent - (187:7,0 [16] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (187:7,0 [16] x:\dir\subdir\Test\TestComponent.cshtml) - Html -
+ MarkupElement - (203:7,16 [51] x:\dir\subdir\Test\TestComponent.cshtml) - li
+ HtmlContent - (207:7,20 [22] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (207:7,20 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ LazyIntermediateToken - (209:8,0 [20] x:\dir\subdir\Test\TestComponent.cshtml) - Html -
+ CSharpExpression - (230:8,21 [1] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (230:8,21 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - i
+ HtmlContent - (231:8,22 [18] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (231:8,22 [18] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ HtmlContent - (254:9,21 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (254:9,21 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (256:10,0 [15] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (256:10,0 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - }\n
+ HtmlContent - (271:11,0 [8] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (271:11,0 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html -
+ HtmlContent - (284:11,13 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (284:11,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (286:12,0 [7] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (286:12,0 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - }\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.mappings.txt
new file mode 100644
index 0000000000..2910248103
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InMarkupInFunctionsBlock/TestComponent.mappings.txt
@@ -0,0 +1,34 @@
+Source Location: (57:1,7 [57] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ void MyMethod(RenderTreeBuilder __builder)
+ {
+|
+Generated Location: (810:26,7 [57] )
+|
+ void MyMethod(RenderTreeBuilder __builder)
+ {
+|
+
+Source Location: (141:5,13 [46] x:\dir\subdir\Test\TestComponent.cshtml)
+|for (var i = 0; i < 100; i++)
+ {
+|
+Generated Location: (1135:38,13 [46] )
+|for (var i = 0; i < 100; i++)
+ {
+|
+
+Source Location: (256:10,0 [15] x:\dir\subdir\Test\TestComponent.cshtml)
+| }
+|
+Generated Location: (1802:61,0 [15] )
+| }
+|
+
+Source Location: (286:12,0 [7] x:\dir\subdir\Test\TestComponent.cshtml)
+| }
+|
+Generated Location: (2068:71,0 [7] )
+| }
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InsideAttribute_InMarkupBlock/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InsideAttribute_InMarkupBlock/TestComponent.codegen.cs
new file mode 100644
index 0000000000..56f8b8e45d
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InsideAttribute_InMarkupBlock/TestComponent.codegen.cs
@@ -0,0 +1,21 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ __builder.AddMarkupContent(0, "Hello
");
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InsideAttribute_InMarkupBlock/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InsideAttribute_InMarkupBlock/TestComponent.ir.txt
new file mode 100644
index 0000000000..4924d8da0d
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_WhiteSpace_InsideAttribute_InMarkupBlock/TestComponent.ir.txt
@@ -0,0 +1,10 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [14] ) - System
+ UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [19] ) - System.Linq
+ UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ MarkupBlock - - Hello
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.codegen.cs
new file mode 100644
index 0000000000..6ccca11c24
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.codegen.cs
@@ -0,0 +1,40 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
+ {
+ __builder.OpenElement(0, "elem");
+ __builder.AddAttribute(1, "attr",
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+ Foo
+
+#line default
+#line hidden
+#nullable disable
+ );
+ __builder.CloseElement();
+ }
+ #pragma warning restore 1998
+#nullable restore
+#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ int Foo = 18;
+
+
+#line default
+#line hidden
+#nullable disable
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.ir.txt
new file mode 100644
index 0000000000..f055dca7c3
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.ir.txt
@@ -0,0 +1,15 @@
+Document -
+ NamespaceDeclaration - - Test
+ UsingDirective - (3:1,1 [14] ) - System
+ UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
+ UsingDirective - (53:3,1 [19] ) - System.Linq
+ UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
+ UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ MarkupElement - (0:0,0 [18] x:\dir\subdir\Test\TestComponent.cshtml) - elem
+ HtmlAttribute - (5:0,5 [10] x:\dir\subdir\Test\TestComponent.cshtml) - attr= -
+ CSharpExpressionAttributeValue - (11:0,11 [4] x:\dir\subdir\Test\TestComponent.cshtml) -
+ LazyIntermediateToken - (12:0,12 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo
+ CSharpCode - (31:1,11 [29] x:\dir\subdir\Test\TestComponent.cshtml)
+ LazyIntermediateToken - (31:1,11 [29] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n int Foo = 18;\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.mappings.txt
new file mode 100644
index 0000000000..833739d291
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Legacy_3_1_Whitespace_BetweenElementAndFunctions/TestComponent.mappings.txt
@@ -0,0 +1,9 @@
+Source Location: (31:1,11 [29] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ int Foo = 18;
+ |
+Generated Location: (931:30,11 [29] )
+|
+ int Foo = 18;
+ |
+