diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs index ca6bcc9bbc..3b665ecc41 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs @@ -84,11 +84,39 @@ namespace Microsoft.AspNet.Razor.Test.Generator [InlineData("LayoutDirective")] [InlineData("ConditionalAttributes")] [InlineData("ResolveUrl")] + [InlineData("Await")] public void CSharpCodeGeneratorCorrectlyGeneratesRunTimeCode(string testType) { RunTest(testType); } + [Fact] + public void CSharpCodeGeneratorCorrectlyGeneratesMappingsForAwait() + { + RunTest("Await", + "Await.DesignTime", + designTimeMode: true, + tabTest: TabTest.Tabs, + expectedDesignTimePragmas: new List() + { + BuildLineMapping(12, 0, 12, 173, 9, 0, 76), + BuildLineMapping(192, 9, 39, 637, 30, 15, 11), + BuildLineMapping(247, 10, 38, 750, 35, 14, 11), + BuildLineMapping(304, 11, 39, 832, 40, 12, 14), + BuildLineMapping(371, 12, 46, 919, 46, 13, 1), + BuildLineMapping(376, 12, 51, 1027, 52, 18, 11), + BuildLineMapping(391, 12, 66, 1115, 57, 18, 1), + BuildLineMapping(448, 13, 49, 1224, 63, 19, 5), + BuildLineMapping(578, 18, 42, 1332, 68, 15, 15), + BuildLineMapping(640, 19, 41, 1452, 73, 17, 22), + BuildLineMapping(711, 20, 42, 1545, 78, 12, 39), + BuildLineMapping(806, 21, 49, 1657, 84, 13, 1), + BuildLineMapping(811, 21, 54, 1765, 90, 18, 27), + BuildLineMapping(842, 21, 85, 1873, 95, 22, 1), + BuildLineMapping(902, 22, 52, 1982, 101, 19, 19) + }); + } + [Fact] public void CSharpCodeGeneratorCorrectlyGeneratesMappingsForSimpleUnspacedIf() { diff --git a/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.csproj b/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.csproj index 04843123c8..3a9ef968e0 100644 --- a/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.csproj +++ b/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.csproj @@ -115,6 +115,8 @@ + + @@ -317,6 +319,7 @@ + \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Await.DesignTime.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Await.DesignTime.cs new file mode 100644 index 0000000000..6865e8ed83 --- /dev/null +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Await.DesignTime.cs @@ -0,0 +1,108 @@ +namespace TestOutput +{ + using System; + using System.Threading.Tasks; + + public class Await + { + private static object @__o; +#line 1 "Await.cshtml" + + public async Task Foo() + { + return "Bar"; + } + +#line default +#line hidden + private void @__RazorDesignTimeHelpers__() + { + #pragma warning disable 219 + #pragma warning restore 219 + } + #line hidden + public Await() + { + } + + public override async Task ExecuteAsync() + { +#line 1 "------------------------------------------" + __o = await Foo(); + +#line default +#line hidden +#line 1 "------------------------------------------" + __o = await Foo(); + +#line default +#line hidden +#line 12 "Await.cshtml" + await Foo(); + +#line default +#line hidden + +#line 13 "Await.cshtml" + + +#line default +#line hidden + +#line 1 "------------------------------------------" + __o = await Foo(); + +#line default +#line hidden +#line 13 "Await.cshtml" + + +#line default +#line hidden + +#line 1 "------------------------------------------" + __o = await; + +#line default +#line hidden +#line 1 "------------------------------------------" + __o = await Foo(1, 2); + +#line default +#line hidden +#line 1 "------------------------------------------" + __o = await Foo("bob", true); + +#line default +#line hidden +#line 21 "Await.cshtml" + await Foo(something, hello: "world"); + +#line default +#line hidden + +#line 22 "Await.cshtml" + + +#line default +#line hidden + +#line 1 "------------------------------------------" + __o = await Foo(boolValue: false); + +#line default +#line hidden +#line 22 "Await.cshtml" + + +#line default +#line hidden + +#line 1 "------------------------------------------" + __o = await ("wrrronggg"); + +#line default +#line hidden + } + } +} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Await.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Await.cs new file mode 100644 index 0000000000..f1b07a694a --- /dev/null +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Await.cs @@ -0,0 +1,129 @@ +namespace TestOutput +{ + using System; + using System.Threading.Tasks; + + public class Await + { +#line 1 "Await.cshtml" + + public async Task Foo() + { + return "Bar"; + } + +#line default +#line hidden + #line hidden + public Await() + { + } + + public override async Task ExecuteAsync() + { + WriteLiteral("\r\n
\r\n

Basic Asynchronous Expression Test

\r\n

Basic Asynch" + +"ronous Expression: "); + Write( +#line 10 "Await.cshtml" + await Foo() + +#line default +#line hidden + ); + + WriteLiteral("

\r\n

Basic Asynchronous Template: "); + Write( +#line 11 "Await.cshtml" + await Foo() + +#line default +#line hidden + ); + + WriteLiteral("

\r\n

Basic Asynchronous Statement: "); +#line 12 "Await.cshtml" + await Foo(); + +#line default +#line hidden + + WriteLiteral("

\r\n

Basic Asynchronous Statement Nested: "); + Write( +#line 13 "Await.cshtml" + await Foo() + +#line default +#line hidden + ); + + WriteLiteral(" "); +#line 13 "Await.cshtml" + + +#line default +#line hidden + + WriteLiteral("

\r\n

Basic Incomplete Asynchronous Statement: "); + Write( +#line 14 "Await.cshtml" + await + +#line default +#line hidden + ); + + WriteLiteral("

\r\n
\r\n\r\n
\r\n

Advanced Asynchronous Expression Test

" + +"\r\n

Advanced Asynchronous Expression: "); + Write( +#line 19 "Await.cshtml" + await Foo(1, 2) + +#line default +#line hidden + ); + + WriteLiteral("

\r\n

Advanced Asynchronous Template: "); + Write( +#line 20 "Await.cshtml" + await Foo("bob", true) + +#line default +#line hidden + ); + + WriteLiteral("

\r\n

Advanced Asynchronous Statement: "); +#line 21 "Await.cshtml" + await Foo(something, hello: "world"); + +#line default +#line hidden + + WriteLiteral("

\r\n

Advanced Asynchronous Statement Nested: "); + Write( +#line 22 "Await.cshtml" + await Foo(boolValue: false) + +#line default +#line hidden + ); + + WriteLiteral(" "); +#line 22 "Await.cshtml" + + +#line default +#line hidden + + WriteLiteral("

\r\n

Advanced Incomplete Asynchronous Statement: "); + Write( +#line 23 "Await.cshtml" + await ("wrrronggg") + +#line default +#line hidden + ); + + WriteLiteral("

\r\n
"); + } + } +} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/Await.cshtml b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/Await.cshtml new file mode 100644 index 0000000000..5c034a224f --- /dev/null +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/Await.cshtml @@ -0,0 +1,24 @@ +@functions { + public async Task Foo() + { + return "Bar"; + } +} + +
+

Basic Asynchronous Expression Test

+

Basic Asynchronous Expression: @await Foo()

+

Basic Asynchronous Template: @(await Foo())

+

Basic Asynchronous Statement: @{ await Foo(); }

+

Basic Asynchronous Statement Nested: @{ @await Foo() }

+

Basic Incomplete Asynchronous Statement: @await

+
+ +
+

Advanced Asynchronous Expression Test

+

Advanced Asynchronous Expression: @await Foo(1, 2)

+

Advanced Asynchronous Template: @(await Foo("bob", true))

+

Advanced Asynchronous Statement: @{ await Foo(something, hello: "world"); }

+

Advanced Asynchronous Statement Nested: @{ @await Foo(boolValue: false) }

+

Advanced Incomplete Asynchronous Statement: @await ("wrrronggg")

+
\ No newline at end of file