"<text>" and "</text>" tags cannot contain attributes.
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs
index 578a52740f..924079b1d9 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs
@@ -16,6 +16,12 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
}
#region Runtime
+ [Fact]
+ public void SingleLineControlFlowStatements_Runtime()
+ {
+ RunTimeTest();
+ }
+
[Fact]
public void CSharp8_Runtime()
{
@@ -485,6 +491,12 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
#endregion
#region DesignTime
+ [Fact]
+ public void SingleLineControlFlowStatements_DesignTime()
+ {
+ DesignTimeTest();
+ }
+
[Fact]
public void CSharp8_DesignTime()
{
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 36aeb62624..ba2740b7ae 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
@@ -19,6 +19,52 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
#region Basics
+ [Fact]
+ public void SingleLineControlFlowStatements_InCodeDirective()
+ {
+ // Arrange
+
+ // Act
+ var generated = CompileToCSharp(@"
+@using Microsoft.AspNetCore.Components.RenderTree;
+
+@code {
+ void RenderChildComponent(RenderTreeBuilder builder)
+ {
+ var output = string.Empty;
+ if (builder == null) output = ""Builder is null!"";
+ else output = ""Builder is not null!"";
+ Output: @output
+ }
+}");
+
+ // Assert
+ AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
+ AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
+ CompileToAssembly(generated);
+ }
+
+ [Fact]
+ public void SingleLineControlFlowStatements_InCodeBlock()
+ {
+ // Arrange
+
+ // Act
+ var generated = CompileToCSharp(@"
+@using Microsoft.AspNetCore.Components.RenderTree;
+
+@{
+ var output = string.Empty;
+ if (builder == null) output = ""Builder is null!"";
+ else output = ""Builder is not null!"";
+ Output: @output
+}");
+
+ // Assert
+ AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
+ AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
+ CompileToAssembly(generated);
+ }
[Fact]
public void ChildComponent_InFunctionsDirective()
{
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs
index 7c66f7e2d6..b6efbe507a 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs
@@ -8,6 +8,35 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{
public class CSharpBlockTest : ParserTestBase
{
+ [Fact]
+ public void CSharpBlock_SingleLineControlFlowStatement_Error()
+ {
+ ParseDocumentTest(
+@"@{
+ var time = DateTime.Now;
+ if (time.ToBinary() % 2 == 0) The time: @time
+
+ if (time.ToBinary() %3 == 0)
+ // For some reason we want to render the time now?
+ The confusing time: @time
+
+ if (time.ToBinary() % 4 == 0)
+ @: The time: @time
+
+ if (time.ToBinary() % 5 == 0) @@SomeGitHubUserName Hi!
+}");
+ }
+
+ [Fact]
+ public void CSharpBlock_SingleLineControlFlowStatement()
+ {
+ ParseDocumentTest(
+@"@{
+ var time = DateTime.Now;
+ if (time.ToBinary() % 2 == 0) @time
+}");
+ }
+
[Fact]
public void LocalFunctionsWithRazor()
{
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpFunctionsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpFunctionsTest.cs
index 34e9918f7d..f50d91b295 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpFunctionsTest.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpFunctionsTest.cs
@@ -8,6 +8,45 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{
public class CSharpFunctionsTest : ParserTestBase
{
+ [Fact]
+ public void Functions_SingleLineControlFlowStatement_Error()
+ {
+ ParseDocumentTest(
+ RazorLanguageVersion.Version_3_0,
+ @"
+@functions {
+ string GetAnnouncmentText(string message)
+ {
+ if (message.Length > 0) Message: @message
+
+ if (message == null)
+ // Nothing to render
+ Message was null
+
+ if (DateTime.Now.ToBinary() % 2 == 0)
+ @: The time: @time
+
+ if (message != null) @@SomeGitHubUserName @message
+ }
+}
+", new[] { FunctionsDirective.Directive, }, designTime: false);
+ }
+
+ [Fact]
+ public void Functions_SingleLineControlFlowStatement()
+ {
+ ParseDocumentTest(
+ RazorLanguageVersion.Version_3_0,
+ @"
+@functions {
+ string GetAnnouncmentText(string message)
+ {
+ if (message.Length > 0) return ""Anouncement: "" + message;
+ }
+}
+", new[] { FunctionsDirective.Directive, }, designTime: false);
+ }
+
[Fact]
public void MarkupInFunctionsBlock_DoesNotParseWhenNotSupported()
{
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml
new file mode 100644
index 0000000000..9d6ae22f9d
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml
@@ -0,0 +1,102 @@
+Before Text
+
+@{
+ if (DateTime.Now.ToBinary() % 2 == 0) @("Current time is divisible by 2") else @DateTime.Now
+
+ object Bar()
+ {
+ if (DateTime.Now.ToBinary() % 2 == 0)
+ return "Current time is divisible by 2";
+ else if (DateTime.Now.ToBinary() % 3 == 0)
+ return "Current time is divisible by 3";
+ else
+ return DateTime.Now;
+ }
+
+ for (var i = 0; i < 10; i++)
+ // Incrementing a number
+ i--;
+
+ @foreach (var item in new[] {"hello"})
+ @item
+
+ do
+ @currentCount
+ while (--currentCount >= 0);
+
+ while (--currentCount <= 10)
+ currentCount++;
+
+ using (var reader = new System.IO.StreamReader("/something"))
+ @reader.ReadToEnd()
+
+ @lock (this)
+ currentCount++;
+}
+
+@functions {
+ public string Foo()
+ {
+ var x = "";
+
+ if (DateTime.Now.ToBinary() % 2 == 0)
+ return "Current time is divisible by 2";
+ else
+ return "It isn't divisible by two";
+
+ for (var i = 0; i < 10; i++)
+ // Incrementing a number
+ i--;
+
+ foreach (var item in new[] {"hello"})
+ @item
+
+ do
+ @currentCount
+ while (--currentCount >= 0);
+
+ while (--currentCount <= 10)
+ currentCount++;
+
+ using (var reader = new System.IO.StreamReader("/something"))
+ @reader.ReadToEnd()
+
+ lock (this)
+ currentCount++;
+ }
+
+ int currentCount = 0;
+
+ public void IncrementCount()
+ {
+ if (true) currentCount++;
+ }
+
+}
+
+@for (var i = 0; i < 10; i++)
+ @i
+
+@foreach (var item in new[] {"hello"})
+ @item
+
+@do
+ @currentCount
+while (--currentCount >= 0);
+
+@while (--currentCount <= 10)
+ currentCount++;
+
+@using (var reader = new System.IO.StreamReader("/something"))
+ // Reading the entire file
+ @reader.ReadToEnd()
+
+@lock (this)
+ currentCount++;
+
+@if (true) @@GitHubUserName Hello!
+
+@if (true)
+ @: The time is @DateTime.Now
+
+After Text
\ No newline at end of file
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.codegen.cs
new file mode 100644
index 0000000000..3ecf283882
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.codegen.cs
@@ -0,0 +1,385 @@
+//
+#pragma warning disable 1591
+namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
+{
+ #line hidden
+ public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleLineControlFlowStatements_DesignTime
+ {
+ #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
+ public async System.Threading.Tasks.Task ExecuteAsync()
+ {
+#nullable restore
+#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+ if (DateTime.Now.ToBinary() % 2 == 0)
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ __o = "Current time is divisible by 2";
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ else
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ __o = DateTime.Now;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+ object Bar()
+ {
+ if (DateTime.Now.ToBinary() % 2 == 0)
+ return "Current time is divisible by 2";
+ else if (DateTime.Now.ToBinary() % 3 == 0)
+ return "Current time is divisible by 3";
+ else
+ return DateTime.Now;
+ }
+
+ for (var i = 0; i < 10; i++)
+ // Incrementing a number
+ i--;
+
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 20 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ foreach (var item in new[] {"hello"})
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ __o = item;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+ do
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ __o = currentCount;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+ while (--currentCount >= 0);
+
+ while (--currentCount <= 10)
+ currentCount++;
+
+ using (var reader = new System.IO.StreamReader("/something"))
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 31 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ __o = reader.ReadToEnd();
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 31 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ lock (this)
+ currentCount++;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 34 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 77 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ for (var i = 0; i < 10; i++)
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 78 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+__o = i;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 78 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 80 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ foreach (var item in new[] {"hello"})
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 81 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+__o = item;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 81 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 83 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ do
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 84 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+__o = currentCount;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 84 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+while (--currentCount >= 0);
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 87 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ while (--currentCount <= 10)
+ currentCount++;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 90 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ using (var reader = new System.IO.StreamReader("/something"))
+ // Reading the entire file
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 92 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+__o = reader.ReadToEnd();
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 92 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 94 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ lock (this)
+ currentCount++;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 97 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ if (true)
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 97 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ @GitHubUserName
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 99 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ if (true)
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 100 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ __o = DateTime.Now;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 101 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+#line default
+#line hidden
+#nullable disable
+ }
+ #pragma warning restore 1998
+#nullable restore
+#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+ public string Foo()
+ {
+ var x = "";
+
+ if (DateTime.Now.ToBinary() % 2 == 0)
+ return "Current time is divisible by 2";
+ else
+ return "It isn't divisible by two";
+
+ for (var i = 0; i < 10; i++)
+ // Incrementing a number
+ i--;
+
+ foreach (var item in new[] {"hello"})
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 52 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ __o = item;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 52 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+ do
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 55 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ __o = currentCount;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 55 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+ while (--currentCount >= 0);
+
+ while (--currentCount <= 10)
+ currentCount++;
+
+ using (var reader = new System.IO.StreamReader("/something"))
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 62 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ __o = reader.ReadToEnd();
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 62 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+ lock (this)
+ currentCount++;
+ }
+
+ int currentCount = 0;
+
+ public void IncrementCount()
+ {
+ if (true) currentCount++;
+ }
+
+
+#line default
+#line hidden
+#nullable disable
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.diagnostics.txt
new file mode 100644
index 0000000000..1078a21cf6
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.diagnostics.txt
@@ -0,0 +1,2 @@
+TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml(97,12): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
+TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml(100,5): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.ir.txt
new file mode 100644
index 0000000000..b277c3528a
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.ir.txt
@@ -0,0 +1,131 @@
+Document -
+ NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
+ ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleLineControlFlowStatements_DesignTime - -
+ 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 - - public async - System.Threading.Tasks.Task - ExecuteAsync
+ HtmlContent - (0:0,0 [22] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (0:0,0 [2] SingleLineControlFlowStatements.cshtml) - Html -
+ IntermediateToken - (3:0,3 [11] SingleLineControlFlowStatements.cshtml) - Html - Before Text
+ IntermediateToken - (14:0,14 [4] SingleLineControlFlowStatements.cshtml) - Html -
+ IntermediateToken - (18:0,18 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n
+ CSharpCode - (24:2,2 [44] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (24:2,2 [44] SingleLineControlFlowStatements.cshtml) - CSharp - \n if (DateTime.Now.ToBinary() % 2 == 0)
+ CSharpExpression - (70:3,44 [32] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (70:3,44 [32] SingleLineControlFlowStatements.cshtml) - CSharp - "Current time is divisible by 2"
+ CSharpCode - (103:3,77 [6] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (103:3,77 [6] SingleLineControlFlowStatements.cshtml) - CSharp - else
+ CSharpExpression - (110:3,84 [12] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (110:3,84 [12] SingleLineControlFlowStatements.cshtml) - CSharp - DateTime.Now
+ CSharpCode - (122:3,96 [381] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (122:3,96 [381] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n object Bar()\n {\n if (DateTime.Now.ToBinary() % 2 == 0)\n return "Current time is divisible by 2";\n else if (DateTime.Now.ToBinary() % 3 == 0)\n return "Current time is divisible by 3";\n else\n return DateTime.Now;\n }\n\n for (var i = 0; i < 10; i++)\n // Incrementing a number\n i--;\n\n
+ CSharpCode - (504:19,5 [47] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (504:19,5 [47] SingleLineControlFlowStatements.cshtml) - CSharp - foreach (var item in new[] {"hello"})\n
+ CSharpExpression - (552:20,9 [4] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (552:20,9 [4] SingleLineControlFlowStatements.cshtml) - CSharp - item
+ CSharpCode - (556:20,13 [0] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (556:20,13 [0] SingleLineControlFlowStatements.cshtml) - CSharp -
+ CSharpCode - (556:20,13 [20] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (556:20,13 [20] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n do\n
+ CSharpExpression - (577:23,9 [12] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (577:23,9 [12] SingleLineControlFlowStatements.cshtml) - CSharp - currentCount
+ CSharpCode - (589:23,21 [174] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (589:23,21 [174] SingleLineControlFlowStatements.cshtml) - CSharp - \n while (--currentCount >= 0);\n\n while (--currentCount <= 10)\n currentCount++;\n\n using (var reader = new System.IO.StreamReader("/something"))\n
+ CSharpExpression - (764:30,9 [18] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (764:30,9 [18] SingleLineControlFlowStatements.cshtml) - CSharp - reader.ReadToEnd()
+ CSharpCode - (782:30,27 [8] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (782:30,27 [8] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n
+ CSharpCode - (791:32,5 [36] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (791:32,5 [36] SingleLineControlFlowStatements.cshtml) - CSharp - lock (this)\n currentCount++;
+ CSharpCode - (827:33,23 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (827:33,23 [2] SingleLineControlFlowStatements.cshtml) - CSharp - \n
+ HtmlContent - (832:35,0 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (832:35,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n
+ HtmlContent - (1669:74,1 [4] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1669:74,1 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n
+ CSharpCode - (1674:76,1 [34] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1674:76,1 [34] SingleLineControlFlowStatements.cshtml) - CSharp - for (var i = 0; i < 10; i++)\n
+ CSharpExpression - (1709:77,5 [1] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1709:77,5 [1] SingleLineControlFlowStatements.cshtml) - CSharp - i
+ CSharpCode - (1710:77,6 [0] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1710:77,6 [0] SingleLineControlFlowStatements.cshtml) - CSharp -
+ HtmlContent - (1710:77,6 [4] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1710:77,6 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n
+ CSharpCode - (1715:79,1 [43] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1715:79,1 [43] SingleLineControlFlowStatements.cshtml) - CSharp - foreach (var item in new[] {"hello"})\n
+ CSharpExpression - (1759:80,5 [4] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1759:80,5 [4] SingleLineControlFlowStatements.cshtml) - CSharp - item
+ CSharpCode - (1763:80,9 [0] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1763:80,9 [0] SingleLineControlFlowStatements.cshtml) - CSharp -
+ HtmlContent - (1763:80,9 [4] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1763:80,9 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n
+ CSharpCode - (1768:82,1 [8] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1768:82,1 [8] SingleLineControlFlowStatements.cshtml) - CSharp - do\n
+ CSharpExpression - (1777:83,5 [12] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1777:83,5 [12] SingleLineControlFlowStatements.cshtml) - CSharp - currentCount
+ CSharpCode - (1789:83,17 [30] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1789:83,17 [30] SingleLineControlFlowStatements.cshtml) - CSharp - \nwhile (--currentCount >= 0);
+ HtmlContent - (1819:84,28 [4] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1819:84,28 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n
+ CSharpCode - (1824:86,1 [49] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1824:86,1 [49] SingleLineControlFlowStatements.cshtml) - CSharp - while (--currentCount <= 10)\n currentCount++;
+ HtmlContent - (1873:87,19 [4] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1873:87,19 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n
+ CSharpCode - (1878:89,1 [99] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1878:89,1 [99] SingleLineControlFlowStatements.cshtml) - CSharp - using (var reader = new System.IO.StreamReader("/something"))\n // Reading the entire file\n
+ CSharpExpression - (1978:91,5 [18] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1978:91,5 [18] SingleLineControlFlowStatements.cshtml) - CSharp - reader.ReadToEnd()
+ CSharpCode - (1996:91,23 [0] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1996:91,23 [0] SingleLineControlFlowStatements.cshtml) - CSharp -
+ HtmlContent - (1996:91,23 [4] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1996:91,23 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n
+ CSharpCode - (2001:93,1 [32] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2001:93,1 [32] SingleLineControlFlowStatements.cshtml) - CSharp - lock (this)\n currentCount++;
+ HtmlContent - (2033:94,19 [4] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2033:94,19 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n
+ CSharpCode - (2038:96,1 [10] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2038:96,1 [10] SingleLineControlFlowStatements.cshtml) - CSharp - if (true)
+ CSharpCode - (2049:96,12 [16] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2049:96,12 [16] SingleLineControlFlowStatements.cshtml) - CSharp - @GitHubUserName
+ HtmlContent - (2065:96,28 [17] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2065:96,28 [2] SingleLineControlFlowStatements.cshtml) - Html -
+ IntermediateToken - (2068:96,31 [6] SingleLineControlFlowStatements.cshtml) - Html - Hello!
+ IntermediateToken - (2074:96,37 [4] SingleLineControlFlowStatements.cshtml) - Html -
+ IntermediateToken - (2078:96,41 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n
+ CSharpCode - (2083:98,1 [16] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2083:98,1 [16] SingleLineControlFlowStatements.cshtml) - CSharp - if (true) \n
+ HtmlContent - (2101:99,6 [16] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2101:99,6 [16] SingleLineControlFlowStatements.cshtml) - Html - The time is
+ CSharpExpression - (2118:99,23 [12] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2118:99,23 [12] SingleLineControlFlowStatements.cshtml) - CSharp - DateTime.Now
+ HtmlContent - (2130:99,35 [6] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2130:99,35 [6] SingleLineControlFlowStatements.cshtml) - Html -
\n
+ CSharpCode - (2136:100,0 [0] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2136:100,0 [0] SingleLineControlFlowStatements.cshtml) - CSharp -
+ HtmlContent - (2136:100,0 [19] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2136:100,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n
+ IntermediateToken - (2138:101,0 [2] SingleLineControlFlowStatements.cshtml) - Html -
+ IntermediateToken - (2141:101,3 [10] SingleLineControlFlowStatements.cshtml) - Html - After Text
+ IntermediateToken - (2151:101,13 [4] SingleLineControlFlowStatements.cshtml) - Html -
+ CSharpCode - (846:36,12 [386] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (846:36,12 [386] SingleLineControlFlowStatements.cshtml) - CSharp - \n public string Foo()\n {\n var x = "";\n\n if (DateTime.Now.ToBinary() % 2 == 0)\n return "Current time is divisible by 2";\n else\n return "It isn't divisible by two";\n \n for (var i = 0; i < 10; i++)\n // Incrementing a number\n i--;\n\n foreach (var item in new[] {"hello"})\n
+ CSharpExpression - (1233:51,13 [4] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1233:51,13 [4] SingleLineControlFlowStatements.cshtml) - CSharp - item
+ CSharpCode - (1237:51,17 [28] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1237:51,17 [28] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n do\n
+ CSharpExpression - (1266:54,13 [12] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1266:54,13 [12] SingleLineControlFlowStatements.cshtml) - CSharp - currentCount
+ CSharpCode - (1278:54,25 [194] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1278:54,25 [194] SingleLineControlFlowStatements.cshtml) - CSharp - \n while (--currentCount >= 0);\n\n while (--currentCount <= 10)\n currentCount++;\n\n using (var reader = new System.IO.StreamReader("/something"))\n
+ CSharpExpression - (1473:61,13 [18] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1473:61,13 [18] SingleLineControlFlowStatements.cshtml) - CSharp - reader.ReadToEnd()
+ CSharpCode - (1491:61,31 [177] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1491:61,31 [177] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n lock (this)\n currentCount++;\n }\n\n int currentCount = 0;\n\n public void IncrementCount()\n {\n if (true) currentCount++;\n }\n\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.mappings.txt
new file mode 100644
index 0000000000..046e1006f8
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.mappings.txt
@@ -0,0 +1,363 @@
+Source Location: (24:2,2 [44] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|
+ if (DateTime.Now.ToBinary() % 2 == 0) |
+Generated Location: (782:19,2 [44] )
+|
+ if (DateTime.Now.ToBinary() % 2 == 0) |
+
+Source Location: (70:3,44 [32] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|"Current time is divisible by 2"|
+Generated Location: (1048:27,44 [32] )
+|"Current time is divisible by 2"|
+
+Source Location: (103:3,77 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+| else |
+Generated Location: (1336:34,77 [6] )
+| else |
+
+Source Location: (110:3,84 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|DateTime.Now|
+Generated Location: (1604:41,84 [12] )
+|DateTime.Now|
+
+Source Location: (122:3,96 [381] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|
+
+ object Bar()
+ {
+ if (DateTime.Now.ToBinary() % 2 == 0)
+ return "Current time is divisible by 2";
+ else if (DateTime.Now.ToBinary() % 3 == 0)
+ return "Current time is divisible by 3";
+ else
+ return DateTime.Now;
+ }
+
+ for (var i = 0; i < 10; i++)
+ // Incrementing a number
+ i--;
+
+ |
+Generated Location: (1891:48,96 [381] )
+|
+
+ object Bar()
+ {
+ if (DateTime.Now.ToBinary() % 2 == 0)
+ return "Current time is divisible by 2";
+ else if (DateTime.Now.ToBinary() % 3 == 0)
+ return "Current time is divisible by 3";
+ else
+ return DateTime.Now;
+ }
+
+ for (var i = 0; i < 10; i++)
+ // Incrementing a number
+ i--;
+
+ |
+
+Source Location: (504:19,5 [47] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|foreach (var item in new[] {"hello"})
+ |
+Generated Location: (2456:71,5 [47] )
+|foreach (var item in new[] {"hello"})
+ |
+
+Source Location: (552:20,9 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|item|
+Generated Location: (2691:79,9 [4] )
+|item|
+
+Source Location: (556:20,13 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+||
+Generated Location: (2888:86,13 [0] )
+||
+
+Source Location: (556:20,13 [20] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|
+
+ do
+ |
+Generated Location: (3080:93,13 [20] )
+|
+
+ do
+ |
+
+Source Location: (577:23,9 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|currentCount|
+Generated Location: (3288:103,9 [12] )
+|currentCount|
+
+Source Location: (589:23,21 [174] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|
+ while (--currentCount >= 0);
+
+ while (--currentCount <= 10)
+ currentCount++;
+
+ using (var reader = new System.IO.StreamReader("/something"))
+ |
+Generated Location: (3501:110,21 [174] )
+|
+ while (--currentCount >= 0);
+
+ while (--currentCount <= 10)
+ currentCount++;
+
+ using (var reader = new System.IO.StreamReader("/something"))
+ |
+
+Source Location: (764:30,9 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|reader.ReadToEnd()|
+Generated Location: (3863:124,9 [18] )
+|reader.ReadToEnd()|
+
+Source Location: (782:30,27 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|
+
+ |
+Generated Location: (4088:131,27 [8] )
+|
+
+ |
+
+Source Location: (791:32,5 [36] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|lock (this)
+ currentCount++;|
+Generated Location: (4280:140,5 [36] )
+|lock (this)
+ currentCount++;|
+
+Source Location: (827:33,23 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|
+|
+Generated Location: (4518:148,23 [2] )
+|
+|
+
+Source Location: (1674:76,1 [34] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|for (var i = 0; i < 10; i++)
+ |
+Generated Location: (4698:155,1 [34] )
+|for (var i = 0; i < 10; i++)
+ |
+
+Source Location: (1709:77,5 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|i|
+Generated Location: (4917:163,6 [1] )
+|i|
+
+Source Location: (1710:77,6 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+||
+Generated Location: (5104:170,6 [0] )
+||
+
+Source Location: (1715:79,1 [43] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|foreach (var item in new[] {"hello"})
+ |
+Generated Location: (5284:177,1 [43] )
+|foreach (var item in new[] {"hello"})
+ |
+
+Source Location: (1759:80,5 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|item|
+Generated Location: (5512:185,6 [4] )
+|item|
+
+Source Location: (1763:80,9 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+||
+Generated Location: (5705:192,9 [0] )
+||
+
+Source Location: (1768:82,1 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|do
+ |
+Generated Location: (5885:199,1 [8] )
+|do
+ |
+
+Source Location: (1777:83,5 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|currentCount|
+Generated Location: (6078:207,6 [12] )
+|currentCount|
+
+Source Location: (1789:83,17 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|
+while (--currentCount >= 0);|
+Generated Location: (6287:214,17 [30] )
+|
+while (--currentCount >= 0);|
+
+Source Location: (1824:86,1 [49] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|while (--currentCount <= 10)
+ currentCount++;|
+Generated Location: (6497:222,1 [49] )
+|while (--currentCount <= 10)
+ currentCount++;|
+
+Source Location: (1878:89,1 [99] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|using (var reader = new System.IO.StreamReader("/something"))
+ // Reading the entire file
+ |
+Generated Location: (6726:230,1 [99] )
+|using (var reader = new System.IO.StreamReader("/something"))
+ // Reading the entire file
+ |
+
+Source Location: (1978:91,5 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|reader.ReadToEnd()|
+Generated Location: (7010:239,6 [18] )
+|reader.ReadToEnd()|
+
+Source Location: (1996:91,23 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+||
+Generated Location: (7231:246,23 [0] )
+||
+
+Source Location: (2001:93,1 [32] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|lock (this)
+ currentCount++;|
+Generated Location: (7411:253,1 [32] )
+|lock (this)
+ currentCount++;|
+
+Source Location: (2038:96,1 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|if (true) |
+Generated Location: (7623:261,1 [10] )
+|if (true) |
+
+Source Location: (2049:96,12 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|@GitHubUserName |
+Generated Location: (7824:268,12 [16] )
+|@GitHubUserName |
+
+Source Location: (2083:98,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|if (true)
+ |
+Generated Location: (8020:275,1 [16] )
+|if (true)
+ |
+
+Source Location: (2118:99,23 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|DateTime.Now|
+Generated Location: (8239:283,23 [12] )
+|DateTime.Now|
+
+Source Location: (2136:100,0 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+||
+Generated Location: (8432:290,0 [0] )
+||
+
+Source Location: (846:36,12 [386] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|
+ public string Foo()
+ {
+ var x = "";
+
+ if (DateTime.Now.ToBinary() % 2 == 0)
+ return "Current time is divisible by 2";
+ else
+ return "It isn't divisible by two";
+
+ for (var i = 0; i < 10; i++)
+ // Incrementing a number
+ i--;
+
+ foreach (var item in new[] {"hello"})
+ |
+Generated Location: (8670:298,12 [386] )
+|
+ public string Foo()
+ {
+ var x = "";
+
+ if (DateTime.Now.ToBinary() % 2 == 0)
+ return "Current time is divisible by 2";
+ else
+ return "It isn't divisible by two";
+
+ for (var i = 0; i < 10; i++)
+ // Incrementing a number
+ i--;
+
+ foreach (var item in new[] {"hello"})
+ |
+
+Source Location: (1233:51,13 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|item|
+Generated Location: (9248:320,13 [4] )
+|item|
+
+Source Location: (1237:51,17 [28] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|
+
+ do
+ |
+Generated Location: (9449:327,17 [28] )
+|
+
+ do
+ |
+
+Source Location: (1266:54,13 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|currentCount|
+Generated Location: (9669:337,13 [12] )
+|currentCount|
+
+Source Location: (1278:54,25 [194] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|
+ while (--currentCount >= 0);
+
+ while (--currentCount <= 10)
+ currentCount++;
+
+ using (var reader = new System.IO.StreamReader("/something"))
+ |
+Generated Location: (9886:344,25 [194] )
+|
+ while (--currentCount >= 0);
+
+ while (--currentCount <= 10)
+ currentCount++;
+
+ using (var reader = new System.IO.StreamReader("/something"))
+ |
+
+Source Location: (1473:61,13 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|reader.ReadToEnd()|
+Generated Location: (10272:358,13 [18] )
+|reader.ReadToEnd()|
+
+Source Location: (1491:61,31 [177] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml)
+|
+
+ lock (this)
+ currentCount++;
+ }
+
+ int currentCount = 0;
+
+ public void IncrementCount()
+ {
+ if (true) currentCount++;
+ }
+
+|
+Generated Location: (10501:365,31 [177] )
+|
+
+ lock (this)
+ currentCount++;
+ }
+
+ int currentCount = 0;
+
+ public void IncrementCount()
+ {
+ if (true) currentCount++;
+ }
+
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.codegen.cs
new file mode 100644
index 0000000000..8f808b9826
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.codegen.cs
@@ -0,0 +1,344 @@
+#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a057512a2be3416c0f48286af45a4e9855e06f55"
+//
+#pragma warning disable 1591
+[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleLineControlFlowStatements_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml")]
+namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
+{
+ #line hidden
+ [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a057512a2be3416c0f48286af45a4e9855e06f55", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml")]
+ public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleLineControlFlowStatements_Runtime
+ {
+ #pragma warning disable 1998
+ public async System.Threading.Tasks.Task ExecuteAsync()
+ {
+ WriteLiteral("Before Text
\r\n\r\n");
+#nullable restore
+#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+ if (DateTime.Now.ToBinary() % 2 == 0)
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ Write("Current time is divisible by 2");
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ else
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ Write(DateTime.Now);
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+ object Bar()
+ {
+ if (DateTime.Now.ToBinary() % 2 == 0)
+ return "Current time is divisible by 2";
+ else if (DateTime.Now.ToBinary() % 3 == 0)
+ return "Current time is divisible by 3";
+ else
+ return DateTime.Now;
+ }
+
+ for (var i = 0; i < 10; i++)
+ // Incrementing a number
+ i--;
+
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 20 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ foreach (var item in new[] {"hello"})
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ Write(item);
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+ do
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ Write(currentCount);
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+ while (--currentCount >= 0);
+
+ while (--currentCount <= 10)
+ currentCount++;
+
+ using (var reader = new System.IO.StreamReader("/something"))
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 31 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ Write(reader.ReadToEnd());
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ lock (this)
+ currentCount++;
+
+#line default
+#line hidden
+#nullable disable
+ WriteLiteral("\r\n");
+ WriteLiteral("\r\n");
+#nullable restore
+#line 77 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ for (var i = 0; i < 10; i++)
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 78 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+Write(i);
+
+#line default
+#line hidden
+#nullable disable
+ WriteLiteral("\r\n");
+#nullable restore
+#line 80 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ foreach (var item in new[] {"hello"})
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 81 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+Write(item);
+
+#line default
+#line hidden
+#nullable disable
+ WriteLiteral("\r\n");
+#nullable restore
+#line 83 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ do
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 84 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+Write(currentCount);
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 84 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+while (--currentCount >= 0);
+
+#line default
+#line hidden
+#nullable disable
+ WriteLiteral("\r\n");
+#nullable restore
+#line 87 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ while (--currentCount <= 10)
+ currentCount++;
+
+#line default
+#line hidden
+#nullable disable
+ WriteLiteral("\r\n");
+#nullable restore
+#line 90 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ using (var reader = new System.IO.StreamReader("/something"))
+ // Reading the entire file
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 92 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+Write(reader.ReadToEnd());
+
+#line default
+#line hidden
+#nullable disable
+ WriteLiteral("\r\n");
+#nullable restore
+#line 94 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ lock (this)
+ currentCount++;
+
+#line default
+#line hidden
+#nullable disable
+ WriteLiteral("\r\n");
+#nullable restore
+#line 97 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ if (true)
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 97 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ @GitHubUserName
+
+#line default
+#line hidden
+#nullable disable
+ WriteLiteral("Hello!
\r\n\r\n");
+#nullable restore
+#line 99 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ if (true)
+
+
+#line default
+#line hidden
+#nullable disable
+ WriteLiteral(" The time is ");
+#nullable restore
+#line 100 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ Write(DateTime.Now);
+
+#line default
+#line hidden
+#nullable disable
+ WriteLiteral("
\r\n");
+ WriteLiteral("After Text
");
+ }
+ #pragma warning restore 1998
+#nullable restore
+#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+ public string Foo()
+ {
+ var x = "";
+
+ if (DateTime.Now.ToBinary() % 2 == 0)
+ return "Current time is divisible by 2";
+ else
+ return "It isn't divisible by two";
+
+ for (var i = 0; i < 10; i++)
+ // Incrementing a number
+ i--;
+
+ foreach (var item in new[] {"hello"})
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 52 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ Write(item);
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 52 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+ do
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 55 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ Write(currentCount);
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 55 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+ while (--currentCount >= 0);
+
+ while (--currentCount <= 10)
+ currentCount++;
+
+ using (var reader = new System.IO.StreamReader("/something"))
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 62 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+ Write(reader.ReadToEnd());
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 62 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml"
+
+
+ lock (this)
+ currentCount++;
+ }
+
+ int currentCount = 0;
+
+ public void IncrementCount()
+ {
+ if (true) currentCount++;
+ }
+
+
+#line default
+#line hidden
+#nullable disable
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.diagnostics.txt
new file mode 100644
index 0000000000..1078a21cf6
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.diagnostics.txt
@@ -0,0 +1,2 @@
+TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml(97,12): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
+TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml(100,5): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.ir.txt
new file mode 100644
index 0000000000..0447aaa746
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.ir.txt
@@ -0,0 +1,125 @@
+Document -
+ RazorCompiledItemAttribute -
+ NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
+ RazorSourceChecksumAttribute -
+ ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleLineControlFlowStatements_Runtime - -
+ MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync
+ HtmlContent - (0:0,0 [22] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (0:0,0 [2] SingleLineControlFlowStatements.cshtml) - Html -
+ IntermediateToken - (3:0,3 [11] SingleLineControlFlowStatements.cshtml) - Html - Before Text
+ IntermediateToken - (14:0,14 [4] SingleLineControlFlowStatements.cshtml) - Html -
+ IntermediateToken - (18:0,18 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n
+ CSharpCode - (24:2,2 [44] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (24:2,2 [44] SingleLineControlFlowStatements.cshtml) - CSharp - \n if (DateTime.Now.ToBinary() % 2 == 0)
+ CSharpExpression - (70:3,44 [32] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (70:3,44 [32] SingleLineControlFlowStatements.cshtml) - CSharp - "Current time is divisible by 2"
+ CSharpCode - (103:3,77 [6] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (103:3,77 [6] SingleLineControlFlowStatements.cshtml) - CSharp - else
+ CSharpExpression - (110:3,84 [12] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (110:3,84 [12] SingleLineControlFlowStatements.cshtml) - CSharp - DateTime.Now
+ CSharpCode - (122:3,96 [381] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (122:3,96 [381] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n object Bar()\n {\n if (DateTime.Now.ToBinary() % 2 == 0)\n return "Current time is divisible by 2";\n else if (DateTime.Now.ToBinary() % 3 == 0)\n return "Current time is divisible by 3";\n else\n return DateTime.Now;\n }\n\n for (var i = 0; i < 10; i++)\n // Incrementing a number\n i--;\n\n
+ CSharpCode - (504:19,5 [47] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (504:19,5 [47] SingleLineControlFlowStatements.cshtml) - CSharp - foreach (var item in new[] {"hello"})\n
+ CSharpExpression - (552:20,9 [4] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (552:20,9 [4] SingleLineControlFlowStatements.cshtml) - CSharp - item
+ CSharpCode - (556:20,13 [0] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (556:20,13 [0] SingleLineControlFlowStatements.cshtml) - CSharp -
+ CSharpCode - (556:20,13 [20] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (556:20,13 [20] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n do\n
+ CSharpExpression - (577:23,9 [12] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (577:23,9 [12] SingleLineControlFlowStatements.cshtml) - CSharp - currentCount
+ CSharpCode - (589:23,21 [174] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (589:23,21 [174] SingleLineControlFlowStatements.cshtml) - CSharp - \n while (--currentCount >= 0);\n\n while (--currentCount <= 10)\n currentCount++;\n\n using (var reader = new System.IO.StreamReader("/something"))\n
+ CSharpExpression - (764:30,9 [18] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (764:30,9 [18] SingleLineControlFlowStatements.cshtml) - CSharp - reader.ReadToEnd()
+ CSharpCode - (782:30,27 [8] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (782:30,27 [8] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n
+ CSharpCode - (791:32,5 [36] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (791:32,5 [36] SingleLineControlFlowStatements.cshtml) - CSharp - lock (this)\n currentCount++;
+ CSharpCode - (827:33,23 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (827:33,23 [2] SingleLineControlFlowStatements.cshtml) - CSharp - \n
+ HtmlContent - (832:35,0 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (832:35,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n
+ HtmlContent - (1671:75,0 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1671:75,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n
+ CSharpCode - (1674:76,1 [34] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1674:76,1 [34] SingleLineControlFlowStatements.cshtml) - CSharp - for (var i = 0; i < 10; i++)\n
+ CSharpExpression - (1709:77,5 [1] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1709:77,5 [1] SingleLineControlFlowStatements.cshtml) - CSharp - i
+ CSharpCode - (1710:77,6 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1710:77,6 [2] SingleLineControlFlowStatements.cshtml) - CSharp - \n
+ HtmlContent - (1712:78,0 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1712:78,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n
+ CSharpCode - (1715:79,1 [43] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1715:79,1 [43] SingleLineControlFlowStatements.cshtml) - CSharp - foreach (var item in new[] {"hello"})\n
+ CSharpExpression - (1759:80,5 [4] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1759:80,5 [4] SingleLineControlFlowStatements.cshtml) - CSharp - item
+ CSharpCode - (1763:80,9 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1763:80,9 [2] SingleLineControlFlowStatements.cshtml) - CSharp - \n
+ HtmlContent - (1765:81,0 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1765:81,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n
+ CSharpCode - (1768:82,1 [8] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1768:82,1 [8] SingleLineControlFlowStatements.cshtml) - CSharp - do\n
+ CSharpExpression - (1777:83,5 [12] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1777:83,5 [12] SingleLineControlFlowStatements.cshtml) - CSharp - currentCount
+ CSharpCode - (1789:83,17 [32] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1789:83,17 [32] SingleLineControlFlowStatements.cshtml) - CSharp - \nwhile (--currentCount >= 0);\n
+ HtmlContent - (1821:85,0 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1821:85,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n
+ CSharpCode - (1824:86,1 [51] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1824:86,1 [51] SingleLineControlFlowStatements.cshtml) - CSharp - while (--currentCount <= 10)\n currentCount++;\n
+ HtmlContent - (1875:88,0 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1875:88,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n
+ CSharpCode - (1878:89,1 [99] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1878:89,1 [99] SingleLineControlFlowStatements.cshtml) - CSharp - using (var reader = new System.IO.StreamReader("/something"))\n // Reading the entire file\n
+ CSharpExpression - (1978:91,5 [18] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1978:91,5 [18] SingleLineControlFlowStatements.cshtml) - CSharp - reader.ReadToEnd()
+ CSharpCode - (1996:91,23 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1996:91,23 [2] SingleLineControlFlowStatements.cshtml) - CSharp - \n
+ HtmlContent - (1998:92,0 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1998:92,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n
+ CSharpCode - (2001:93,1 [34] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2001:93,1 [34] SingleLineControlFlowStatements.cshtml) - CSharp - lock (this)\n currentCount++;\n
+ HtmlContent - (2035:95,0 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2035:95,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n
+ CSharpCode - (2038:96,1 [10] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2038:96,1 [10] SingleLineControlFlowStatements.cshtml) - CSharp - if (true)
+ CSharpCode - (2049:96,12 [16] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2049:96,12 [16] SingleLineControlFlowStatements.cshtml) - CSharp - @GitHubUserName
+ HtmlContent - (2065:96,28 [17] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2065:96,28 [2] SingleLineControlFlowStatements.cshtml) - Html -
+ IntermediateToken - (2068:96,31 [6] SingleLineControlFlowStatements.cshtml) - Html - Hello!
+ IntermediateToken - (2074:96,37 [4] SingleLineControlFlowStatements.cshtml) - Html -
+ IntermediateToken - (2078:96,41 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n
+ CSharpCode - (2083:98,1 [16] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2083:98,1 [16] SingleLineControlFlowStatements.cshtml) - CSharp - if (true) \n
+ HtmlContent - (2101:99,6 [16] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2101:99,6 [16] SingleLineControlFlowStatements.cshtml) - Html - The time is
+ CSharpExpression - (2118:99,23 [12] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2118:99,23 [12] SingleLineControlFlowStatements.cshtml) - CSharp - DateTime.Now
+ HtmlContent - (2130:99,35 [6] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2130:99,35 [6] SingleLineControlFlowStatements.cshtml) - Html -
\n
+ CSharpCode - (2136:100,0 [2] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2136:100,0 [2] SingleLineControlFlowStatements.cshtml) - CSharp - \n
+ HtmlContent - (2138:101,0 [17] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (2138:101,0 [2] SingleLineControlFlowStatements.cshtml) - Html -
+ IntermediateToken - (2141:101,3 [10] SingleLineControlFlowStatements.cshtml) - Html - After Text
+ IntermediateToken - (2151:101,13 [4] SingleLineControlFlowStatements.cshtml) - Html -
+ CSharpCode - (846:36,12 [386] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (846:36,12 [386] SingleLineControlFlowStatements.cshtml) - CSharp - \n public string Foo()\n {\n var x = "";\n\n if (DateTime.Now.ToBinary() % 2 == 0)\n return "Current time is divisible by 2";\n else\n return "It isn't divisible by two";\n \n for (var i = 0; i < 10; i++)\n // Incrementing a number\n i--;\n\n foreach (var item in new[] {"hello"})\n
+ CSharpExpression - (1233:51,13 [4] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1233:51,13 [4] SingleLineControlFlowStatements.cshtml) - CSharp - item
+ CSharpCode - (1237:51,17 [28] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1237:51,17 [28] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n do\n
+ CSharpExpression - (1266:54,13 [12] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1266:54,13 [12] SingleLineControlFlowStatements.cshtml) - CSharp - currentCount
+ CSharpCode - (1278:54,25 [194] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1278:54,25 [194] SingleLineControlFlowStatements.cshtml) - CSharp - \n while (--currentCount >= 0);\n\n while (--currentCount <= 10)\n currentCount++;\n\n using (var reader = new System.IO.StreamReader("/something"))\n
+ CSharpExpression - (1473:61,13 [18] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1473:61,13 [18] SingleLineControlFlowStatements.cshtml) - CSharp - reader.ReadToEnd()
+ CSharpCode - (1491:61,31 [177] SingleLineControlFlowStatements.cshtml)
+ IntermediateToken - (1491:61,31 [177] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n lock (this)\n currentCount++;\n }\n\n int currentCount = 0;\n\n public void IncrementCount()\n {\n if (true) currentCount++;\n }\n\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.codegen.cs
new file mode 100644
index 0000000000..d8c711fa0e
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/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;
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+using Microsoft.AspNetCore.Components.RenderTree;
+
+#line default
+#line hidden
+#nullable disable
+ public 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.RenderTree.RenderTreeBuilder builder)
+ {
+#nullable restore
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ var output = string.Empty;
+ if (builder == null) output = "Builder is null!";
+ else output = "Builder is not null!";
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 7 "x:\dir\subdir\Test\TestComponent.cshtml"
+ __o = output;
+
+#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/SingleLineControlFlowStatements_InCodeBlock/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.ir.txt
new file mode 100644
index 0000000000..18ceaf1ef4
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.ir.txt
@@ -0,0 +1,28 @@
+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 [49] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components.RenderTree
+ ClassDeclaration - - public - 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 - (50:0,50 [4] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (50:0,50 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
+ CSharpCode - (56:2,2 [136] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (56:2,2 [136] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n var output = string.Empty;\n if (builder == null) output = "Builder is null!";\n else output = "Builder is not null!";\n
+ MarkupElement - (192:6,4 [22] x:\dir\subdir\Test\TestComponent.cshtml) - p
+ HtmlContent - (195:6,7 [8] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (195:6,7 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Output:
+ CSharpExpression - (204:6,16 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (204:6,16 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - output
+ CSharpCode - (214:6,26 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (214:6,26 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.mappings.txt
new file mode 100644
index 0000000000..b0e58ecabe
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.mappings.txt
@@ -0,0 +1,30 @@
+Source Location: (1:0,1 [49] x:\dir\subdir\Test\TestComponent.cshtml)
+|using Microsoft.AspNetCore.Components.RenderTree;|
+Generated Location: (320:12,0 [49] )
+|using Microsoft.AspNetCore.Components.RenderTree;|
+
+Source Location: (56:2,2 [136] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ var output = string.Empty;
+ if (builder == null) output = "Builder is null!";
+ else output = "Builder is not null!";
+ |
+Generated Location: (1016:31,2 [136] )
+|
+ var output = string.Empty;
+ if (builder == null) output = "Builder is null!";
+ else output = "Builder is not null!";
+ |
+
+Source Location: (204:6,16 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+|output|
+Generated Location: (1290:42,16 [6] )
+|output|
+
+Source Location: (214:6,26 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+|
+Generated Location: (1387:47,38 [2] )
+|
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.codegen.cs
new file mode 100644
index 0000000000..61eb15d81e
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.codegen.cs
@@ -0,0 +1,62 @@
+//
+#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.RenderTree;
+
+#line default
+#line hidden
+#nullable disable
+ public 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.RenderTree.RenderTreeBuilder builder)
+ {
+ }
+ #pragma warning restore 1998
+#nullable restore
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ void RenderChildComponent(RenderTreeBuilder builder)
+ {
+ var output = string.Empty;
+ if (builder == null) output = "Builder is null!";
+ else output = "Builder is not null!";
+
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 9 "x:\dir\subdir\Test\TestComponent.cshtml"
+ __o = output;
+
+#line default
+#line hidden
+#nullable disable
+#nullable restore
+#line 9 "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/SingleLineControlFlowStatements_InCodeDirective/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.ir.txt
new file mode 100644
index 0000000000..48f398102f
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.ir.txt
@@ -0,0 +1,28 @@
+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 [49] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components.RenderTree
+ ClassDeclaration - - public - 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 - (50:0,50 [4] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (50:0,50 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
+ CSharpCode - (61:2,7 [217] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (61:2,7 [217] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void RenderChildComponent(RenderTreeBuilder builder)\n {\n var output = string.Empty;\n if (builder == null) output = "Builder is null!";\n else output = "Builder is not null!";\n
+ MarkupElement - (278:8,8 [22] x:\dir\subdir\Test\TestComponent.cshtml) - p
+ HtmlContent - (281:8,11 [8] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (281:8,11 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Output:
+ CSharpExpression - (290:8,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (290:8,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - output
+ CSharpCode - (300:8,30 [9] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (300:8,30 [9] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n }\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.mappings.txt
new file mode 100644
index 0000000000..dfffce2a60
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.mappings.txt
@@ -0,0 +1,36 @@
+Source Location: (1:0,1 [49] x:\dir\subdir\Test\TestComponent.cshtml)
+|using Microsoft.AspNetCore.Components.RenderTree;|
+Generated Location: (320:12,0 [49] )
+|using Microsoft.AspNetCore.Components.RenderTree;|
+
+Source Location: (61:2,7 [217] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ void RenderChildComponent(RenderTreeBuilder builder)
+ {
+ var output = string.Empty;
+ if (builder == null) output = "Builder is null!";
+ else output = "Builder is not null!";
+ |
+Generated Location: (1070:33,7 [217] )
+|
+ void RenderChildComponent(RenderTreeBuilder builder)
+ {
+ var output = string.Empty;
+ if (builder == null) output = "Builder is null!";
+ else output = "Builder is not null!";
+ |
+
+Source Location: (290:8,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+|output|
+Generated Location: (1429:46,20 [6] )
+|output|
+
+Source Location: (300:8,30 [9] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ }
+|
+Generated Location: (1588:53,30 [9] )
+|
+ }
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.codegen.cs
new file mode 100644
index 0000000000..344c9db113
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/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;
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+using Microsoft.AspNetCore.Components.RenderTree;
+
+#line default
+#line hidden
+#nullable disable
+ public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
+ {
+#nullable restore
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ var output = string.Empty;
+ if (builder == null) output = "Builder is null!";
+ else output = "Builder is not null!";
+
+#line default
+#line hidden
+#nullable disable
+ builder.AddContent(0, " ");
+ builder.OpenElement(1, "p");
+ builder.AddContent(2, "Output: ");
+ builder.AddContent(3,
+#nullable restore
+#line 7 "x:\dir\subdir\Test\TestComponent.cshtml"
+ output
+
+#line default
+#line hidden
+#nullable disable
+ );
+ builder.CloseElement();
+ builder.AddMarkupContent(4, "\r\n");
+ }
+ #pragma warning restore 1998
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.ir.txt
new file mode 100644
index 0000000000..53749a6138
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.ir.txt
@@ -0,0 +1,23 @@
+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 [51] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components.RenderTree
+ ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ CSharpCode - (56:2,2 [132] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (56:2,2 [132] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n var output = string.Empty;\n if (builder == null) output = "Builder is null!";\n else output = "Builder is not null!";\n
+ HtmlContent - (188:6,0 [4] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (188:6,0 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html -
+ MarkupElement - (192:6,4 [22] x:\dir\subdir\Test\TestComponent.cshtml) - p
+ HtmlContent - (195:6,7 [8] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (195:6,7 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Output:
+ CSharpExpression - (204:6,16 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (204:6,16 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - output
+ HtmlContent - (214:6,26 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (214:6,26 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (216:7,0 [0] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (216:7,0 [0] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp -
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.mappings.txt
new file mode 100644
index 0000000000..2abccf9774
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.mappings.txt
@@ -0,0 +1,13 @@
+Source Location: (56:2,2 [132] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ var output = string.Empty;
+ if (builder == null) output = "Builder is null!";
+ else output = "Builder is not null!";
+|
+Generated Location: (748:24,2 [132] )
+|
+ var output = string.Empty;
+ if (builder == null) output = "Builder is null!";
+ else output = "Builder is not null!";
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.codegen.cs
new file mode 100644
index 0000000000..5dd2ab1396
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.codegen.cs
@@ -0,0 +1,60 @@
+//
+#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.RenderTree;
+
+#line default
+#line hidden
+#nullable disable
+ public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
+ {
+ }
+ #pragma warning restore 1998
+#nullable restore
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ void RenderChildComponent(RenderTreeBuilder builder)
+ {
+ var output = string.Empty;
+ if (builder == null) output = "Builder is null!";
+ else output = "Builder is not null!";
+
+#line default
+#line hidden
+#nullable disable
+ builder.AddContent(0, " ");
+ builder.OpenElement(1, "p");
+ builder.AddContent(2, "Output: ");
+ builder.AddContent(3,
+#nullable restore
+#line 9 "x:\dir\subdir\Test\TestComponent.cshtml"
+ output
+
+#line default
+#line hidden
+#nullable disable
+ );
+ builder.CloseElement();
+ builder.AddMarkupContent(4, "\r\n");
+#nullable restore
+#line 10 "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/SingleLineControlFlowStatements_InCodeDirective/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.ir.txt
new file mode 100644
index 0000000000..ce90835d3a
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.ir.txt
@@ -0,0 +1,23 @@
+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 [51] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components.RenderTree
+ ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ CSharpCode - (61:2,7 [209] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (61:2,7 [209] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void RenderChildComponent(RenderTreeBuilder builder)\n {\n var output = string.Empty;\n if (builder == null) output = "Builder is null!";\n else output = "Builder is not null!";\n
+ HtmlContent - (270:8,0 [8] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (270:8,0 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html -
+ MarkupElement - (278:8,8 [22] x:\dir\subdir\Test\TestComponent.cshtml) - p
+ HtmlContent - (281:8,11 [8] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (281:8,11 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Output:
+ CSharpExpression - (290:8,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (290:8,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - output
+ HtmlContent - (300:8,30 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (300:8,30 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (302:9,0 [7] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (302:9,0 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - }\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.mappings.txt
new file mode 100644
index 0000000000..e46d850ede
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeDirective/TestComponent.mappings.txt
@@ -0,0 +1,24 @@
+Source Location: (61:2,7 [209] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ void RenderChildComponent(RenderTreeBuilder builder)
+ {
+ var output = string.Empty;
+ if (builder == null) output = "Builder is null!";
+ else output = "Builder is not null!";
+|
+Generated Location: (802:26,7 [209] )
+|
+ void RenderChildComponent(RenderTreeBuilder builder)
+ {
+ var output = string.Empty;
+ if (builder == null) output = "Builder is null!";
+ else output = "Builder is not null!";
+|
+
+Source Location: (302:9,0 [7] x:\dir\subdir\Test\TestComponent.cshtml)
+| }
+|
+Generated Location: (1529:52,0 [7] )
+| }
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement.cspans.txt
new file mode 100644
index 0000000000..2b83431b67
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement.cspans.txt
@@ -0,0 +1,9 @@
+Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [76] )
+Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [76] )
+MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [76] )
+Code span at (2:0,2 [66] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [76] )
+Transition span at (68:2,34 [1] ) (Accepts:None) - Parent: Expression block at (68:2,34 [5] )
+Code span at (69:2,35 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (68:2,34 [5] )
+Code span at (73:2,39 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [76] )
+MetaCode span at (75:3,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [76] )
+Markup span at (76:3,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [76] )
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement.stree.txt
new file mode 100644
index 0000000000..8ba21b984f
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement.stree.txt
@@ -0,0 +1,59 @@
+RazorDocument - [0..76)::76 - [@{LF var time = DateTime.Now;LF if (time.ToBinary() % 2 == 0) @timeLF}]
+ MarkupBlock - [0..76)::76
+ MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any
+ Marker;[];
+ CSharpCodeBlock - [0..76)::76
+ CSharpStatement - [0..76)::76
+ CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None
+ Transition;[@];
+ CSharpStatementBody - [1..76)::75
+ RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None
+ LeftBrace;[{];
+ CSharpCodeBlock - [2..75)::73
+ CSharpStatementLiteral - [2..68)::66 - [LF var time = DateTime.Now;LF if (time.ToBinary() % 2 == 0) ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL
+ NewLine;[LF];
+ Whitespace;[ ];
+ Identifier;[var];
+ Whitespace;[ ];
+ Identifier;[time];
+ Whitespace;[ ];
+ Assign;[=];
+ Whitespace;[ ];
+ Identifier;[DateTime];
+ Dot;[.];
+ Identifier;[Now];
+ Semicolon;[;];
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[if];
+ Whitespace;[ ];
+ LeftParenthesis;[(];
+ Identifier;[time];
+ Dot;[.];
+ Identifier;[ToBinary];
+ LeftParenthesis;[(];
+ RightParenthesis;[)];
+ Whitespace;[ ];
+ Modulo;[%];
+ Whitespace;[ ];
+ IntegerLiteral;[2];
+ Whitespace;[ ];
+ Equals;[==];
+ Whitespace;[ ];
+ IntegerLiteral;[0];
+ RightParenthesis;[)];
+ Whitespace;[ ];
+ CSharpCodeBlock - [68..73)::5
+ CSharpImplicitExpression - [68..73)::5
+ CSharpTransition - [68..69)::1 - Gen - SpanEditHandler;Accepts:None
+ Transition;[@];
+ CSharpImplicitExpressionBody - [69..73)::4
+ CSharpCodeBlock - [69..73)::4
+ CSharpExpressionLiteral - [69..73)::4 - [time] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14
+ Identifier;[time];
+ CSharpStatementLiteral - [73..75)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any
+ NewLine;[LF];
+ RazorMetaCode - [75..76)::1 - Gen - SpanEditHandler;Accepts:None
+ RightBrace;[}];
+ MarkupTextLiteral - [76..76)::0 - [] - Gen - SpanEditHandler;Accepts:Any
+ Marker;[];
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement_Error.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement_Error.cspans.txt
new file mode 100644
index 0000000000..b4bfdb3e9d
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement_Error.cspans.txt
@@ -0,0 +1,29 @@
+Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [382] )
+Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [382] )
+MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [382] )
+Code span at (2:0,2 [66] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [382] )
+Markup span at (68:2,34 [3] ) (Accepts:None) - Parent: Tag block at (68:2,34 [3] )
+Markup span at (71:2,37 [10] ) (Accepts:Any) - Parent: Markup block at (68:2,34 [24] )
+Transition span at (81:2,47 [1] ) (Accepts:None) - Parent: Expression block at (81:2,47 [5] )
+Code span at (82:2,48 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (81:2,47 [5] )
+Markup span at (86:2,52 [4] ) (Accepts:None) - Parent: Tag block at (86:2,52 [4] )
+Markup span at (90:2,56 [2] ) (Accepts:None) - Parent: Markup block at (68:2,34 [24] )
+Code span at (92:3,0 [104] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [382] )
+Markup span at (196:6,8 [3] ) (Accepts:None) - Parent: Tag block at (196:6,8 [3] )
+Markup span at (199:6,11 [20] ) (Accepts:Any) - Parent: Markup block at (196:6,8 [34] )
+Transition span at (219:6,31 [1] ) (Accepts:None) - Parent: Expression block at (219:6,31 [5] )
+Code span at (220:6,32 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (219:6,31 [5] )
+Markup span at (224:6,36 [4] ) (Accepts:None) - Parent: Tag block at (224:6,36 [4] )
+Markup span at (228:6,40 [2] ) (Accepts:None) - Parent: Markup block at (196:6,8 [34] )
+Code span at (230:7,0 [45] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [382] )
+Transition span at (275:9,8 [1] ) (Accepts:None) - Parent: Markup block at (275:9,8 [27] )
+MetaCode span at (276:9,9 [1] ) (Accepts:Any) - Parent: Markup block at (275:9,8 [27] )
+Markup span at (277:9,10 [14] ) (Accepts:Any) - Parent: Markup block at (275:9,8 [27] )
+Transition span at (291:9,24 [1] ) (Accepts:None) - Parent: Expression block at (291:9,24 [5] )
+Code span at (292:9,25 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (291:9,24 [5] )
+Markup span at (296:9,29 [6] ) (Accepts:None) - Parent: Markup block at (275:9,8 [27] )
+Code span at (302:10,0 [36] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [382] )
+Code span at (338:11,34 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [382] )
+Code span at (339:11,35 [42] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [382] )
+MetaCode span at (381:12,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [382] )
+Markup span at (382:12,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [382] )
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement_Error.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement_Error.diag.txt
new file mode 100644
index 0000000000..f3d2aeec7b
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement_Error.diag.txt
@@ -0,0 +1,4 @@
+(3,35): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
+(7,9): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
+(10,9): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
+(12,35): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement_Error.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement_Error.stree.txt
new file mode 100644
index 0000000000..bd49b06499
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/CSharpBlock_SingleLineControlFlowStatement_Error.stree.txt
@@ -0,0 +1,214 @@
+RazorDocument - [0..382)::382 - [@{LF var time = DateTime.Now;LF if (time.ToBinary() % 2 == 0) The time: @time
LFLF if (time.ToBinary() %3 == 0)LF // For some reason we want to render the time now?LF The confusing time: @time
LFLF if (time.ToBinary() % 4 == 0)LF @: The time: @time
LFLF if (time.ToBinary() % 5 == 0) @@SomeGitHubUserName Hi!LF}]
+ MarkupBlock - [0..382)::382
+ MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any
+ Marker;[];
+ CSharpCodeBlock - [0..382)::382
+ CSharpStatement - [0..382)::382
+ CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None
+ Transition;[@];
+ CSharpStatementBody - [1..382)::381
+ RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None
+ LeftBrace;[{];
+ CSharpCodeBlock - [2..381)::379
+ CSharpStatementLiteral - [2..68)::66 - [LF var time = DateTime.Now;LF if (time.ToBinary() % 2 == 0) ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL
+ NewLine;[LF];
+ Whitespace;[ ];
+ Identifier;[var];
+ Whitespace;[ ];
+ Identifier;[time];
+ Whitespace;[ ];
+ Assign;[=];
+ Whitespace;[ ];
+ Identifier;[DateTime];
+ Dot;[.];
+ Identifier;[Now];
+ Semicolon;[;];
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[if];
+ Whitespace;[ ];
+ LeftParenthesis;[(];
+ Identifier;[time];
+ Dot;[.];
+ Identifier;[ToBinary];
+ LeftParenthesis;[(];
+ RightParenthesis;[)];
+ Whitespace;[ ];
+ Modulo;[%];
+ Whitespace;[ ];
+ IntegerLiteral;[2];
+ Whitespace;[ ];
+ Equals;[==];
+ Whitespace;[ ];
+ IntegerLiteral;[0];
+ RightParenthesis;[)];
+ Whitespace;[ ];
+ MarkupBlock - [68..92)::24
+ MarkupElement - [68..90)::22
+ MarkupStartTag - [68..71)::3 - [] - Gen - SpanEditHandler;Accepts:None
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [71..81)::10 - [The time: ] - Gen - SpanEditHandler;Accepts:Any
+ Text;[The];
+ Whitespace;[ ];
+ Text;[time:];
+ Whitespace;[ ];
+ CSharpCodeBlock - [81..86)::5
+ CSharpImplicitExpression - [81..86)::5
+ CSharpTransition - [81..82)::1 - Gen - SpanEditHandler;Accepts:None
+ Transition;[@];
+ CSharpImplicitExpressionBody - [82..86)::4
+ CSharpCodeBlock - [82..86)::4
+ CSharpExpressionLiteral - [82..86)::4 - [time] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14
+ Identifier;[time];
+ MarkupEndTag - [86..90)::4 - [
] - Gen - SpanEditHandler;Accepts:None
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [90..92)::2 - [LF] - Gen - SpanEditHandler;Accepts:None
+ NewLine;[LF];
+ CSharpStatementLiteral - [92..196)::104 - [LF if (time.ToBinary() %3 == 0)LF // For some reason we want to render the time now?LF ] - Gen - SpanEditHandler;Accepts:Any
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[if];
+ Whitespace;[ ];
+ LeftParenthesis;[(];
+ Identifier;[time];
+ Dot;[.];
+ Identifier;[ToBinary];
+ LeftParenthesis;[(];
+ RightParenthesis;[)];
+ Whitespace;[ ];
+ Modulo;[%];
+ IntegerLiteral;[3];
+ Whitespace;[ ];
+ Equals;[==];
+ Whitespace;[ ];
+ IntegerLiteral;[0];
+ RightParenthesis;[)];
+ NewLine;[LF];
+ Whitespace;[ ];
+ CSharpComment;[// For some reason we want to render the time now?];
+ NewLine;[LF];
+ Whitespace;[ ];
+ MarkupBlock - [196..230)::34
+ MarkupElement - [196..228)::32
+ MarkupStartTag - [196..199)::3 - [] - Gen - SpanEditHandler;Accepts:None
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [199..219)::20 - [The confusing time: ] - Gen - SpanEditHandler;Accepts:Any
+ Text;[The];
+ Whitespace;[ ];
+ Text;[confusing];
+ Whitespace;[ ];
+ Text;[time:];
+ Whitespace;[ ];
+ CSharpCodeBlock - [219..224)::5
+ CSharpImplicitExpression - [219..224)::5
+ CSharpTransition - [219..220)::1 - Gen - SpanEditHandler;Accepts:None
+ Transition;[@];
+ CSharpImplicitExpressionBody - [220..224)::4
+ CSharpCodeBlock - [220..224)::4
+ CSharpExpressionLiteral - [220..224)::4 - [time] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14
+ Identifier;[time];
+ MarkupEndTag - [224..228)::4 - [
] - Gen - SpanEditHandler;Accepts:None
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [228..230)::2 - [LF] - Gen - SpanEditHandler;Accepts:None
+ NewLine;[LF];
+ CSharpStatementLiteral - [230..275)::45 - [LF if (time.ToBinary() % 4 == 0)LF ] - Gen - SpanEditHandler;Accepts:Any
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[if];
+ Whitespace;[ ];
+ LeftParenthesis;[(];
+ Identifier;[time];
+ Dot;[.];
+ Identifier;[ToBinary];
+ LeftParenthesis;[(];
+ RightParenthesis;[)];
+ Whitespace;[ ];
+ Modulo;[%];
+ Whitespace;[ ];
+ IntegerLiteral;[4];
+ Whitespace;[ ];
+ Equals;[==];
+ Whitespace;[ ];
+ IntegerLiteral;[0];
+ RightParenthesis;[)];
+ NewLine;[LF];
+ Whitespace;[ ];
+ MarkupBlock - [275..302)::27
+ MarkupTransition - [275..276)::1 - Gen - SpanEditHandler;Accepts:None
+ Transition;[@];
+ RazorMetaCode - [276..277)::1 - Gen - SpanEditHandler;Accepts:Any
+ Colon;[:];
+ MarkupTextLiteral - [277..291)::14 - [ The time: ] - Gen - SpanEditHandler;Accepts:Any
+ Whitespace;[ ];
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ Text;[The];
+ Whitespace;[ ];
+ Text;[time:];
+ Whitespace;[ ];
+ CSharpCodeBlock - [291..296)::5
+ CSharpImplicitExpression - [291..296)::5
+ CSharpTransition - [291..292)::1 - Gen - SpanEditHandler;Accepts:None
+ Transition;[@];
+ CSharpImplicitExpressionBody - [292..296)::4
+ CSharpCodeBlock - [292..296)::4
+ CSharpExpressionLiteral - [292..296)::4 - [time] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14
+ Identifier;[time];
+ MarkupTextLiteral - [296..302)::6 - [
LF] - Gen - SpanEditHandler;Accepts:None
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ NewLine;[LF];
+ CSharpStatementLiteral - [302..338)::36 - [LF if (time.ToBinary() % 5 == 0) ] - Gen - SpanEditHandler;Accepts:Any
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[if];
+ Whitespace;[ ];
+ LeftParenthesis;[(];
+ Identifier;[time];
+ Dot;[.];
+ Identifier;[ToBinary];
+ LeftParenthesis;[(];
+ RightParenthesis;[)];
+ Whitespace;[ ];
+ Modulo;[%];
+ Whitespace;[ ];
+ IntegerLiteral;[5];
+ Whitespace;[ ];
+ Equals;[==];
+ Whitespace;[ ];
+ IntegerLiteral;[0];
+ RightParenthesis;[)];
+ Whitespace;[ ];
+ CSharpEphemeralTextLiteral - [338..339)::1 - [@] - Gen - SpanEditHandler;Accepts:Any
+ Transition;[@];
+ CSharpStatementLiteral - [339..381)::42 - [@SomeGitHubUserName Hi!LF] - Gen - SpanEditHandler;Accepts:Any
+ Transition;[@];
+ Identifier;[SomeGitHubUserName];
+ Whitespace;[ ];
+ LessThan;[<];
+ Identifier;[strong];
+ GreaterThan;[>];
+ Identifier;[Hi];
+ Not;[!];
+ LessThan;[<];
+ Slash;[/];
+ Identifier;[strong];
+ GreaterThan;[>];
+ NewLine;[LF];
+ RazorMetaCode - [381..382)::1 - Gen - SpanEditHandler;Accepts:None
+ RightBrace;[}];
+ MarkupTextLiteral - [382..382)::0 - [] - Gen - SpanEditHandler;Accepts:Any
+ Marker;[];
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.diag.txt
deleted file mode 100644
index 37ec018710..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.diag.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-(1,9): Error RZ1008: Expected a "{" but found a ")". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed:
-
-@if(isLoggedIn)
- Hello, @user
-
-Instead, wrap the contents of the block in "{}":
-
-@if(isLoggedIn) {
- Hello, @user
-}
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.diag.txt
index afc72ddf95..c18bec89a9 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.diag.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.diag.txt
@@ -1,30 +1,3 @@
-(1,10): Error RZ1008: Expected a "{" but found a "<". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed:
-
-@if(isLoggedIn)
- Hello, @user
-
-Instead, wrap the contents of the block in "{}":
-
-@if(isLoggedIn) {
- Hello, @user
-}
-(1,34): Error RZ1008: Expected a "{" but found a "<". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed:
-
-@if(isLoggedIn)
- Hello, @user
-
-Instead, wrap the contents of the block in "{}":
-
-@if(isLoggedIn) {
- Hello, @user
-}
-(1,50): Error RZ1008: Expected a "{" but found a "<". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed:
-
-@if(isLoggedIn)
- Hello, @user
-
-Instead, wrap the contents of the block in "{}":
-
-@if(isLoggedIn) {
- Hello, @user
-}
+(1,10): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
+(1,34): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
+(1,50): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement.cspans.txt
new file mode 100644
index 0000000000..ad756e73a2
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement.cspans.txt
@@ -0,0 +1,8 @@
+Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [147] )
+Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [145] )
+MetaCode span at (3:1,1 [9] ) (Accepts:None) - Parent: Directive block at (2:1,0 [145] )
+None span at (12:1,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (2:1,0 [145] )
+MetaCode span at (13:1,11 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [145] )
+Code span at (14:1,12 [130] ) (Accepts:Any) - Parent: Directive block at (2:1,0 [145] )
+MetaCode span at (144:6,0 [3] ) (Accepts:None) - Parent: Directive block at (2:1,0 [145] )
+Markup span at (147:7,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [147] )
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement.stree.txt
new file mode 100644
index 0000000000..96b51d354b
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement.stree.txt
@@ -0,0 +1,62 @@
+RazorDocument - [0..147)::147 - [LF@functions {LF string GetAnnouncmentText(string message)LF {LF if (message.Length > 0) return "Anouncement: " + message;LF }LF}LF]
+ MarkupBlock - [0..147)::147
+ MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any
+ NewLine;[LF];
+ CSharpCodeBlock - [2..147)::145
+ RazorDirective - [2..147)::145 - Directive:{functions;CodeBlock;Unrestricted}
+ CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None
+ Transition;[@];
+ RazorDirectiveBody - [3..147)::144
+ RazorMetaCode - [3..12)::9 - Gen - SpanEditHandler;Accepts:None
+ Identifier;[functions];
+ CSharpCodeBlock - [12..147)::135
+ UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace
+ Whitespace;[ ];
+ RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd
+ LeftBrace;[{];
+ CSharpCodeBlock - [14..144)::130
+ CSharpStatementLiteral - [14..144)::130 - [LF string GetAnnouncmentText(string message)LF {LF if (message.Length > 0) return "Anouncement: " + message;LF }LF] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[string];
+ Whitespace;[ ];
+ Identifier;[GetAnnouncmentText];
+ LeftParenthesis;[(];
+ Keyword;[string];
+ Whitespace;[ ];
+ Identifier;[message];
+ RightParenthesis;[)];
+ NewLine;[LF];
+ Whitespace;[ ];
+ LeftBrace;[{];
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[if];
+ Whitespace;[ ];
+ LeftParenthesis;[(];
+ Identifier;[message];
+ Dot;[.];
+ Identifier;[Length];
+ Whitespace;[ ];
+ GreaterThan;[>];
+ Whitespace;[ ];
+ IntegerLiteral;[0];
+ RightParenthesis;[)];
+ Whitespace;[ ];
+ Keyword;[return];
+ Whitespace;[ ];
+ StringLiteral;["Anouncement: "];
+ Whitespace;[ ];
+ Plus;[+];
+ Whitespace;[ ];
+ Identifier;[message];
+ Semicolon;[;];
+ NewLine;[LF];
+ Whitespace;[ ];
+ RightBrace;[}];
+ NewLine;[LF];
+ RazorMetaCode - [144..147)::3 - Gen - SpanEditHandler;Accepts:None
+ RightBrace;[}];
+ NewLine;[LF];
+ MarkupTextLiteral - [147..147)::0 - [] - Gen - SpanEditHandler;Accepts:Any
+ Marker;[];
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.cspans.txt
new file mode 100644
index 0000000000..223c39f5de
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.cspans.txt
@@ -0,0 +1,36 @@
+Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [408] )
+Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [406] )
+MetaCode span at (3:1,1 [9] ) (Accepts:None) - Parent: Directive block at (2:1,0 [406] )
+None span at (12:1,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (2:1,0 [406] )
+MetaCode span at (13:1,11 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [406] )
+Code span at (14:1,12 [88] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] )
+Markup span at (102:4,32 [3] ) (Accepts:None) - Parent: Tag block at (102:4,32 [3] )
+Markup span at (105:4,35 [9] ) (Accepts:Any) - Parent: Markup block at (102:4,32 [26] )
+Transition span at (114:4,44 [1] ) (Accepts:None) - Parent: Expression block at (114:4,44 [8] )
+Code span at (115:4,45 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (114:4,44 [8] )
+Markup span at (122:4,52 [4] ) (Accepts:None) - Parent: Tag block at (122:4,52 [4] )
+Markup span at (126:4,56 [2] ) (Accepts:None) - Parent: Markup block at (102:4,32 [26] )
+Code span at (128:5,0 [78] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] )
+Markup span at (206:8,12 [3] ) (Accepts:None) - Parent: Tag block at (206:8,12 [3] )
+Markup span at (209:8,15 [16] ) (Accepts:Any) - Parent: Markup block at (206:8,12 [25] )
+Markup span at (225:8,31 [4] ) (Accepts:None) - Parent: Tag block at (225:8,31 [4] )
+Markup span at (229:8,35 [2] ) (Accepts:None) - Parent: Markup block at (206:8,12 [25] )
+Code span at (231:9,0 [61] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] )
+Transition span at (292:11,12 [1] ) (Accepts:None) - Parent: Markup block at (292:11,12 [27] )
+MetaCode span at (293:11,13 [1] ) (Accepts:Any) - Parent: Markup block at (292:11,12 [27] )
+Markup span at (294:11,14 [14] ) (Accepts:Any) - Parent: Markup block at (292:11,12 [27] )
+Transition span at (308:11,28 [1] ) (Accepts:None) - Parent: Expression block at (308:11,28 [5] )
+Code span at (309:11,29 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (308:11,28 [5] )
+Markup span at (313:11,33 [6] ) (Accepts:None) - Parent: Markup block at (292:11,12 [27] )
+Code span at (319:12,0 [31] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] )
+Code span at (350:13,29 [1] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] )
+Code span at (351:13,30 [20] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] )
+Markup span at (371:13,50 [8] ) (Accepts:None) - Parent: Tag block at (371:13,50 [8] )
+Markup span at (379:13,58 [0] ) (Accepts:Any) - Parent: Markup block at (371:13,50 [27] )
+Transition span at (379:13,58 [1] ) (Accepts:None) - Parent: Expression block at (379:13,58 [8] )
+Code span at (380:13,59 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (379:13,58 [8] )
+Markup span at (387:13,66 [9] ) (Accepts:None) - Parent: Tag block at (387:13,66 [9] )
+Markup span at (396:13,75 [2] ) (Accepts:None) - Parent: Markup block at (371:13,50 [27] )
+Code span at (398:14,0 [7] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] )
+MetaCode span at (405:15,0 [3] ) (Accepts:None) - Parent: Directive block at (2:1,0 [406] )
+Markup span at (408:16,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [408] )
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.diag.txt
new file mode 100644
index 0000000000..f661098862
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.diag.txt
@@ -0,0 +1,4 @@
+(5,33): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
+(9,13): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
+(12,13): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
+(14,30): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.stree.txt
new file mode 100644
index 0000000000..03065213c0
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.stree.txt
@@ -0,0 +1,208 @@
+RazorDocument - [0..408)::408 - [LF@functions {LF string GetAnnouncmentText(string message)LF {LF if (message.Length > 0) Message: @message
LFLF if (message == null)LF // Nothing to renderLF Message was null
LFLF if (DateTime.Now.ToBinary() % 2 == 0)LF @: The time: @time
LFLF if (message != null) @@SomeGitHubUserName @messageLF }LF}LF]
+ MarkupBlock - [0..408)::408
+ MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any
+ NewLine;[LF];
+ CSharpCodeBlock - [2..408)::406
+ RazorDirective - [2..408)::406 - Directive:{functions;CodeBlock;Unrestricted} [RZ1008(102:4,32 [1] ), RZ1008(206:8,12 [1] ), RZ1008(292:11,12 [2] ), RZ1008(350:13,29 [2] )]
+ CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None
+ Transition;[@];
+ RazorDirectiveBody - [3..408)::405
+ RazorMetaCode - [3..12)::9 - Gen - SpanEditHandler;Accepts:None
+ Identifier;[functions];
+ CSharpCodeBlock - [12..408)::396
+ UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace
+ Whitespace;[ ];
+ RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd
+ LeftBrace;[{];
+ CSharpCodeBlock - [14..405)::391
+ CSharpStatementLiteral - [14..102)::88 - [LF string GetAnnouncmentText(string message)LF {LF if (message.Length > 0) ] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[string];
+ Whitespace;[ ];
+ Identifier;[GetAnnouncmentText];
+ LeftParenthesis;[(];
+ Keyword;[string];
+ Whitespace;[ ];
+ Identifier;[message];
+ RightParenthesis;[)];
+ NewLine;[LF];
+ Whitespace;[ ];
+ LeftBrace;[{];
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[if];
+ Whitespace;[ ];
+ LeftParenthesis;[(];
+ Identifier;[message];
+ Dot;[.];
+ Identifier;[Length];
+ Whitespace;[ ];
+ GreaterThan;[>];
+ Whitespace;[ ];
+ IntegerLiteral;[0];
+ RightParenthesis;[)];
+ Whitespace;[ ];
+ MarkupBlock - [102..128)::26
+ MarkupElement - [102..126)::24
+ MarkupStartTag - [102..105)::3 - [] - Gen - SpanEditHandler;Accepts:None
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [105..114)::9 - [Message: ] - Gen - SpanEditHandler;Accepts:Any
+ Text;[Message:];
+ Whitespace;[ ];
+ CSharpCodeBlock - [114..122)::8
+ CSharpImplicitExpression - [114..122)::8
+ CSharpTransition - [114..115)::1 - Gen - SpanEditHandler;Accepts:None
+ Transition;[@];
+ CSharpImplicitExpressionBody - [115..122)::7
+ CSharpCodeBlock - [115..122)::7
+ CSharpExpressionLiteral - [115..122)::7 - [message] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15
+ Identifier;[message];
+ MarkupEndTag - [122..126)::4 - [
] - Gen - SpanEditHandler;Accepts:None
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [126..128)::2 - [LF] - Gen - SpanEditHandler;Accepts:None
+ NewLine;[LF];
+ CSharpStatementLiteral - [128..206)::78 - [LF if (message == null)LF // Nothing to renderLF ] - Gen - SpanEditHandler;Accepts:Any
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[if];
+ Whitespace;[ ];
+ LeftParenthesis;[(];
+ Identifier;[message];
+ Whitespace;[ ];
+ Equals;[==];
+ Whitespace;[ ];
+ Keyword;[null];
+ RightParenthesis;[)];
+ NewLine;[LF];
+ Whitespace;[ ];
+ CSharpComment;[// Nothing to render];
+ NewLine;[LF];
+ Whitespace;[ ];
+ MarkupBlock - [206..231)::25
+ MarkupElement - [206..229)::23
+ MarkupStartTag - [206..209)::3 - [] - Gen - SpanEditHandler;Accepts:None
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [209..225)::16 - [Message was null] - Gen - SpanEditHandler;Accepts:Any
+ Text;[Message];
+ Whitespace;[ ];
+ Text;[was];
+ Whitespace;[ ];
+ Text;[null];
+ MarkupEndTag - [225..229)::4 - [
] - Gen - SpanEditHandler;Accepts:None
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [229..231)::2 - [LF] - Gen - SpanEditHandler;Accepts:None
+ NewLine;[LF];
+ CSharpStatementLiteral - [231..292)::61 - [LF if (DateTime.Now.ToBinary() % 2 == 0)LF ] - Gen - SpanEditHandler;Accepts:Any
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[if];
+ Whitespace;[ ];
+ LeftParenthesis;[(];
+ Identifier;[DateTime];
+ Dot;[.];
+ Identifier;[Now];
+ Dot;[.];
+ Identifier;[ToBinary];
+ LeftParenthesis;[(];
+ RightParenthesis;[)];
+ Whitespace;[ ];
+ Modulo;[%];
+ Whitespace;[ ];
+ IntegerLiteral;[2];
+ Whitespace;[ ];
+ Equals;[==];
+ Whitespace;[ ];
+ IntegerLiteral;[0];
+ RightParenthesis;[)];
+ NewLine;[LF];
+ Whitespace;[ ];
+ MarkupBlock - [292..319)::27
+ MarkupTransition - [292..293)::1 - Gen - SpanEditHandler;Accepts:None
+ Transition;[@];
+ RazorMetaCode - [293..294)::1 - Gen - SpanEditHandler;Accepts:Any
+ Colon;[:];
+ MarkupTextLiteral - [294..308)::14 - [ The time: ] - Gen - SpanEditHandler;Accepts:Any
+ Whitespace;[ ];
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ Text;[The];
+ Whitespace;[ ];
+ Text;[time:];
+ Whitespace;[ ];
+ CSharpCodeBlock - [308..313)::5
+ CSharpImplicitExpression - [308..313)::5
+ CSharpTransition - [308..309)::1 - Gen - SpanEditHandler;Accepts:None
+ Transition;[@];
+ CSharpImplicitExpressionBody - [309..313)::4
+ CSharpCodeBlock - [309..313)::4
+ CSharpExpressionLiteral - [309..313)::4 - [time] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15
+ Identifier;[time];
+ MarkupTextLiteral - [313..319)::6 - [
LF] - Gen - SpanEditHandler;Accepts:None
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ NewLine;[LF];
+ CSharpStatementLiteral - [319..350)::31 - [LF if (message != null) ] - Gen - SpanEditHandler;Accepts:Any
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[if];
+ Whitespace;[ ];
+ LeftParenthesis;[(];
+ Identifier;[message];
+ Whitespace;[ ];
+ NotEqual;[!=];
+ Whitespace;[ ];
+ Keyword;[null];
+ RightParenthesis;[)];
+ Whitespace;[ ];
+ CSharpEphemeralTextLiteral - [350..351)::1 - [@] - Gen - SpanEditHandler;Accepts:Any
+ Transition;[@];
+ CSharpStatementLiteral - [351..371)::20 - [@SomeGitHubUserName ] - Gen - SpanEditHandler;Accepts:Any
+ Transition;[@];
+ Identifier;[SomeGitHubUserName];
+ Whitespace;[ ];
+ MarkupBlock - [371..398)::27
+ MarkupElement - [371..396)::25
+ MarkupStartTag - [371..379)::8 - [] - Gen - SpanEditHandler;Accepts:None
+ OpenAngle;[<];
+ Text;[strong];
+ CloseAngle;[>];
+ MarkupTextLiteral - [379..379)::0 - [] - Gen - SpanEditHandler;Accepts:Any
+ Marker;[];
+ CSharpCodeBlock - [379..387)::8
+ CSharpImplicitExpression - [379..387)::8
+ CSharpTransition - [379..380)::1 - Gen - SpanEditHandler;Accepts:None
+ Transition;[@];
+ CSharpImplicitExpressionBody - [380..387)::7
+ CSharpCodeBlock - [380..387)::7
+ CSharpExpressionLiteral - [380..387)::7 - [message] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15
+ Identifier;[message];
+ MarkupEndTag - [387..396)::9 - [] - Gen - SpanEditHandler;Accepts:None
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[strong];
+ CloseAngle;[>];
+ MarkupTextLiteral - [396..398)::2 - [LF] - Gen - SpanEditHandler;Accepts:None
+ NewLine;[LF];
+ CSharpStatementLiteral - [398..405)::7 - [ }LF] - Gen - SpanEditHandler;Accepts:Any
+ Whitespace;[ ];
+ RightBrace;[}];
+ NewLine;[LF];
+ RazorMetaCode - [405..408)::3 - Gen - SpanEditHandler;Accepts:None
+ RightBrace;[}];
+ NewLine;[LF];
+ MarkupTextLiteral - [408..408)::0 - [] - Gen - SpanEditHandler;Accepts:Any
+ Marker;[];
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.diag.txt
index 9dba2e6078..bfae619d1f 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.diag.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.diag.txt
@@ -1,12 +1,3 @@
(1,2): Error RZ1035: Missing close angle for tag helper 'p'.
(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing.
-(1,21): Error RZ1008: Expected a "{" but found a "<". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed:
-
-@if(isLoggedIn)
- Hello, @user
-
-Instead, wrap the contents of the block in "{}":
-
-@if(isLoggedIn) {
- Hello, @user
-}
+(1,21): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}".