From 8a8e14465338decfc08887a36828f8f2f0848fea Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 28 Mar 2019 12:46:36 +0000 Subject: [PATCH] Remove base.BuildRenderTree calls (dotnet/aspnetcore-tooling#368) \n\nCommit migrated from https://github.com/dotnet/aspnetcore-tooling/commit/bcc77db7624cdef30023f293285d00c0a73b05bc --- .../BasicComponent_DesignTime.codegen.cs | 1 - .../BasicComponent_DesignTime.ir.txt | 2 -- .../BasicComponent_DesignTime.mappings.txt | 6 +++--- .../BasicComponent_Runtime.codegen.cs | 1 - .../BasicComponent_Runtime.ir.txt | 2 -- .../Components/ComponentDocumentClassifierPass.cs | 14 -------------- .../src/Components/ComponentWhitespacePass.cs | 2 +- 7 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.codegen.cs index 27c275d0ed..054b128eb5 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.codegen.cs @@ -30,7 +30,6 @@ IDisposable __typeHelper = default(IDisposable); #pragma warning disable 1998 protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) { - base.BuildRenderTree(builder); #nullable restore #line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml" __o = this.ToString(); diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.ir.txt index c05976fe90..a08e83f549 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.ir.txt @@ -15,8 +15,6 @@ Document - CSharpCode - IntermediateToken - - CSharp - #pragma warning restore 0414 MethodDeclaration - - protected override - void - BuildRenderTree - CSharpCode - - IntermediateToken - - CSharp - base.BuildRenderTree(builder); MarkupElement - (25:1,0 [91] BasicComponent.cshtml) - div HtmlAttribute - (29:1,4 [25] BasicComponent.cshtml) - class=" - " CSharpExpressionAttributeValue - (37:1,12 [16] BasicComponent.cshtml) - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.mappings.txt index 6547f5a986..aff2ce3f1b 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.mappings.txt +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.mappings.txt @@ -5,19 +5,19 @@ Generated Location: (641:17,0 [11] ) Source Location: (38:1,13 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml) |this.ToString()| -Generated Location: (1275:35,13 [15] ) +Generated Location: (1231:34,13 [15] ) |this.ToString()| Source Location: (79:3,5 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml) |string.Format("{0}", "Hello")| -Generated Location: (1458:42,6 [29] ) +Generated Location: (1414:41,6 [29] ) |string.Format("{0}", "Hello")| Source Location: (132:6,12 [37] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml) | void IDisposable.Dispose(){ } | -Generated Location: (1710:51,12 [37] ) +Generated Location: (1666:50,12 [37] ) | void IDisposable.Dispose(){ } | diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.codegen.cs index 37e1ce772c..b660af0498 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.codegen.cs @@ -14,7 +14,6 @@ namespace __GeneratedComponent #pragma warning disable 1998 protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) { - base.BuildRenderTree(builder); builder.OpenElement(0, "div"); builder.AddAttribute(1, "class", this.ToString()); builder.AddContent(2, "\r\n Hello world\r\n "); diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.ir.txt index ab41d275db..885d9ddd37 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.ir.txt @@ -7,8 +7,6 @@ Document - UsingDirective - (102:4,1 [37] ) - Microsoft.AspNetCore.Components ClassDeclaration - - public - AspNetCore_d3c3d6059615673cb46fc4974164d61eabadb890 - Microsoft.AspNetCore.Components.ComponentBase - IDisposable MethodDeclaration - - protected override - void - BuildRenderTree - CSharpCode - - IntermediateToken - - CSharp - base.BuildRenderTree(builder); MarkupElement - (25:1,0 [91] BasicComponent.cshtml) - div HtmlAttribute - (29:1,4 [25] BasicComponent.cshtml) - class=" - " CSharpExpressionAttributeValue - (37:1,12 [16] BasicComponent.cshtml) - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs index 37d44227df..8b5ad5061d 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs @@ -13,7 +13,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Components internal class ComponentDocumentClassifierPass : DocumentClassifierPassBase { public static readonly string ComponentDocumentKind = "component.1.0"; - private static readonly object BuildRenderTreeBaseCallAnnotation = new object(); /// /// The fallback value of the root namespace. Only used if the fallback root namespace @@ -116,20 +115,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components ParameterName = "builder", TypeName = ComponentsApi.RenderTreeBuilder.FullTypeName, }); - - // We need to call the 'base' method as the first statement. - var callBase = new CSharpCodeIntermediateNode(); - callBase.Annotations.Add(BuildRenderTreeBaseCallAnnotation, true); - callBase.Children.Add(new IntermediateToken - { - Kind = TokenKind.CSharp, - Content = $"base.{ComponentsApi.ComponentBase.BuildRenderTree}(builder);" - }); - method.Children.Insert(0, callBase); } } - - internal static bool IsBuildRenderTreeBaseCall(CSharpCodeIntermediateNode node) - => node.Annotations[BuildRenderTreeBaseCallAnnotation] != null; } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentWhitespacePass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentWhitespacePass.cs index 2713f96de8..08eec3ae80 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentWhitespacePass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentWhitespacePass.cs @@ -78,7 +78,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components case CSharpCodeIntermediateNode codeIntermediateNode: shouldRemoveNode = false; - shouldContinueIteration = ComponentDocumentClassifierPass.IsBuildRenderTreeBaseCall(codeIntermediateNode); + shouldContinueIteration = false; break; default: