Remove base.BuildRenderTree calls (dotnet/aspnetcore-tooling#368)

\n\nCommit migrated from bcc77db762
This commit is contained in:
Steve Sanderson 2019-03-28 12:46:36 +00:00 committed by GitHub
parent 8eee2d5bc4
commit 8a8e144653
7 changed files with 4 additions and 24 deletions

View File

@ -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();

View File

@ -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) -

View File

@ -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(){ }
|

View File

@ -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 ");

View File

@ -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) -

View File

@ -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();
/// <summary>
/// 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;
}
}

View File

@ -78,7 +78,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
case CSharpCodeIntermediateNode codeIntermediateNode:
shouldRemoveNode = false;
shouldContinueIteration = ComponentDocumentClassifierPass.IsBuildRenderTreeBaseCall(codeIntermediateNode);
shouldContinueIteration = false;
break;
default: