Skip to content

Commit

Permalink
[automated] Merge branch 'release/3.0' => 'master' (#968)
Browse files Browse the repository at this point in the history
* Give "builder" a less discoverable name

Fixes #12991

* Fixup tests

* [Blazor][Fixes #12933] Remove the need for a custom property when resolving static web assets from referenced projects

* Removes the need for a custom property when resolving static web assets from referenced projects
* Rolls in several improvements suggested by the MSBuild folks to improve performance.
  • Loading branch information
dotnet-maestro-bot authored and javiercn committed Aug 14, 2019
1 parent da76fa2 commit 2d13d28
Show file tree
Hide file tree
Showing 646 changed files with 2,305 additions and 2,282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private void __RazorDirectiveTokenHelpers__() {
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
{
__o =
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: (1238:35,13 [15] )
Generated Location: (1240:35,13 [15] )
|this.ToString()|

Source Location: (79:3,5 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml)
|string.Format("{0}", "Hello")|
Generated Location: (1435:43,6 [29] )
Generated Location: (1437:43,6 [29] )
|string.Format("{0}", "Hello")|

Source Location: (132:6,12 [37] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml)
|
void IDisposable.Dispose(){ }
|
Generated Location: (1687:52,12 [37] )
Generated Location: (1689:52,12 [37] )
|
void IDisposable.Dispose(){ }
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace __GeneratedComponent
public class AspNetCore_d3c3d6059615673cb46fc4974164d61eabadb890 : Microsoft.AspNetCore.Components.ComponentBase, IDisposable
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
{
builder.OpenElement(0, "div");
builder.AddAttribute(1, "class",
__builder.OpenElement(0, "div");
__builder.AddAttribute(1, "class",
#nullable restore
#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml"
this.ToString()
Expand All @@ -24,8 +24,8 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin
#line hidden
#nullable disable
);
builder.AddMarkupContent(2, "\r\n Hello world\r\n ");
builder.AddContent(3,
__builder.AddMarkupContent(2, "\r\n Hello world\r\n ");
__builder.AddContent(3,
#nullable restore
#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml"
string.Format("{0}", "Hello")
Expand All @@ -34,8 +34,8 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin
#line hidden
#nullable disable
);
builder.AddMarkupContent(4, "\r\n");
builder.CloseElement();
__builder.AddMarkupContent(4, "\r\n");
__builder.CloseElement();
}
#pragma warning restore 1998
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,12 @@ public override void WriteComponent(CodeRenderingContext context, ComponentInter
{
// Writes something like:
//
// builder.OpenComponent<MyComponent>(0);
// builder.AddAttribute(1, "Foo", ...);
// builder.AddAttribute(2, "ChildContent", ...);
// builder.SetKey(someValue);
// builder.AddElementCapture(3, (__value) => _field = __value);
// builder.CloseComponent();
// __builder.OpenComponent<MyComponent>(0);
// __builder.AddAttribute(1, "Foo", ...);
// __builder.AddAttribute(2, "ChildContent", ...);
// __builder.SetKey(someValue);
// __builder.AddElementCapture(3, (__value) => _field = __value);
// __builder.CloseComponent();

foreach (var typeArgument in node.TypeArguments)
{
Expand Down Expand Up @@ -375,7 +375,7 @@ public override void WriteComponent(CodeRenderingContext context, ComponentInter
// the component on the builder. We generate a method elsewhere, and then pass all of the information
// to that method. We pass in all of the attribute values + the sequence numbers.
//
// __Blazor.MyComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, ..., 2, ..., 3, ....);
// __Blazor.MyComponent.TypeInference.CreateMyComponent_0(__builder, 0, 1, ..., 2, ..., 3, ....);

// Preserve order of attributes + splats
var attributes = node.Children.Where(s =>
Expand Down Expand Up @@ -676,9 +676,9 @@ public override void WriteComponentChildContent(CodeRenderingContext context, Co

// Writes something like:
//
// builder.AddAttribute(1, "ChildContent", (RenderFragment)((__builder73) => { ... }));
// __builder.AddAttribute(1, "ChildContent", (RenderFragment)((__builder73) => { ... }));
// OR
// builder.AddAttribute(1, "ChildContent", (RenderFragment<Person>)((person) => (__builder73) => { ... }));
// __builder.AddAttribute(1, "ChildContent", (RenderFragment<Person>)((person) => (__builder73) => { ... }));
BeginWriteAttribute(context.CodeWriter, node.AttributeName);
context.CodeWriter.Write($"({node.TypeName})(");

Expand Down Expand Up @@ -775,7 +775,7 @@ public override void WriteSetKey(CodeRenderingContext context, SetKeyIntermediat

// Looks like:
//
// builder.SetKey(_keyValue);
// __builder.SetKey(_keyValue);

var codeWriter = context.CodeWriter;

Expand Down Expand Up @@ -811,7 +811,7 @@ public override void WriteSplat(CodeRenderingContext context, SplatIntermediateN

// Looks like:
//
// builder.AddMultipleAttributes(2, ...);
// __builder.AddMultipleAttributes(2, ...);
context.CodeWriter.WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.AddMultipleAttributes}");
context.CodeWriter.Write("-1");
context.CodeWriter.WriteParameterSeparator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected override void OnDocumentStructureCreated(
method.Parameters.Clear();
method.Parameters.Add(new MethodParameter()
{
ParameterName = "builder",
ParameterName = ComponentsApi.RenderTreeBuilder.BuilderParameter,
TypeName = ComponentsApi.RenderTreeBuilder.FullTypeName,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public override void WriteComponentTypeInferenceMethod(CodeRenderingContext cont
//
// Looks like:
//
// public static void CreateFoo_0<T1, T2>(RenderTreeBuilder builder, int seq, int __seq0, T1 __arg0, int __seq1, global::System.Collections.Generic.List<T2> __arg1, int __seq2, string __arg2)
// public static void CreateFoo_0<T1, T2>(RenderTreeBuilder __builder, int seq, int __seq0, T1 __arg0, int __seq1, global::System.Collections.Generic.List<T2> __arg1, int __seq2, string __arg2)
// {
// builder.OpenComponent<Foo<T1, T2>>();
// builder.AddAttribute(__seq0, "Attr0", __arg0);
Expand All @@ -88,7 +88,8 @@ public override void WriteComponentTypeInferenceMethod(CodeRenderingContext cont
writer.Write("(");
writer.Write("global::");
writer.Write(ComponentsApi.RenderTreeBuilder.FullTypeName);
writer.Write(" builder");
writer.Write(" ");
writer.Write(ComponentsApi.RenderTreeBuilder.BuilderParameter);
writer.Write(", ");
writer.Write("int seq");

Expand Down Expand Up @@ -118,8 +119,8 @@ public override void WriteComponentTypeInferenceMethod(CodeRenderingContext cont

writer.WriteLine("{");

// builder.OpenComponent<TComponent>(42);
context.CodeWriter.Write("builder");
// _builder.OpenComponent<TComponent>(42);
context.CodeWriter.Write(ComponentsApi.RenderTreeBuilder.BuilderParameter);
context.CodeWriter.Write(".");
context.CodeWriter.Write(ComponentsApi.RenderTreeBuilder.OpenComponent);
context.CodeWriter.Write("<");
Expand All @@ -136,7 +137,7 @@ public override void WriteComponentTypeInferenceMethod(CodeRenderingContext cont
{
if (child is ComponentAttributeIntermediateNode attribute)
{
context.CodeWriter.WriteStartInstanceMethodInvocation("builder", ComponentsApi.RenderTreeBuilder.AddAttribute);
context.CodeWriter.WriteStartInstanceMethodInvocation(ComponentsApi.RenderTreeBuilder.BuilderParameter, ComponentsApi.RenderTreeBuilder.AddAttribute);
context.CodeWriter.Write(parameters[index].seqName);
context.CodeWriter.Write(", ");

Expand All @@ -149,7 +150,7 @@ public override void WriteComponentTypeInferenceMethod(CodeRenderingContext cont
}
else if (child is SplatIntermediateNode)
{
context.CodeWriter.WriteStartInstanceMethodInvocation("builder", ComponentsApi.RenderTreeBuilder.AddMultipleAttributes);
context.CodeWriter.WriteStartInstanceMethodInvocation(ComponentsApi.RenderTreeBuilder.BuilderParameter, ComponentsApi.RenderTreeBuilder.AddMultipleAttributes);
context.CodeWriter.Write(parameters[index].seqName);
context.CodeWriter.Write(", ");

Expand All @@ -161,7 +162,7 @@ public override void WriteComponentTypeInferenceMethod(CodeRenderingContext cont

foreach (var childContent in node.Component.ChildContents)
{
context.CodeWriter.WriteStartInstanceMethodInvocation("builder", ComponentsApi.RenderTreeBuilder.AddAttribute);
context.CodeWriter.WriteStartInstanceMethodInvocation(ComponentsApi.RenderTreeBuilder.BuilderParameter, ComponentsApi.RenderTreeBuilder.AddAttribute);
context.CodeWriter.Write(parameters[index].seqName);
context.CodeWriter.Write(", ");

Expand All @@ -176,7 +177,7 @@ public override void WriteComponentTypeInferenceMethod(CodeRenderingContext cont

foreach (var setKey in node.Component.SetKeys)
{
context.CodeWriter.WriteStartInstanceMethodInvocation("builder", ComponentsApi.RenderTreeBuilder.SetKey);
context.CodeWriter.WriteStartInstanceMethodInvocation(ComponentsApi.RenderTreeBuilder.BuilderParameter, ComponentsApi.RenderTreeBuilder.SetKey);
context.CodeWriter.Write(parameters[index].parameterName);
context.CodeWriter.WriteEndMethodInvocation();

Expand All @@ -185,7 +186,7 @@ public override void WriteComponentTypeInferenceMethod(CodeRenderingContext cont

foreach (var capture in node.Component.Captures)
{
context.CodeWriter.WriteStartInstanceMethodInvocation("builder", capture.IsComponentCapture ? ComponentsApi.RenderTreeBuilder.AddComponentReferenceCapture : ComponentsApi.RenderTreeBuilder.AddElementReferenceCapture);
context.CodeWriter.WriteStartInstanceMethodInvocation(ComponentsApi.RenderTreeBuilder.BuilderParameter, capture.IsComponentCapture ? ComponentsApi.RenderTreeBuilder.AddComponentReferenceCapture : ComponentsApi.RenderTreeBuilder.AddElementReferenceCapture);
context.CodeWriter.Write(parameters[index].seqName);
context.CodeWriter.Write(", ");

Expand All @@ -196,7 +197,7 @@ public override void WriteComponentTypeInferenceMethod(CodeRenderingContext cont
index++;
}

context.CodeWriter.WriteInstanceMethodInvocation("builder", ComponentsApi.RenderTreeBuilder.CloseComponent);
context.CodeWriter.WriteInstanceMethodInvocation(ComponentsApi.RenderTreeBuilder.BuilderParameter, ComponentsApi.RenderTreeBuilder.CloseComponent);

writer.WriteLine("}");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,14 @@ public override void WriteComponent(CodeRenderingContext context, ComponentInter
//
// Writes something like:
//
// builder.OpenComponent<MyComponent>(0);
// builder.AddAttribute(1, "Foo", ...);
// builder.AddAttribute(2, "ChildContent", ...);
// builder.SetKey(someValue);
// builder.AddElementCapture(3, (__value) => _field = __value);
// builder.CloseComponent();

// builder.OpenComponent<TComponent>(42);
// _builder.OpenComponent<MyComponent>(0);
// _builder.AddAttribute(1, "Foo", ...);
// _builder.AddAttribute(2, "ChildContent", ...);
// _builder.SetKey(someValue);
// _builder.AddElementCapture(3, (__value) => _field = __value);
// _builder.CloseComponent();

// _builder.OpenComponent<TComponent>(42);
context.CodeWriter.Write(_scopeStack.BuilderVarName);
context.CodeWriter.Write(".");
context.CodeWriter.Write(ComponentsApi.RenderTreeBuilder.OpenComponent);
Expand Down Expand Up @@ -383,7 +383,7 @@ public override void WriteComponent(CodeRenderingContext context, ComponentInter
context.RenderNode(capture);
}

// builder.CloseComponent();
// _builder.CloseComponent();
context.CodeWriter.Write(_scopeStack.BuilderVarName);
context.CodeWriter.Write(".");
context.CodeWriter.Write(ComponentsApi.RenderTreeBuilder.CloseComponent);
Expand Down Expand Up @@ -502,7 +502,7 @@ public override void WriteComponentAttribute(CodeRenderingContext context, Compo
throw new ArgumentNullException(nameof(node));
}

// builder.AddAttribute(1, "Foo", 42);
// _builder.AddAttribute(1, "Foo", 42);
context.CodeWriter.Write(_scopeStack.BuilderVarName);
context.CodeWriter.Write(".");
context.CodeWriter.Write(ComponentsApi.RenderTreeBuilder.AddAttribute);
Expand Down Expand Up @@ -656,9 +656,9 @@ public override void WriteComponentChildContent(CodeRenderingContext context, Co

// Writes something like:
//
// builder.AddAttribute(1, "ChildContent", (RenderFragment)((__builder73) => { ... }));
// _builder.AddAttribute(1, "ChildContent", (RenderFragment)((__builder73) => { ... }));
// OR
// builder.AddAttribute(1, "ChildContent", (RenderFragment<Person>)((person) => (__builder73) => { ... }));
// _builder.AddAttribute(1, "ChildContent", (RenderFragment<Person>)((person) => (__builder73) => { ... }));
BeginWriteAttribute(context.CodeWriter, node.AttributeName);
context.CodeWriter.Write($"({node.TypeName})(");

Expand Down Expand Up @@ -716,7 +716,7 @@ public override void WriteSetKey(CodeRenderingContext context, SetKeyIntermediat
{
// Looks like:
//
// builder.SetKey(_keyValue);
// _builder.SetKey(_keyValue);

var codeWriter = context.CodeWriter;

Expand Down Expand Up @@ -752,7 +752,7 @@ public override void WriteSplat(CodeRenderingContext context, SplatIntermediateN

// Looks like:
//
// builder.AddMultipleAttributes(2, ...);
// _builder.AddMultipleAttributes(2, ...);
context.CodeWriter.WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.AddMultipleAttributes}");
context.CodeWriter.Write((_sourceSequence++).ToString());
context.CodeWriter.WriteParameterSeparator();
Expand Down Expand Up @@ -790,9 +790,9 @@ public override void WriteReferenceCapture(CodeRenderingContext context, Referen
{
// Looks like:
//
// builder.AddComponentReferenceCapture(2, (__value) = { _field = (MyComponent)__value; });
// _builder.AddComponentReferenceCapture(2, (__value) = { _field = (MyComponent)__value; });
// OR
// builder.AddElementReferenceCapture(2, (__value) = { _field = (ElementReference)__value; });
// _builder.AddElementReferenceCapture(2, (__value) = { _field = (ElementReference)__value; });
var codeWriter = context.CodeWriter;

var methodName = node.IsComponentCapture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public static class RenderTreeBuilder
{
public static readonly string FullTypeName = "Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder";

public static readonly string BuilderParameter = "__builder";

public static readonly string OpenElement = nameof(OpenElement);

public static readonly string CloseElement = nameof(CloseElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class ScopeStack
private readonly Stack<ScopeEntry> _stack = new Stack<ScopeEntry>();
private int _builderVarNumber = 1;

public string BuilderVarName { get; private set; } = "builder";
public string BuilderVarName { get; private set; } = ComponentsApi.RenderTreeBuilder.BuilderParameter;

public void OpenComponentScope(CodeRenderingContext context, string name, string parameterName)
{
Expand Down Expand Up @@ -61,8 +61,8 @@ private void OffsetBuilderVarNumber(int delta)
{
_builderVarNumber += delta;
BuilderVarName = _builderVarNumber == 1
? "builder"
: $"builder{_builderVarNumber}";
? ComponentsApi.RenderTreeBuilder.BuilderParameter
: $"{ComponentsApi.RenderTreeBuilder.BuilderParameter}{_builderVarNumber}";
}

private class ScopeEntry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public void SingleLineControlFlowStatements_InCodeDirective()
@using Microsoft.AspNetCore.Components.Rendering;
@code {
void RenderChildComponent(RenderTreeBuilder builder)
void RenderChildComponent(RenderTreeBuilder __builder)
{
var output = string.Empty;
if (builder == null) output = ""Builder is null!"";
if (__builder == null) output = ""Builder is null!"";
else output = ""Builder is not null!"";
<p>Output: @output</p>
}
Expand All @@ -56,7 +56,7 @@ public void SingleLineControlFlowStatements_InCodeBlock()
@{
var output = string.Empty;
if (builder == null) output = ""Builder is null!"";
if (__builder == null) output = ""Builder is null!"";
else output = ""Builder is not null!"";
<p>Output: @output</p>
}");
Expand Down Expand Up @@ -85,10 +85,10 @@ public class MyComponent : ComponentBase
var generated = CompileToCSharp(@"
@using Microsoft.AspNetCore.Components.Rendering;
@{ RenderChildComponent(builder); }
@{ RenderChildComponent(__builder); }
@code {
void RenderChildComponent(RenderTreeBuilder builder)
void RenderChildComponent(RenderTreeBuilder __builder)
{
<MyComponent />
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ namespace Test
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
{
}
#pragma warning restore 1998
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private void __RazorDirectiveTokenHelpers__() {
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
{
__o = Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Microsoft.AspNetCore.Components.UIMouseEventArgs>(this,
#nullable restore
Expand Down
Loading

0 comments on commit 2d13d28

Please sign in to comment.