Rename AddComponentElement->OpenComponentElement for clarity (you have to close it too)

This commit is contained in:
Steve Sanderson 2018-01-24 15:26:27 -08:00
parent 2469558410
commit 9e90ff3689
5 changed files with 21 additions and 21 deletions

View File

@ -232,7 +232,7 @@ namespace Microsoft.Blazor.Build.Core.RazorCompilation.Engine
if (TryGetComponentTypeNameFromTagName(tagNameOriginalCase, out var componentTypeName)) if (TryGetComponentTypeNameFromTagName(tagNameOriginalCase, out var componentTypeName))
{ {
codeWriter codeWriter
.WriteStartMethodInvocation($"{builderVarName}.{nameof(RenderTreeBuilder.AddComponentElement)}<{componentTypeName}>") .WriteStartMethodInvocation($"{builderVarName}.{nameof(RenderTreeBuilder.OpenComponentElement)}<{componentTypeName}>")
.Write((_sourceSequence++).ToString()) .Write((_sourceSequence++).ToString())
.WriteEndMethodInvocation(); .WriteEndMethodInvocation();
} }

View File

@ -130,7 +130,7 @@ namespace Microsoft.Blazor.RenderTree
/// </summary> /// </summary>
/// <typeparam name="TComponent">The type of the child component.</typeparam> /// <typeparam name="TComponent">The type of the child component.</typeparam>
/// <param name="sequence">An integer that represents the position of the instruction in the source code.</param> /// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
public void AddComponentElement<TComponent>(int sequence) where TComponent : IComponent public void OpenComponentElement<TComponent>(int sequence) where TComponent : IComponent
{ {
// Currently, child components can't have further grandchildren of their own, so it would // Currently, child components can't have further grandchildren of their own, so it would
// technically be possible to skip their CloseElement calls and not track them in _openElementIndices. // technically be possible to skip their CloseElement calls and not track them in _openElementIndices.

View File

@ -253,13 +253,13 @@ namespace Microsoft.Blazor.Test
// Act // Act
builder.OpenElement(10, "parent"); // 0: <parent> builder.OpenElement(10, "parent"); // 0: <parent>
builder.AddComponentElement<TestComponent>(11); // 1: <testcomponent builder.OpenComponentElement<TestComponent>(11); // 1: <testcomponent
builder.AddAttribute(12, "child1attribute1", "A"); // 2: child1attribute1="A" builder.AddAttribute(12, "child1attribute1", "A"); // 2: child1attribute1="A"
builder.AddAttribute(13, "child1attribute2", "B"); // 3: child1attribute2="B" /> builder.AddAttribute(13, "child1attribute2", "B"); // 3: child1attribute2="B">
builder.CloseElement(); builder.CloseElement(); // </testcomponent>
builder.AddComponentElement<TestComponent>(14); // 4: <testcomponent builder.OpenComponentElement<TestComponent>(14); // 4: <testcomponent
builder.AddAttribute(15, "child2attribute", "C"); // 5: child2attribute="C" /> builder.AddAttribute(15, "child2attribute", "C"); // 5: child2attribute="C">
builder.CloseElement(); builder.CloseElement(); // </testcomponent>
builder.CloseElement(); // </parent> builder.CloseElement(); // </parent>
// Assert // Assert

View File

@ -43,7 +43,7 @@ namespace Microsoft.Blazor.Test
builder.AddAttribute(1, "My attribute", "My value"); builder.AddAttribute(1, "My attribute", "My value");
builder.CloseElement(); builder.CloseElement();
}, },
builder => builder.AddComponentElement<FakeComponent>(0) builder => builder.OpenComponentElement<FakeComponent>(0)
}.Select(x => new object[] { x }); }.Select(x => new object[] { x });
[Fact] [Fact]
@ -350,8 +350,8 @@ namespace Microsoft.Blazor.Test
var oldTree = new RenderTreeBuilder(renderer); var oldTree = new RenderTreeBuilder(renderer);
var newTree = new RenderTreeBuilder(renderer); var newTree = new RenderTreeBuilder(renderer);
var diff = new RenderTreeDiffComputer(renderer); var diff = new RenderTreeDiffComputer(renderer);
oldTree.AddComponentElement<FakeComponent>(123); oldTree.OpenComponentElement<FakeComponent>(123);
newTree.AddComponentElement<FakeComponent2>(123); newTree.OpenComponentElement<FakeComponent2>(123);
// Act // Act
var result = diff.ApplyNewRenderTreeVersion(oldTree.GetNodes(), newTree.GetNodes()); var result = diff.ApplyNewRenderTreeVersion(oldTree.GetNodes(), newTree.GetNodes());
@ -641,9 +641,9 @@ namespace Microsoft.Blazor.Test
oldTree.CloseElement(); // </container> oldTree.CloseElement(); // </container>
newTree.AddText(10, "text1"); // 0: text1 newTree.AddText(10, "text1"); // 0: text1
newTree.OpenElement(11, "container"); // 1: <container> newTree.OpenElement(11, "container"); // 1: <container>
newTree.AddComponentElement<FakeComponent>(12); // 2: <FakeComponent> newTree.OpenComponentElement<FakeComponent>(12); // 2: <FakeComponent>
newTree.CloseElement(); // </FakeComponent> newTree.CloseElement(); // </FakeComponent>
newTree.AddComponentElement<FakeComponent2>(13); // 3: <FakeComponent2> newTree.OpenComponentElement<FakeComponent2>(13); // 3: <FakeComponent2>
newTree.CloseElement(); // </FakeComponent2> newTree.CloseElement(); // </FakeComponent2>
newTree.CloseElement(); // </container> newTree.CloseElement(); // </container>
@ -684,16 +684,16 @@ namespace Microsoft.Blazor.Test
var diff = new RenderTreeDiffComputer(renderer); var diff = new RenderTreeDiffComputer(renderer);
oldTree.AddText(10, "text1"); // 0: text1 oldTree.AddText(10, "text1"); // 0: text1
oldTree.OpenElement(11, "container"); // 1: <container> oldTree.OpenElement(11, "container"); // 1: <container>
oldTree.AddComponentElement<FakeComponent>(12); // 2: <FakeComponent> oldTree.OpenComponentElement<FakeComponent>(12); // 2: <FakeComponent>
oldTree.CloseElement(); // </FakeComponent> oldTree.CloseElement(); // </FakeComponent>
oldTree.AddComponentElement<FakeComponent2>(13); // 3: <FakeComponent2> oldTree.OpenComponentElement<FakeComponent2>(13); // 3: <FakeComponent2>
oldTree.CloseElement(); // </FakeComponent2> oldTree.CloseElement(); // </FakeComponent2>
oldTree.CloseElement(); // </container oldTree.CloseElement(); // </container
newTree.AddText(10, "text1"); // 0: text1 newTree.AddText(10, "text1"); // 0: text1
newTree.OpenElement(11, "container"); // 1: <container> newTree.OpenElement(11, "container"); // 1: <container>
newTree.AddComponentElement<FakeComponent>(12); // 2: <FakeComponent> newTree.OpenComponentElement<FakeComponent>(12); // 2: <FakeComponent>
newTree.CloseElement(); // </FakeComponent> newTree.CloseElement(); // </FakeComponent>
newTree.AddComponentElement<FakeComponent2>(13); // 3: <FakeComponent2> newTree.OpenComponentElement<FakeComponent2>(13); // 3: <FakeComponent2>
newTree.CloseElement(); // </FakeComponent2> newTree.CloseElement(); // </FakeComponent2>
newTree.CloseElement(); // </container newTree.CloseElement(); // </container

View File

@ -44,7 +44,7 @@ namespace Microsoft.Blazor.Test
var component = new TestComponent(builder => var component = new TestComponent(builder =>
{ {
builder.AddText(0, "Hello"); builder.AddText(0, "Hello");
builder.AddComponentElement<MessageComponent>(1); builder.OpenComponentElement<MessageComponent>(1);
builder.CloseElement(); builder.CloseElement();
}); });
@ -95,7 +95,7 @@ namespace Microsoft.Blazor.Test
var renderer = new TestRenderer(); var renderer = new TestRenderer();
var parentComponent = new TestComponent(builder => var parentComponent = new TestComponent(builder =>
{ {
builder.AddComponentElement<MessageComponent>(0); builder.OpenComponentElement<MessageComponent>(0);
builder.CloseElement(); builder.CloseElement();
}); });
var parentComponentId = renderer.AssignComponentId(parentComponent); var parentComponentId = renderer.AssignComponentId(parentComponent);
@ -154,7 +154,7 @@ namespace Microsoft.Blazor.Test
var renderer = new TestRenderer(); var renderer = new TestRenderer();
var parentComponent = new TestComponent(builder => var parentComponent = new TestComponent(builder =>
{ {
builder.AddComponentElement<EventComponent>(0); builder.OpenComponentElement<EventComponent>(0);
builder.CloseElement(); builder.CloseElement();
}); });
var parentComponentId = renderer.AssignComponentId(parentComponent); var parentComponentId = renderer.AssignComponentId(parentComponent);
@ -310,7 +310,7 @@ namespace Microsoft.Blazor.Test
var component = new TestComponent(builder => var component = new TestComponent(builder =>
{ {
builder.AddText(0, message); builder.AddText(0, message);
builder.AddComponentElement<MessageComponent>(1); builder.OpenComponentElement<MessageComponent>(1);
builder.CloseElement(); builder.CloseElement();
}); });