From 196f3bae1fa43fb2c18c8ffce03a4a5440a42380 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Mon, 14 Aug 2017 12:43:56 -0700 Subject: [PATCH] Fix ModelExpression's in section directive blocks. - Changed `SectionDirectivePass` to move non-token body nodes from the original `DirectiveIntermediateNode` to the `SectionIntermediateNode`. By doing this there's no longer dual references of `SectionIntermediateNode` bodies. - Added MVC tests for current and 1_X extensions. #1614 --- .../Extensions/SectionDirectivePass.cs | 4 +- .../CodeGenerationIntegrationTest.cs | 18 ++++- .../Sections.cshtml | 7 +- .../Sections_DesignTime.codegen.cs | 21 +++++- .../Sections_DesignTime.ir.txt | 52 +++++++++----- .../Sections_DesignTime.mappings.txt | 23 +++++-- .../Sections_Runtime.codegen.cs | 62 +++++++++++++++-- .../Sections_Runtime.ir.txt | 68 ++++++++++++++----- .../CodeGenerationIntegrationTest.cs | 9 ++- .../Sections.cshtml | 7 +- .../Sections_DesignTime.codegen.cs | 21 +++++- .../Sections_DesignTime.ir.txt | 52 +++++++++----- .../Sections_DesignTime.mappings.txt | 23 +++++-- 13 files changed, 291 insertions(+), 76 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionDirectivePass.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionDirectivePass.cs index d0844d3ab..ea2ad395f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionDirectivePass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/SectionDirectivePass.cs @@ -35,9 +35,11 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte } } - for (; i < directive.Node.Children.Count; i++) + while (i != directive.Node.Children.Count) { + // Move non-token children over to the section node so we don't have double references to children nodes. section.Children.Add(directive.Node.Children[i]); + directive.Node.Children.RemoveAt(i); } directive.InsertAfter(section); diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/IntegrationTests/CodeGenerationIntegrationTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/IntegrationTests/CodeGenerationIntegrationTest.cs index 4b78caab0..0f6a1a5b1 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/IntegrationTests/CodeGenerationIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/IntegrationTests/CodeGenerationIntegrationTest.cs @@ -109,7 +109,14 @@ public void Basic_Runtime() [Fact] public void Sections_Runtime() { - var references = CreateCompilationReferences(CurrentMvcShim); + var references = CreateCompilationReferences(CurrentMvcShim, appCode: $@" +using Microsoft.AspNetCore.Mvc.ViewFeatures; + +public class InputTestTagHelper : {typeof(TagHelper).FullName} +{{ + public ModelExpression For {{ get; set; }} +}} +"); RunRuntimeTest(references); } @@ -351,7 +358,14 @@ public void Basic_DesignTime() [Fact] public void Sections_DesignTime() { - var references = CreateCompilationReferences(CurrentMvcShim); + var references = CreateCompilationReferences(CurrentMvcShim, appCode: $@" +using Microsoft.AspNetCore.Mvc.ViewFeatures; + +public class InputTestTagHelper : {typeof(TagHelper).FullName} +{{ + public ModelExpression For {{ get; set; }} +}} +"); RunDesignTimeTest(references); } diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml index 81f73f2ca..7438788ff 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml @@ -1,4 +1,8 @@ -@{ +@model DateTime + +@addTagHelper "InputTestTagHelper, AppCode" + +@{ Layout = "_SectionTestLayout.cshtml"; } @@ -6,4 +10,5 @@ @section Section1 {
This is in Section 1
+ } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs index 72c84fbab..d0551e436 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs @@ -11,11 +11,20 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { + private global::InputTestTagHelper __InputTestTagHelper; #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { ((System.Action)(() => { +DateTime __typeHelper = default(DateTime); + } + ))(); + ((System.Action)(() => { +global::System.Object __typeHelper = "InputTestTagHelper, AppCode"; + } + ))(); + ((System.Action)(() => { global::System.Object Section1 = null; } ))(); @@ -27,13 +36,19 @@ private void __RazorDirectiveTokenHelpers__() { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() { -#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" Layout = "_SectionTestLayout.cshtml"; #line default #line hidden DefineSection("Section1", async() => { + __InputTestTagHelper = CreateTagHelper(); +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Date); + +#line default +#line hidden } ); } @@ -47,7 +62,7 @@ private void __RazorDirectiveTokenHelpers__() { [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt index f6c25ee51..061c04e61 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt @@ -8,7 +8,9 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html @@ -23,7 +25,9 @@ Document - DirectiveToken - (617:12,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor - DirectiveToken - (86:6,9 [8] Sections.cshtml) - Section1 + DirectiveToken - (7:0,7 [8] Sections.cshtml) - DateTime + DirectiveToken - (33:2,14 [29] Sections.cshtml) - "InputTestTagHelper, AppCode" + DirectiveToken - (152:10,9 [8] Sections.cshtml) - Section1 CSharpCode - IntermediateToken - - CSharp - #pragma warning disable 0414 CSharpCode - @@ -31,21 +35,37 @@ Document - CSharpCode - IntermediateToken - - CSharp - #pragma warning restore 0414 MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync - CSharpCode - (2:0,2 [46] Sections.cshtml) - IntermediateToken - (2:0,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n - HtmlContent - (51:3,0 [26] Sections.cshtml) - IntermediateToken - (51:3,0 [2] Sections.cshtml) - Html - \n - IntermediateToken - (53:4,0 [5] Sections.cshtml) - Html -
- IntermediateToken - (58:4,5 [9] Sections.cshtml) - Html - Some body - IntermediateToken - (67:4,14 [6] Sections.cshtml) - Html -
- IntermediateToken - (73:4,20 [4] Sections.cshtml) - Html - \n\n + HtmlContent - (17:1,0 [2] Sections.cshtml) + IntermediateToken - (17:1,0 [2] Sections.cshtml) - Html - \n + HtmlContent - (62:2,43 [4] Sections.cshtml) + IntermediateToken - (62:2,43 [4] Sections.cshtml) - Html - \n\n + CSharpCode - (68:4,2 [46] Sections.cshtml) + IntermediateToken - (68:4,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n + HtmlContent - (117:7,0 [26] Sections.cshtml) + IntermediateToken - (117:7,0 [2] Sections.cshtml) - Html - \n + IntermediateToken - (119:8,0 [5] Sections.cshtml) - Html -
+ IntermediateToken - (124:8,5 [9] Sections.cshtml) - Html - Some body + IntermediateToken - (133:8,14 [6] Sections.cshtml) - Html -
+ IntermediateToken - (139:8,20 [4] Sections.cshtml) - Html - \n\n Section - - Section1 - HtmlContent - (96:6,19 [39] Sections.cshtml) - IntermediateToken - (96:6,19 [6] Sections.cshtml) - Html - \n - IntermediateToken - (102:7,4 [5] Sections.cshtml) - Html -
- IntermediateToken - (107:7,9 [20] Sections.cshtml) - Html - This is in Section 1 - IntermediateToken - (127:7,29 [6] Sections.cshtml) - Html -
- IntermediateToken - (133:7,35 [2] Sections.cshtml) - Html - \n + HtmlContent - (162:10,19 [43] Sections.cshtml) + IntermediateToken - (162:10,19 [6] Sections.cshtml) - Html - \n + IntermediateToken - (168:11,4 [5] Sections.cshtml) - Html -
+ IntermediateToken - (173:11,9 [20] Sections.cshtml) - Html - This is in Section 1 + IntermediateToken - (193:11,29 [6] Sections.cshtml) - Html -
+ IntermediateToken - (199:11,35 [6] Sections.cshtml) - Html - \n + TagHelper - (205:12,4 [25] Sections.cshtml) - input-test - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTestTagHelper + DefaultTagHelperProperty - (222:12,21 [4] Sections.cshtml) - for - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression InputTestTagHelper.For - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - ModelExpressionProvider.CreateModelExpression(ViewData, __model => + IntermediateToken - - CSharp - __model. + IntermediateToken - (222:12,21 [4] Sections.cshtml) - CSharp - Date + IntermediateToken - - CSharp - ) + DefaultTagHelperExecute - + HtmlContent - (230:12,29 [2] Sections.cshtml) + IntermediateToken - (230:12,29 [2] Sections.cshtml) - Html - \n Inject - Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt index 5a6cfe78f..c2b3302c4 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt @@ -1,14 +1,29 @@ -Source Location: (86:6,9 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|DateTime| +Generated Location: (742:19,0 [8] ) +|DateTime| + +Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|"InputTestTagHelper, AppCode"| +Generated Location: (883:23,37 [29] ) +|"InputTestTagHelper, AppCode"| + +Source Location: (152:10,9 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |Section1| -Generated Location: (697:18,22 [8] ) +Generated Location: (997:27,22 [8] ) |Section1| -Source Location: (2:0,2 [46] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +Source Location: (68:4,2 [46] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) | Layout = "_SectionTestLayout.cshtml"; | -Generated Location: (1132:30,2 [46] ) +Generated Location: (1432:39,2 [46] ) | Layout = "_SectionTestLayout.cshtml"; | +Source Location: (222:12,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|Date| +Generated Location: (1835:47,102 [4] ) +|Date| + diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs index 7221f0899..ba56f0430 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs @@ -1,4 +1,4 @@ -#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c7635d54fa83ccf10a29be2f0a7b56d1703398a7" +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "dbec91fd88a09c6a2e35b5adedb3f8ab8e3ae486" // #pragma warning disable 1591 [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml))] @@ -12,23 +12,71 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { + #line hidden + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext __tagHelperExecutionContext; + private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner __tagHelperRunner = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner(); + private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager __backed__tagHelperScopeManager = null; + private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager __tagHelperScopeManager + { + get + { + if (__backed__tagHelperScopeManager == null) + { + __backed__tagHelperScopeManager = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager(StartTagHelperWritingScope, EndTagHelperWritingScope); + } + return __backed__tagHelperScopeManager; + } + } + private global::InputTestTagHelper __InputTestTagHelper; #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() { -#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + BeginContext(17, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(64, 2, true); + WriteLiteral("\r\n"); + EndContext(); +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" Layout = "_SectionTestLayout.cshtml"; #line default #line hidden - BeginContext(51, 26, true); + BeginContext(117, 26, true); WriteLiteral("\r\n
Some body
\r\n\r\n"); EndContext(); DefineSection("Section1", async() => { - BeginContext(96, 39, true); - WriteLiteral("\r\n
This is in Section 1
\r\n"); + BeginContext(162, 43, true); + WriteLiteral("\r\n
This is in Section 1
\r\n "); + EndContext(); + BeginContext(205, 25, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input-test", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __InputTestTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTestTagHelper); +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Date); + +#line default +#line hidden + __tagHelperExecutionContext.AddTagHelperAttribute("for", __InputTestTagHelper.For, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + EndContext(); + BeginContext(230, 2, true); + WriteLiteral("\r\n"); EndContext(); } ); @@ -43,7 +91,7 @@ public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_c [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt index 8e13c694a..4a4f3ce12 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt @@ -9,29 +9,63 @@ Document - UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync - CSharpCode - (2:0,2 [46] Sections.cshtml) - IntermediateToken - (2:0,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n CSharpCode - - IntermediateToken - - CSharp - BeginContext(51, 26, true); - HtmlContent - (51:3,0 [26] Sections.cshtml) - IntermediateToken - (51:3,0 [2] Sections.cshtml) - Html - \n - IntermediateToken - (53:4,0 [5] Sections.cshtml) - Html -
- IntermediateToken - (58:4,5 [9] Sections.cshtml) - Html - Some body - IntermediateToken - (67:4,14 [6] Sections.cshtml) - Html -
- IntermediateToken - (73:4,20 [4] Sections.cshtml) - Html - \n\n + IntermediateToken - - CSharp - BeginContext(17, 2, true); + HtmlContent - (17:1,0 [2] Sections.cshtml) + IntermediateToken - (17:1,0 [2] Sections.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(64, 2, true); + HtmlContent - (64:3,0 [2] Sections.cshtml) + IntermediateToken - (64:3,0 [2] Sections.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - (68:4,2 [46] Sections.cshtml) + IntermediateToken - (68:4,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n + CSharpCode - + IntermediateToken - - CSharp - BeginContext(117, 26, true); + HtmlContent - (117:7,0 [26] Sections.cshtml) + IntermediateToken - (117:7,0 [2] Sections.cshtml) - Html - \n + IntermediateToken - (119:8,0 [5] Sections.cshtml) - Html -
+ IntermediateToken - (124:8,5 [9] Sections.cshtml) - Html - Some body + IntermediateToken - (133:8,14 [6] Sections.cshtml) - Html -
+ IntermediateToken - (139:8,20 [4] Sections.cshtml) - Html - \n\n CSharpCode - IntermediateToken - - CSharp - EndContext(); Section - - Section1 CSharpCode - - IntermediateToken - - CSharp - BeginContext(96, 39, true); - HtmlContent - (96:6,19 [39] Sections.cshtml) - IntermediateToken - (96:6,19 [6] Sections.cshtml) - Html - \n - IntermediateToken - (102:7,4 [5] Sections.cshtml) - Html -
- IntermediateToken - (107:7,9 [20] Sections.cshtml) - Html - This is in Section 1 - IntermediateToken - (127:7,29 [6] Sections.cshtml) - Html -
- IntermediateToken - (133:7,35 [2] Sections.cshtml) - Html - \n + IntermediateToken - - CSharp - BeginContext(162, 43, true); + HtmlContent - (162:10,19 [43] Sections.cshtml) + IntermediateToken - (162:10,19 [6] Sections.cshtml) - Html - \n + IntermediateToken - (168:11,4 [5] Sections.cshtml) - Html -
+ IntermediateToken - (173:11,9 [20] Sections.cshtml) - Html - This is in Section 1 + IntermediateToken - (193:11,29 [6] Sections.cshtml) - Html -
+ IntermediateToken - (199:11,35 [6] Sections.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(205, 25, false); + TagHelper - (205:12,4 [25] Sections.cshtml) - input-test - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTestTagHelper + DefaultTagHelperProperty - (222:12,21 [4] Sections.cshtml) - for - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression InputTestTagHelper.For - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - ModelExpressionProvider.CreateModelExpression(ViewData, __model => + IntermediateToken - - CSharp - __model. + IntermediateToken - (222:12,21 [4] Sections.cshtml) - CSharp - Date + IntermediateToken - - CSharp - ) + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(230, 2, true); + HtmlContent - (230:12,29 [2] Sections.cshtml) + IntermediateToken - (230:12,29 [2] Sections.cshtml) - Html - \n CSharpCode - IntermediateToken - - CSharp - EndContext(); Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/IntegrationTests/CodeGenerationIntegrationTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/IntegrationTests/CodeGenerationIntegrationTest.cs index e7908a734..6910a8428 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/IntegrationTests/CodeGenerationIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/IntegrationTests/CodeGenerationIntegrationTest.cs @@ -103,7 +103,14 @@ public void Basic_DesignTime() [Fact] public void Sections_DesignTime() { - var references = CreateCompilationReferences(CurrentMvcShim); + var references = CreateCompilationReferences(CurrentMvcShim, appCode: $@" +using Microsoft.AspNetCore.Mvc.ViewFeatures; + +public class InputTestTagHelper : {typeof(TagHelper).FullName} +{{ + public ModelExpression For {{ get; set; }} +}} +"); RunDesignTimeTest(references); } diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml index 81f73f2ca..7438788ff 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml @@ -1,4 +1,8 @@ -@{ +@model DateTime + +@addTagHelper "InputTestTagHelper, AppCode" + +@{ Layout = "_SectionTestLayout.cshtml"; } @@ -6,4 +10,5 @@ @section Section1 {
This is in Section 1
+ } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs index 771d84593..fd3c971a7 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs @@ -11,11 +11,20 @@ namespace AspNetCore using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; - public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage { + private global::InputTestTagHelper __InputTestTagHelper; #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { ((System.Action)(() => { +DateTime __typeHelper = default(DateTime); + } + ))(); + ((System.Action)(() => { +global::System.Object __typeHelper = "InputTestTagHelper, AppCode"; + } + ))(); + ((System.Action)(() => { global::System.Object Section1 = null; } ))(); @@ -27,13 +36,19 @@ private void __RazorDirectiveTokenHelpers__() { #pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() { -#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" Layout = "_SectionTestLayout.cshtml"; #line default #line hidden DefineSection("Section1", async(__razor_section_writer) => { + __InputTestTagHelper = CreateTagHelper(); +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Date); + +#line default +#line hidden } ); } @@ -47,7 +62,7 @@ private void __RazorDirectiveTokenHelpers__() { [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] - public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } } } #pragma warning restore 1591 diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt index c4456d30c..7ab3c05ed 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt @@ -8,7 +8,9 @@ Document - UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures - ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper DesignTimeDirective - DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (294:7,71 [4] ) - Html @@ -21,7 +23,9 @@ Document - DirectiveToken - (507:11,8 [70] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider DirectiveToken - (578:11,79 [23] ) - ModelExpressionProvider DirectiveToken - (617:12,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor - DirectiveToken - (86:6,9 [8] Sections.cshtml) - Section1 + DirectiveToken - (7:0,7 [8] Sections.cshtml) - DateTime + DirectiveToken - (33:2,14 [29] Sections.cshtml) - "InputTestTagHelper, AppCode" + DirectiveToken - (152:10,9 [8] Sections.cshtml) - Section1 CSharpCode - IntermediateToken - - CSharp - #pragma warning disable 0414 CSharpCode - @@ -29,21 +33,37 @@ Document - CSharpCode - IntermediateToken - - CSharp - #pragma warning restore 0414 MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync - CSharpCode - (2:0,2 [46] Sections.cshtml) - IntermediateToken - (2:0,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n - HtmlContent - (51:3,0 [26] Sections.cshtml) - IntermediateToken - (51:3,0 [2] Sections.cshtml) - Html - \n - IntermediateToken - (53:4,0 [5] Sections.cshtml) - Html -
- IntermediateToken - (58:4,5 [9] Sections.cshtml) - Html - Some body - IntermediateToken - (67:4,14 [6] Sections.cshtml) - Html -
- IntermediateToken - (73:4,20 [4] Sections.cshtml) - Html - \n\n + HtmlContent - (17:1,0 [2] Sections.cshtml) + IntermediateToken - (17:1,0 [2] Sections.cshtml) - Html - \n + HtmlContent - (62:2,43 [4] Sections.cshtml) + IntermediateToken - (62:2,43 [4] Sections.cshtml) - Html - \n\n + CSharpCode - (68:4,2 [46] Sections.cshtml) + IntermediateToken - (68:4,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n + HtmlContent - (117:7,0 [26] Sections.cshtml) + IntermediateToken - (117:7,0 [2] Sections.cshtml) - Html - \n + IntermediateToken - (119:8,0 [5] Sections.cshtml) - Html -
+ IntermediateToken - (124:8,5 [9] Sections.cshtml) - Html - Some body + IntermediateToken - (133:8,14 [6] Sections.cshtml) - Html -
+ IntermediateToken - (139:8,20 [4] Sections.cshtml) - Html - \n\n Section - - Section1 - HtmlContent - (96:6,19 [39] Sections.cshtml) - IntermediateToken - (96:6,19 [6] Sections.cshtml) - Html - \n - IntermediateToken - (102:7,4 [5] Sections.cshtml) - Html -
- IntermediateToken - (107:7,9 [20] Sections.cshtml) - Html - This is in Section 1 - IntermediateToken - (127:7,29 [6] Sections.cshtml) - Html -
- IntermediateToken - (133:7,35 [2] Sections.cshtml) - Html - \n + HtmlContent - (162:10,19 [43] Sections.cshtml) + IntermediateToken - (162:10,19 [6] Sections.cshtml) - Html - \n + IntermediateToken - (168:11,4 [5] Sections.cshtml) - Html -
+ IntermediateToken - (173:11,9 [20] Sections.cshtml) - Html - This is in Section 1 + IntermediateToken - (193:11,29 [6] Sections.cshtml) - Html -
+ IntermediateToken - (199:11,35 [6] Sections.cshtml) - Html - \n + TagHelper - (205:12,4 [25] Sections.cshtml) - input-test - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTestTagHelper + DefaultTagHelperProperty - (222:12,21 [4] Sections.cshtml) - for - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression InputTestTagHelper.For - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - ModelExpressionProvider.CreateModelExpression(ViewData, __model => + IntermediateToken - - CSharp - __model. + IntermediateToken - (222:12,21 [4] Sections.cshtml) - CSharp - Date + IntermediateToken - - CSharp - ) + DefaultTagHelperExecute - + HtmlContent - (230:12,29 [2] Sections.cshtml) + IntermediateToken - (230:12,29 [2] Sections.cshtml) - Html - \n Inject - Inject - Inject - diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt index 5a6cfe78f..5e120c830 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt @@ -1,14 +1,29 @@ -Source Location: (86:6,9 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|DateTime| +Generated Location: (742:19,0 [8] ) +|DateTime| + +Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|"InputTestTagHelper, AppCode"| +Generated Location: (883:23,37 [29] ) +|"InputTestTagHelper, AppCode"| + +Source Location: (152:10,9 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) |Section1| -Generated Location: (697:18,22 [8] ) +Generated Location: (997:27,22 [8] ) |Section1| -Source Location: (2:0,2 [46] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +Source Location: (68:4,2 [46] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) | Layout = "_SectionTestLayout.cshtml"; | -Generated Location: (1132:30,2 [46] ) +Generated Location: (1432:39,2 [46] ) | Layout = "_SectionTestLayout.cshtml"; | +Source Location: (222:12,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|Date| +Generated Location: (1857:47,102 [4] ) +|Date| +