Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked at the parser yet (and might not be able to understand it anyway 😛) but is it worth adding test coverage for a class defined inside a @code block, which has a method/property, which has markup?

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private static void AssertDefaultPhases(RazorProjectEngine engine)
phase => Assert.IsType<DefaultRazorSyntaxTreePhase>(phase),
phase => Assert.IsType<DefaultRazorTagHelperContextDiscoveryPhase>(phase),
phase => Assert.IsType<DefaultRazorIntermediateNodeLoweringPhase>(phase),
phase => Assert.IsType<DefaultRazorMarkupSplitPhase>(phase),
phase => Assert.IsType<DefaultTagHelperResolutionPhase>(phase),
phase => Assert.IsType<DefaultRazorTagHelperRewritePhase>(phase),
phase => Assert.IsType<DefaultRazorDocumentClassifierPhase>(phase),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
[0000] AddMarkupContent("<h1 TestCssScope>Element with no attributes</h1>\r\n")
[0000] OpenElement("li")
[0001] AddAttribute("data-index", i)
[0001] OpenElement("parent")
[0002] AddAttribute("TestCssScope")
[0002] AddAttribute("with-attributes", "yes")
[0003] AddAttribute("with-csharp-attribute-value", 123)
[0003] AddContent("Something ")
[0004] AddAttribute("TestCssScope")
[0004] AddContent(i)
[0005] AddMarkupContent("<child TestCssScope></child>\r\n ")
[0006] AddMarkupContent("<child has multiple attributes=\"some with values\" TestCssScope>With text</child>\r\n ")
[0007] OpenComponent<global::Test.TemplatedComponent>()
Expand All @@ -25,4 +20,9 @@
[0019] AddAttribute("another-attr", "Another attr value")
[0020] AddAttribute("value", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( myVariable ))
[0021] AddAttribute("onchange", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => myVariable = __value, myVariable))
[0022] AddAttribute("TestCssScope")
[0022] AddAttribute("TestCssScope")
[0023] OpenElement("li")
[0024] AddAttribute("data-index", i)
[0025] AddAttribute("TestCssScope")
[0026] AddContent("Something ")
[0027] AddContent(i)
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,52 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.

}
#pragma warning restore 1998
#nullable restore
#line (21,1)-(26,1) "x:\dir\subdir\Test\TestComponent.cshtml"

void MethodRenderingMarkup(RenderTreeBuilder __builder)
{
for (var i = 0; i < 10; i++)
{

#line default
#line hidden
#nullable disable

__builder.OpenElement(23, "li");
__builder.AddAttribute(24, "data-index",
#nullable restore
#line (26,29)-(26,30) "x:\dir\subdir\Test\TestComponent.cshtml"
i

#line default
#line hidden
#nullable disable
);
__builder.AddAttribute(25, "TestCssScope");
__builder.AddContent(26, "Something ");
#nullable restore
#line (26,42)-(26,43) 25 "x:\dir\subdir\Test\TestComponent.cshtml"
__builder.AddContent(27, i

#line default
#line hidden
#nullable disable
);
__builder.CloseElement();
#nullable restore
#line (27,1)-(33,1) "x:\dir\subdir\Test\TestComponent.cshtml"
}

System.GC.KeepAlive(myElementReference);
System.GC.KeepAlive(myComponentReference);
System.GC.KeepAlive(myVariable);
}

#line default
#line hidden
#nullable disable

}
}
#pragma warning restore 1591
Original file line number Diff line number Diff line change
Expand Up @@ -27,50 +27,25 @@ public partial class TestComponent : global::Microsoft.AspNetCore.Components.Com
#nullable disable
{
#nullable restore
#line (17,8)-(26,1) "x:\dir\subdir\Test\TestComponent.cshtml"
#line (17,8)-(19,1) "x:\dir\subdir\Test\TestComponent.cshtml"

ElementReference myElementReference;
TemplatedComponent myComponentReference;
string myVariable;

void MethodRenderingMarkup(RenderTreeBuilder __builder)
{
for (var i = 0; i < 10; i++)
{

#line default
#line hidden
#nullable disable

__builder.OpenElement(0, "li");
__builder.AddAttribute(1, "data-index",
#nullable restore
#line (26,29)-(26,30) "x:\dir\subdir\Test\TestComponent.cshtml"
i
#line (19,1)-(20,1) "x:\dir\subdir\Test\TestComponent.cshtml"
TemplatedComponent myComponentReference;

#line default
#line hidden
#nullable disable
);
__builder.AddAttribute(2, "TestCssScope");
__builder.AddContent(3, "Something ");
#nullable restore
#line (26,42)-(26,43) 24 "x:\dir\subdir\Test\TestComponent.cshtml"
__builder.AddContent(4, i

#line default
#line hidden
#nullable disable
);
__builder.CloseElement();
#nullable restore
#line (27,1)-(33,1) "x:\dir\subdir\Test\TestComponent.cshtml"
}

System.GC.KeepAlive(myElementReference);
System.GC.KeepAlive(myComponentReference);
System.GC.KeepAlive(myVariable);
}
#line (20,1)-(21,1) "x:\dir\subdir\Test\TestComponent.cshtml"
string myVariable;

#line default
#line hidden
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,26 @@ Source Location: (45:1,1 [47] x:\dir\subdir\Test\TestComponent.cshtml)
Generated Location: (524:18,0 [47] )
|using Microsoft.AspNetCore.Components.Rendering|

Source Location: (651:16,7 [233] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (651:16,7 [44] x:\dir\subdir\Test\TestComponent.cshtml)
|
ElementReference myElementReference;
TemplatedComponent myComponentReference;
string myVariable;

void MethodRenderingMarkup(RenderTreeBuilder __builder)
{
for (var i = 0; i < 10; i++)
{
|
Generated Location: (869:30,0 [233] )
Generated Location: (869:30,0 [44] )
|
ElementReference myElementReference;
TemplatedComponent myComponentReference;
string myVariable;

void MethodRenderingMarkup(RenderTreeBuilder __builder)
{
for (var i = 0; i < 10; i++)
{
|

Source Location: (912:25,28 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|i|
Generated Location: (1329:48,0 [1] )
|i|

Source Location: (925:25,41 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|i|
Generated Location: (1605:58,24 [1] )
|i|

Source Location: (933:26,0 [164] x:\dir\subdir\Test\TestComponent.cshtml)
| }

System.GC.KeepAlive(myElementReference);
System.GC.KeepAlive(myComponentReference);
System.GC.KeepAlive(myVariable);
}
Source Location: (695:18,0 [46] x:\dir\subdir\Test\TestComponent.cshtml)
| TemplatedComponent myComponentReference;
|
Generated Location: (1047:39,0 [46] )
| TemplatedComponent myComponentReference;
|
Generated Location: (1787:67,0 [164] )
| }

System.GC.KeepAlive(myElementReference);
System.GC.KeepAlive(myComponentReference);
System.GC.KeepAlive(myVariable);
}
Source Location: (741:19,0 [24] x:\dir\subdir\Test\TestComponent.cshtml)
| string myVariable;
|
Generated Location: (1227:47,0 [24] )
| string myVariable;
|

Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,45 @@ Generated Location: (4078:108,0 [3] )
|}
|

Source Location: (765:20,0 [119] x:\dir\subdir\Test\TestComponent.cshtml)
|
void MethodRenderingMarkup(RenderTreeBuilder __builder)
{
for (var i = 0; i < 10; i++)
{
|
Generated Location: (4264:118,0 [119] )
|
void MethodRenderingMarkup(RenderTreeBuilder __builder)
{
for (var i = 0; i < 10; i++)
{
|

Source Location: (912:25,28 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|i|
Generated Location: (4612:132,0 [1] )
|i|

Source Location: (925:25,41 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|i|
Generated Location: (4891:142,25 [1] )
|i|

Source Location: (933:26,0 [164] x:\dir\subdir\Test\TestComponent.cshtml)
| }

System.GC.KeepAlive(myElementReference);
System.GC.KeepAlive(myComponentReference);
System.GC.KeepAlive(myVariable);
}
|
Generated Location: (5073:151,0 [164] )
| }

System.GC.KeepAlive(myElementReference);
System.GC.KeepAlive(myComponentReference);
System.GC.KeepAlive(myVariable);
}
|

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,69 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.
{
}
#pragma warning restore 1998
#nullable restore
#line (2,8)-(5,1) "x:\dir\subdir\Test\TestComponent.cshtml"

void MyMethod(RenderTreeBuilder __builder)
{

#line default
#line hidden
#nullable disable

__builder.AddContent(0, " ");
__builder.OpenElement(1, "ul");
__builder.AddMarkupContent(2, "\r\n");
#nullable restore
#line (6,1)-(6,13) "x:\dir\subdir\Test\TestComponent.cshtml"


#line default
#line hidden
#nullable disable

#nullable restore
#line (6,14)-(8,1) "x:\dir\subdir\Test\TestComponent.cshtml"
for (var i = 0; i < 100; i++)
{

#line default
#line hidden
#nullable disable

__builder.AddContent(3, " ");
__builder.OpenElement(4, "li");
__builder.AddMarkupContent(5, "\r\n ");
#nullable restore
#line (9,22)-(9,23) 24 "x:\dir\subdir\Test\TestComponent.cshtml"
__builder.AddContent(6, i

#line default
#line hidden
#nullable disable
);
__builder.AddMarkupContent(7, "\r\n ");
__builder.CloseElement();
__builder.AddMarkupContent(8, "\r\n");
#nullable restore
#line (11,1)-(12,1) "x:\dir\subdir\Test\TestComponent.cshtml"
}

#line default
#line hidden
#nullable disable

__builder.AddContent(9, " ");
__builder.CloseElement();
__builder.AddMarkupContent(10, "\r\n");
#nullable restore
#line (13,1)-(14,1) "x:\dir\subdir\Test\TestComponent.cshtml"
}

#line default
#line hidden
#nullable disable

}
}
#pragma warning restore 1591
Original file line number Diff line number Diff line change
Expand Up @@ -20,69 +20,6 @@ namespace Test
public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase
#nullable disable
{
#nullable restore
#line (2,8)-(5,1) "x:\dir\subdir\Test\TestComponent.cshtml"

void MyMethod(RenderTreeBuilder __builder)
{

#line default
#line hidden
#nullable disable

__builder.AddContent(0, " ");
__builder.OpenElement(1, "ul");
__builder.AddMarkupContent(2, "\r\n");
#nullable restore
#line (6,1)-(6,13) "x:\dir\subdir\Test\TestComponent.cshtml"


#line default
#line hidden
#nullable disable

#nullable restore
#line (6,14)-(8,1) "x:\dir\subdir\Test\TestComponent.cshtml"
for (var i = 0; i < 100; i++)
{

#line default
#line hidden
#nullable disable

__builder.AddContent(3, " ");
__builder.OpenElement(4, "li");
__builder.AddMarkupContent(5, "\r\n ");
#nullable restore
#line (9,22)-(9,23) 24 "x:\dir\subdir\Test\TestComponent.cshtml"
__builder.AddContent(6, i

#line default
#line hidden
#nullable disable
);
__builder.AddMarkupContent(7, "\r\n ");
__builder.CloseElement();
__builder.AddMarkupContent(8, "\r\n");
#nullable restore
#line (11,1)-(12,1) "x:\dir\subdir\Test\TestComponent.cshtml"
}

#line default
#line hidden
#nullable disable

__builder.AddContent(9, " ");
__builder.CloseElement();
__builder.AddMarkupContent(10, "\r\n");
#nullable restore
#line (13,1)-(14,1) "x:\dir\subdir\Test\TestComponent.cshtml"
}

#line default
#line hidden
#nullable disable

}
}
#pragma warning restore 1591
Loading