Add support for Razor templates

Adds support for Razor templates and RenderFragment<T>.

Razor templates are a little-known Razor feature that looks like:
```
@<tag>....<tag>
```

It's so little known that it's not even covered in our docs, but it's
been around for many many years. This features hasn't been implemented
until now for Blazor, and this feature brings it back as a build
building block for templated components (more to come).

In Blazor land a template like:
```
@{ RenderFragment<Person> template = @<div>@item.Name</div>; }
```

complies to code like:
```
RenderFragment<Person> template = (__builder, item) =>
{
    __builder.OpenElement(...);
    ...
    __builder.CloseElement(...);
}
```

Since the declaration always has a generic type parameter inside, it
needs to be in a context where the type is known.. ie: not with `var`.

See tests for ways to consume templates.

NOTE: There are the following caveats for templates
- Templates require a single root element.
- Templates don't work in the `@functions { }` block

These limitations are baked into the core of Razor and will take a while
for us to address (v3.0).
This commit is contained in:
Ryan Nowak 2018-08-24 19:12:17 -07:00
parent 2fb5bfb136
commit c97cb8c18b
74 changed files with 2983 additions and 72 deletions

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Blazor.Shared;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
namespace Microsoft.AspNetCore.Blazor.Razor
@ -474,6 +475,14 @@ namespace Microsoft.AspNetCore.Blazor.Razor
private static IntermediateToken GetAttributeContent(TagHelperPropertyIntermediateNode node)
{
var template = node.FindDescendantNodes<TemplateIntermediateNode>().FirstOrDefault();
if (template != null)
{
// See comments in TemplateDiagnosticPass
node.Diagnostics.Add(BlazorDiagnosticFactory.CreateTemplate_InvalidLocation(template.Source));
return new IntermediateToken() { Kind = TokenKind.CSharp, Content = string.Empty, };
}
if (node.Children[0] is HtmlContentIntermediateNode htmlContentNode)
{
// This case can be hit for a 'string' attribute. We want to turn it into

View File

@ -7,6 +7,7 @@ using System.Linq;
using Microsoft.AspNetCore.Blazor.Shared;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
namespace Microsoft.AspNetCore.Blazor.Razor
@ -351,7 +352,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
// because each component creates a lambda scope for its child content.
//
// We're hacking it a bit here by just forcing every component to have an empty lambda
_scopeStack.OpenScope(node.TagName, isComponent: true);
_scopeStack.OpenComponentScope(node.TagName);
_scopeStack.IncrementCurrentScopeChildCount(context);
foreach (var child in node.Body)
@ -397,6 +398,34 @@ namespace Microsoft.AspNetCore.Blazor.Razor
{
// Do nothing
}
else if (node.Children.Count == 1 && node.Children[0] is TemplateIntermediateNode template)
{
// Templates are represented as lambdas assignable for RenderFragment<T> (for some T).
// We don't have a type to write down unless its bound to a stronly typed attribute.
// That's OK because the compiler gives an error if we can't type check it.
context.CodeWriter.Write(DesignTimeVariable);
context.CodeWriter.Write(" = ");
// If we have a parameter type, then add a type check.
if (NeedsTypeCheck(node))
{
context.CodeWriter.Write(BlazorApi.RuntimeHelpers.TypeCheck);
context.CodeWriter.Write("<");
context.CodeWriter.Write(node.BoundAttribute.TypeName);
context.CodeWriter.Write(">");
context.CodeWriter.Write("(");
}
context.RenderNode(template);
if (NeedsTypeCheck(node))
{
context.CodeWriter.Write(")");
}
context.CodeWriter.Write(";");
context.CodeWriter.WriteLine();
}
else
{
// There are a few different forms that could be used to contain all of the tokens, but we don't really care
@ -437,7 +466,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
context.CodeWriter.Write(" = ");
// If we have a parameter type, then add a type check.
if (node.BoundAttribute != null && !node.BoundAttribute.IsWeaklyTyped())
if (NeedsTypeCheck(node))
{
context.CodeWriter.Write(BlazorApi.RuntimeHelpers.TypeCheck);
context.CodeWriter.Write("<");
@ -451,7 +480,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
WriteCSharpToken(context, tokens[i]);
}
if (node.BoundAttribute != null && !node.BoundAttribute.IsWeaklyTyped())
if (NeedsTypeCheck(node))
{
context.CodeWriter.Write(")");
}
@ -461,6 +490,11 @@ namespace Microsoft.AspNetCore.Blazor.Razor
}
}
bool NeedsTypeCheck(ComponentAttributeExtensionNode n)
{
return n.BoundAttribute != null && !n.BoundAttribute.IsWeaklyTyped();
}
IReadOnlyList<IntermediateToken> GetCSharpTokens(ComponentAttributeExtensionNode attribute)
{
// We generally expect all children to be CSharp, this is here just in case.
@ -468,6 +502,27 @@ namespace Microsoft.AspNetCore.Blazor.Razor
}
}
public override void WriteTemplate(CodeRenderingContext context, TemplateIntermediateNode node)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (node == null)
{
throw new ArgumentNullException(nameof(node));
}
// Since the user doesn't write this name themselves, we have to use something hardcoded
// and predicatable.
const string VariableName = "context";
_scopeStack.OpenTemplateScope(context, VariableName);
context.RenderChildren(node);
_scopeStack.CloseScope(context);
}
public override void WriteReferenceCapture(CodeRenderingContext context, RefExtensionNode refNode)
{
if (context == null)

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -153,9 +153,18 @@ namespace Microsoft.AspNetCore.Blazor.Razor
new RazorDiagnosticDescriptor(
"BL9991",
() => "The attribute names could not be inferred from bind attibute '{0}'. Bind attributes should be of the form" +
"'bind', 'bind-value' or 'bind-value-change'",
"'bind', 'bind-value' or 'bind-value-change'",
RazorDiagnosticSeverity.Error);
public static RazorDiagnostic CreateBindAttribute_InvalidSyntax(SourceSpan? source, string attribute)
{
var diagnostic = RazorDiagnostic.Create(
BindAttribute_InvalidSyntax,
source ?? SourceSpan.Undefined,
attribute);
return diagnostic;
}
public static readonly RazorDiagnosticDescriptor DisallowedScriptTag = new RazorDiagnosticDescriptor(
"BL9992",
() => "Script tags should not be placed inside components because they cannot be updated dynamically. To fix this, move the script tag to the 'index.html' file or another static location. For more information see https://go.microsoft.com/fwlink/?linkid=872131",
@ -169,13 +178,15 @@ namespace Microsoft.AspNetCore.Blazor.Razor
return diagnostic;
}
public static RazorDiagnostic CreateBindAttribute_InvalidSyntax(SourceSpan? source, string attribute)
public static readonly RazorDiagnosticDescriptor Template_InvalidLocation =
new RazorDiagnosticDescriptor(
"BL9994",
() => "Razor templates cannot be used in attributes.",
RazorDiagnosticSeverity.Error);
public static RazorDiagnostic CreateTemplate_InvalidLocation(SourceSpan? source)
{
var diagnostic = RazorDiagnostic.Create(
BindAttribute_InvalidSyntax,
source ?? SourceSpan.Undefined,
attribute);
return diagnostic;
return RazorDiagnostic.Create(Template_InvalidLocation, source ?? SourceSpan.Undefined);
}
}
}

View File

@ -63,6 +63,8 @@ namespace Microsoft.AspNetCore.Blazor.Razor
builder.Features.Add(new ConfigureBlazorCodeGenerationOptions());
builder.AddTargetExtension(new BlazorTemplateTargetExtension());
var isDeclarationOnlyCompile = builder.Configuration.ConfigurationName == DeclarationConfiguration.ConfigurationName;
// Blazor-specific passes, in order.
@ -79,6 +81,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
builder.Features.Add(new EventHandlerLoweringPass());
builder.Features.Add(new RefLoweringPass());
builder.Features.Add(new BindLoweringPass());
builder.Features.Add(new TemplateDiagnosticPass());
builder.Features.Add(new HtmlBlockPass());
builder.Features.Add(new ComponentTagHelperDescriptorProvider());

View File

@ -4,6 +4,7 @@
using System;
using System.Linq;
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
namespace Microsoft.AspNetCore.Blazor.Razor
@ -22,6 +23,8 @@ namespace Microsoft.AspNetCore.Blazor.Razor
public abstract void WriteReferenceCapture(CodeRenderingContext context, RefExtensionNode node);
public abstract void WriteTemplate(CodeRenderingContext context, TemplateIntermediateNode node);
public sealed override void BeginWriterScope(CodeRenderingContext context, string writer)
{
throw new NotImplementedException(nameof(BeginWriterScope));

View File

@ -9,6 +9,7 @@ using System.Text;
using Microsoft.AspNetCore.Blazor.Shared;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
namespace Microsoft.AspNetCore.Blazor.Razor
@ -114,7 +115,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
else
{
// There may be something else inside the expression like a Template or another extension node.
throw new NotImplementedException("Unsupported: CSharpExpression with child node that isn't a CSharp node");
context.RenderNode(node.Children[i]);
}
}
@ -202,7 +203,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
context.RenderNode(capture);
}
_scopeStack.OpenScope(tagName: node.TagName, isComponent: false);
_scopeStack.OpenElementScope(node.TagName);
// Render body of the tag inside the scope
foreach (var child in node.Body)
@ -321,7 +322,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
context.RenderNode(attribute);
}
_scopeStack.OpenScope(node.TagName, isComponent: true);
_scopeStack.OpenComponentScope(node.TagName);
foreach (var child in node.Body)
{
context.RenderNode(child);
@ -382,6 +383,29 @@ namespace Microsoft.AspNetCore.Blazor.Razor
var content = string.Join(string.Empty, GetHtmlTokens(htmlNode).Select(t => t.Content));
context.CodeWriter.WriteStringLiteral(content);
}
else if (node.Children.Count == 1 && node.Children[0] is TemplateIntermediateNode template)
{
// Templates are represented as lambdas assignable for RenderFragment<T> (for some T).
// We don't have a type to write down unless its bound to a stronly typed attribute.
// That's OK because the compiler gives an error if we can't type check it.
// If we have a parameter type, then add a type check.
if (node.BoundAttribute != null && !node.BoundAttribute.IsWeaklyTyped())
{
context.CodeWriter.Write(BlazorApi.RuntimeHelpers.TypeCheck);
context.CodeWriter.Write("<");
context.CodeWriter.Write(node.BoundAttribute.TypeName);
context.CodeWriter.Write(">");
context.CodeWriter.Write("(");
}
context.RenderNode(template);
if (node.BoundAttribute != null && !node.BoundAttribute.IsWeaklyTyped())
{
context.CodeWriter.Write(")");
}
}
else
{
// See comments in BlazorDesignTimeNodeWriter for a description of the cases that are possible.
@ -438,6 +462,27 @@ namespace Microsoft.AspNetCore.Blazor.Razor
}
}
public override void WriteTemplate(CodeRenderingContext context, TemplateIntermediateNode node)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (node == null)
{
throw new ArgumentNullException(nameof(node));
}
// Since the user doesn't write this name themselves, we have to use something hardcoded
// and predicatable.
const string VariableName = "context";
_scopeStack.OpenTemplateScope(context, VariableName);
context.RenderChildren(node);
_scopeStack.CloseScope(context);
}
public override void WriteReferenceCapture(CodeRenderingContext context, RefExtensionNode node)
{
var codeWriter = context.CodeWriter;

View File

@ -0,0 +1,16 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
using Microsoft.AspNetCore.Razor.Language.Extensions;
namespace Microsoft.AspNetCore.Blazor.Razor
{
internal class BlazorTemplateTargetExtension : ITemplateTargetExtension
{
public void WriteTemplate(CodeRenderingContext context, TemplateIntermediateNode node)
{
((BlazorNodeWriter)context.NodeWriter).WriteTemplate(context, node);
}
}
}

View File

@ -1,10 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Blazor.Shared;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
namespace Microsoft.AspNetCore.Blazor.Razor
@ -110,6 +111,12 @@ namespace Microsoft.AspNetCore.Blazor.Razor
private IntermediateNode RewriteUsage(IntermediateNode parent, TagHelperPropertyIntermediateNode node)
{
var original = GetAttributeContent(node);
if (original.Count == 0)
{
// This can happen in error cases, the parser will already have flagged this
// as an error, so ignore it.
return node;
}
// Now rewrite the content of the value node to look like:
//
@ -178,6 +185,14 @@ namespace Microsoft.AspNetCore.Blazor.Razor
private static IReadOnlyList<IntermediateToken> GetAttributeContent(TagHelperPropertyIntermediateNode node)
{
var template = node.FindDescendantNodes<TemplateIntermediateNode>().FirstOrDefault();
if (template != null)
{
// See comments in TemplateDiagnosticPass
node.Diagnostics.Add(BlazorDiagnosticFactory.CreateTemplate_InvalidLocation(template.Source));
return new[] { new IntermediateToken() { Kind = TokenKind.CSharp, Content = string.Empty, }, };
}
if (node.Children.Count == 1 && node.Children[0] is HtmlContentIntermediateNode htmlContentNode)
{
// This case can be hit for a 'string' attribute. We want to turn it into

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Blazor.Shared;
@ -21,9 +21,25 @@ namespace Microsoft.AspNetCore.Blazor.Razor
public string BuilderVarName { get; private set; } = "builder";
public void OpenScope(string tagName, bool isComponent)
public void OpenElementScope(string tagName)
{
_stack.Push(new ScopeEntry(tagName, isComponent));
_stack.Push(new ScopeEntry(tagName, ScopeKind.Element));
}
public void OpenComponentScope(string tagName)
{
_stack.Push(new ScopeEntry(tagName, ScopeKind.Component));
}
public void OpenTemplateScope(CodeRenderingContext context, string variableName)
{
var currentScope = new ScopeEntry("__template", ScopeKind.Template);
_stack.Push(currentScope);
// Templates always get a lambda scope, because they are defined as a lambda.
OffsetBuilderVarNumber(1);
currentScope.LambdaScope = context.CodeWriter.BuildLambda(BuilderVarName, variableName);
}
public void CloseScope(CodeRenderingContext context)
@ -34,8 +50,13 @@ namespace Microsoft.AspNetCore.Blazor.Razor
if (currentScope.LambdaScope != null)
{
currentScope.LambdaScope.Dispose();
context.CodeWriter.Write(")");
context.CodeWriter.WriteEndMethodInvocation();
if (currentScope.Kind == ScopeKind.Component)
{
context.CodeWriter.Write(")");
context.CodeWriter.WriteEndMethodInvocation();
}
OffsetBuilderVarNumber(-1);
}
}
@ -46,7 +67,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
{
var currentScope = _stack.Peek();
if (currentScope.IsComponent && currentScope.ChildCount == 0)
if (currentScope.Kind == ScopeKind.Component && currentScope.ChildCount == 0)
{
// When we're about to insert the first child into a component,
// it's time to open a new lambda
@ -72,16 +93,25 @@ namespace Microsoft.AspNetCore.Blazor.Razor
private class ScopeEntry
{
public readonly string TagName;
public readonly bool IsComponent;
public ScopeKind Kind;
public int ChildCount;
public IDisposable LambdaScope;
public ScopeEntry(string tagName, bool isComponent)
public ScopeEntry(string tagName, ScopeKind kind)
{
TagName = tagName;
IsComponent = isComponent;
Kind = kind;
ChildCount = 0;
}
public override string ToString() => $"<{TagName}> ({Kind})";
}
private enum ScopeKind
{
Element,
Component,
Template,
}
}
}

View File

@ -0,0 +1,60 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Blazor.Razor
{
internal class TemplateDiagnosticPass : IntermediateNodePassBase, IRazorOptimizationPass
{
// Runs after components/eventhandlers/ref/bind. We need to check for templates in all of those
// places.
public override int Order => 150;
protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode)
{
var visitor = new Visitor();
visitor.Visit(documentNode);
for (var i = 0; i < visitor.Candidates.Count; i++)
{
var candidate = visitor.Candidates[i];
candidate.Parent.Diagnostics.Add(BlazorDiagnosticFactory.CreateTemplate_InvalidLocation(candidate.Node.Source));
// Remove the offending node since we don't know how to render it. This means that the user won't get C#
// completion at this location, which is fine because it's inside an HTML attribute.
candidate.Remove();
}
}
private class Visitor : IntermediateNodeWalker, IExtensionIntermediateNodeVisitor<TemplateIntermediateNode>
{
public List<IntermediateNodeReference> Candidates { get; } = new List<IntermediateNodeReference>();
public void VisitExtension(TemplateIntermediateNode node)
{
// We found a template, let's check where it's located.
for (var i = 0; i < Ancestors.Count; i++)
{
var ancestor = Ancestors[i];
if (
// Inside markup attribute
ancestor is HtmlAttributeIntermediateNode ||
// Inside component attribute
ancestor is ComponentAttributeExtensionNode ||
// Inside malformed ref attribute
ancestor is TagHelperPropertyIntermediateNode)
{
Candidates.Add(new IntermediateNodeReference(Parent, node));
}
}
}
}
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Blazor.RenderTree;
@ -11,4 +11,13 @@ namespace Microsoft.AspNetCore.Blazor
/// </summary>
/// <param name="builder">The <see cref="RenderTreeBuilder"/> to which the content should be written.</param>
public delegate void RenderFragment(RenderTreeBuilder builder);
/// <summary>
/// Represents a segment of UI content for an object of type <typeparamref name="T"/>, implemented
/// as a delegate that writes the content to a <see cref="RenderTreeBuilder"/>.
/// </summary>
/// <typeparam name="T">The type of object.</typeparam>
/// <param name="builder">The <see cref="RenderTreeBuilder"/> to which the content should be written.</param>
/// <param name="value">The value used to build the content.</param>
public delegate void RenderFragment<T>(RenderTreeBuilder builder, T value);
}

View File

@ -0,0 +1,24 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.Blazor
{
/// <summary>
/// Contains extension methods for <see cref="RenderFragment"/> and <see cref="RenderFragment{T}"/>.
/// </summary>
public static class RenderFragmentExtensions
{
/// <summary>
/// Binds a <see cref="RenderFragment{T}" /> and a value of type <typeparamref name="T"/> to a
/// <see cref="RenderFragment"/> so that it can be used by the rendering system from Razor code.
/// </summary>
/// <typeparam name="T">The type of the value used by the <paramref name="fragment"/>.</typeparam>
/// <param name="fragment">A <see cref="RenderFragment{T}"/>, usually produced by a Razor template.</param>
/// <param name="value">The value of type <typeparamref name="T"/>.</param>
/// <returns>A <see cref="RenderFragment"/>.</returns>
public static RenderFragment WithValue<T>(this RenderFragment<T> fragment, T value)
{
return (b) => fragment(b, value);
}
}
}

View File

@ -102,6 +102,26 @@ namespace Microsoft.AspNetCore.Blazor.RenderTree
}
}
/// <summary>
/// Appends frames representing an arbitrary fragment of content.
/// </summary>
/// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
/// <param name="fragment">Content to append.</param>
/// <param name="value">The value used by <paramref name="fragment"/>.</param>
public void AddContent<T>(int sequence, RenderFragment<T> fragment, T value)
{
if (fragment != null)
{
// We surround the fragment with a region delimiter to indicate that the
// sequence numbers inside the fragment are unrelated to the sequence numbers
// outside it. If we didn't do this, the diffing logic might produce inefficient
// diffs depending on how the sequence numbers compared.
OpenRegion(sequence);
fragment(this, value);
CloseRegion();
}
}
/// <summary>
/// Appends a frame representing markup content.
/// </summary>

View File

@ -554,5 +554,58 @@ namespace Test
frame => AssertFrame.Text(frame, "hi", 14),
frame => AssertFrame.Markup(frame, "\n <div></div>\n ", 15));
}
[Fact]
public void RazorTemplate_CanBeUsedFromComponent()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
using Microsoft.AspNetCore.Blazor.RenderTree;
namespace Test
{
public class Repeater : BlazorComponent
{
[Parameter] int Count { get; set; }
[Parameter] RenderFragment<string> Template { get; set; }
[Parameter] string Value { get; set; }
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
for (var i = 0; i < Count; i++)
{
builder.AddContent(i, Template, Value);
}
}
}
}
"));
var component = CompileToComponent(@"
@addTagHelper ""*, TestAssembly""
@{ RenderFragment<string> template = @<div>@context.ToLower()</div>; }
<Repeater Count=3 Value=""Hello, World!"" Template=""template"" />
");
// Act
var frames = GetRenderTree(component);
// Assert
Assert.Collection(
frames,
frame => AssertFrame.Component(frame, "Test.Repeater", 4, 2),
frame => AssertFrame.Attribute(frame, "Count", typeof(int), 3),
frame => AssertFrame.Attribute(frame, "Value", typeof(string), 4),
frame => AssertFrame.Attribute(frame, "Template", typeof(RenderFragment<string>), 5),
frame => AssertFrame.Element(frame, "div", 2, 0),
frame => AssertFrame.Text(frame, "hello, world!", 1),
frame => AssertFrame.Element(frame, "div", 2, 0),
frame => AssertFrame.Text(frame, "hello, world!", 1),
frame => AssertFrame.Element(frame, "div", 2, 0),
frame => AssertFrame.Text(frame, "hello, world!", 1));
}
}
}

View File

@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
internal override bool DesignTime => true;
internal override bool UseTwoPhaseCompilation => true;
[Fact]
public void ChildComponent_WithParameters()
{
@ -1030,5 +1030,221 @@ namespace Test
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void RazorTemplate_InCodeBlock()
{
// Arrange
// Act
var generated = CompileToCSharp(@"
@{
RenderFragment<Person> p = @<div>@context.Name</div>;
}
@functions {
class Person
{
public string Name { get; set; }
}
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void RazorTemplate_InExplicitExpression()
{
// Arrange
// Act
var generated = CompileToCSharp(@"
@(RenderPerson(@<div>@context.Name</div>))
@functions {
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void RazorTemplate_InImplicitExpression()
{
// Arrange
// Act
var generated = CompileToCSharp(@"
@RenderPerson(@<div>@context.Name</div>)
@functions {
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void RazorTemplate_ContainsComponent()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent : BlazorComponent
{
[Parameter] string Name { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper ""*, TestAssembly""
@{
RenderFragment<Person> p = @<div><MyComponent Name=""@context.Name""/></div>;
}
@functions {
class Person
{
public string Name { get; set; }
}
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
// Targeted at the logic that assigns 'builder' names
[Fact]
public void RazorTemplate_FollowedByComponent()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent : BlazorComponent
{
[Parameter] string Name { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper ""*, TestAssembly""
@{
RenderFragment<Person> p = @<div><MyComponent Name=""@context.Name""/></div>;
}
<MyComponent>
@(""hello, world!"")
</MyComponent>
@functions {
class Person
{
public string Name { get; set; }
}
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void RazorTemplate_AsComponentParameter()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent : BlazorComponent
{
[Parameter] RenderFragment<Person> PersonTemplate { get; set; }
}
public class Person
{
public string Name { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper ""*, TestAssembly""
@{ RenderFragment<Person> template = @<div>@context.Name</div>; }
<MyComponent PersonTemplate=""@template""/>
");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void RazorTemplate_AsComponentParameter_MixedContent()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent : BlazorComponent
{
[Parameter] RenderFragment<Context> Template { get; set; }
}
public class Context
{
public int Index { get; set; }
public string Item { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper ""*, TestAssembly""
@{ RenderFragment<Test.Context> template = @<li>#@context.Index - @context.Item.ToLower()</li>; }
<MyComponent Template=""@template""/>
");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
}
}

View File

@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
frame => AssertFrame.Markup(frame, "<myelem>Hello</myelem>", 0));
}
[Fact(Skip = "Temporarily disable compiling markup frames in 0.5.1")]
[Fact]
public void CreatesSeparateMarkupFrameForEachTopLevelStaticElement()
{
// The JavaScript-side rendering code does not rely on this behavior. It supports
@ -106,14 +106,14 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
"<root>@(\"Hi\") <child1>a</child1> <child2><another>b</another></child2> </root>");
// Assert
Assert.Collection(GetRenderTree(component),
frame => AssertFrame.Element(frame, "root", 7, 0),
var frames = GetRenderTree(component);
Assert.Collection(
frames,
frame => AssertFrame.Element(frame, "root", 5, 0),
frame => AssertFrame.Text(frame, "Hi", 1),
frame => AssertFrame.Text(frame, " ", 2),
frame => AssertFrame.Markup(frame, "<child1>a</child1>", 3),
frame => AssertFrame.Text(frame, " ", 4),
frame => AssertFrame.Markup(frame, "<child2><another>b</another></child2>", 5),
frame => AssertFrame.Text(frame, " ", 6));
frame => AssertFrame.Markup(frame, "<child1>a</child1> ", 3),
frame => AssertFrame.Markup(frame, "<child2><another>b</another></child2> ", 4));
}
[Fact]
@ -598,5 +598,69 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
}
public enum MyEnum { FirstValue, SecondValue }
[Fact]
public void RazorTemplate_CanBeUsedFromRazorCode()
{
// Arrange
var component = CompileToComponent(@"
@{ RenderFragment<string> template = @<div>@context.ToLower()</div>; }
@for (var i = 0; i < 3; i++)
{
@template.WithValue(""Hello, World!"");
}
");
// Act
var frames = GetRenderTree(component);
// Assert
Assert.Collection(
frames,
frame => AssertFrame.Element(frame, "div", 2, 0),
frame => AssertFrame.Text(frame, "hello, world!", 1),
frame => AssertFrame.Element(frame, "div", 2, 0),
frame => AssertFrame.Text(frame, "hello, world!", 1),
frame => AssertFrame.Element(frame, "div", 2, 0),
frame => AssertFrame.Text(frame, "hello, world!", 1));
}
[Fact]
public void RazorTemplate_CanBeUsedFromMethod()
{
// Arrange
var component = CompileToComponent(@"
@(Repeat(@<div>@context.ToLower()</div>, ""Hello, World!"", 3))
@functions {
RenderFragment Repeat<T>(RenderFragment<T> template, T value, int count)
{
return (b) =>
{
for (var i = 0; i < count; i++)
{
template(b, value);
}
};
}
}");
// Act
var frames = GetRenderTree(component);
// Assert
//
// The sequence numbers start at 1 here because there is an AddContent(0, Repeat(....) call
// that precedes the definition of the lambda. Sequence numbers for the lambda are allocated
// from the same logical sequence as the surrounding code.
Assert.Collection(
frames,
frame => AssertFrame.Element(frame, "div", 2, 1),
frame => AssertFrame.Text(frame, "hello, world!", 2),
frame => AssertFrame.Element(frame, "div", 2, 1),
frame => AssertFrame.Text(frame, "hello, world!", 2),
frame => AssertFrame.Element(frame, "div", 2, 1),
frame => AssertFrame.Text(frame, "hello, world!", 2));
}
}
}

View File

@ -1269,5 +1269,221 @@ namespace Test
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void RazorTemplate_InCodeBlock()
{
// Arrange
// Act
var generated = CompileToCSharp(@"
@{
RenderFragment<Person> p = @<div>@context.Name</div>;
}
@functions {
class Person
{
public string Name { get; set; }
}
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void RazorTemplate_InExplicitExpression()
{
// Arrange
// Act
var generated = CompileToCSharp(@"
@(RenderPerson(@<div>@context.Name</div>))
@functions {
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void RazorTemplate_InImplicitExpression()
{
// Arrange
// Act
var generated = CompileToCSharp(@"
@RenderPerson(@<div>@context.Name</div>)
@functions {
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void RazorTemplate_ContainsComponent()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent : BlazorComponent
{
[Parameter] string Name { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper ""*, TestAssembly""
@{
RenderFragment<Person> p = @<div><MyComponent Name=""@context.Name""/></div>;
}
@functions {
class Person
{
public string Name { get; set; }
}
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
// Targeted at the logic that assigns 'builder' names
[Fact]
public void RazorTemplate_FollowedByComponent()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent : BlazorComponent
{
[Parameter] string Name { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper ""*, TestAssembly""
@{
RenderFragment<Person> p = @<div><MyComponent Name=""@context.Name""/></div>;
}
<MyComponent>
@(""hello, world!"")
</MyComponent>
@functions {
class Person
{
public string Name { get; set; }
}
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void RazorTemplate_AsComponentParameter()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent : BlazorComponent
{
[Parameter] RenderFragment<Person> PersonTemplate { get; set; }
}
public class Person
{
public string Name { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper ""*, TestAssembly""
@{ RenderFragment<Person> template = @<div>@context.Name</div>; }
<MyComponent PersonTemplate=""@template""/>
");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void RazorTemplate_AsComponentParameter_MixedContent()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent : BlazorComponent
{
[Parameter] RenderFragment<Context> Template { get; set; }
}
public class Context
{
public int Index { get; set; }
public string Item { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper ""*, TestAssembly""
@{ RenderFragment<Test.Context> template = @<li>#@context.Index - @context.Item.ToLower()</li>; }
<MyComponent Template=""@template""/>
");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
}
}

View File

@ -0,0 +1,127 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Xunit;
namespace Microsoft.AspNetCore.Blazor.Build.Test
{
public class TemplateRazorIntegrationTest : RazorBaselineIntegrationTestBase
{
// Razor doesn't parse this as a template, we don't need much special handling for
// it because it will just be invalid in general.
[Fact]
public void Template_ImplicitExpressionInMarkupAttribute_CreatesDiagnostic()
{
// Arrange
// Act
var generated = CompileToCSharp(@"<div attr=""@<div></div>"" />");
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
Assert.Equal("RZ1005", diagnostic.Id);
}
[Fact]
public void Template_ExplicitExpressionInMarkupAttribute_CreatesDiagnostic()
{
// Arrange
// Act
var generated = CompileToCSharp(@"<div attr=""@(@<div></div>)"" />");
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
Assert.Equal("BL9994", diagnostic.Id);
}
// Razor doesn't parse this as a template, we don't need much special handling for
// it because it will just be invalid in general.
[Fact]
public void Template_ImplicitExpressionInComponentAttribute_CreatesDiagnostic()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent : BlazorComponent
{
}
}
"));
// Act
var generated = CompileToCSharp(@"<MyComponent attr=""@<div></div>"" />");
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
Assert.Equal("RZ1005", diagnostic.Id);
}
[Fact]
public void Template_ExplicitExpressionInComponentAttribute_CreatesDiagnostic()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent : BlazorComponent
{
}
}
"));
// Act
var generated = CompileToCSharp(@"<MyComponent attr=""@(@<div></div>)"" />");
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
Assert.Equal("BL9994", diagnostic.Id);
}
[Fact]
public void Template_ExplicitExpressionInRef_CreatesDiagnostic()
{
// Arrange
// Act
var generated = CompileToCSharp(@"<div ref=""@(@<div></div>)"" />");
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
Assert.Equal("BL9994", diagnostic.Id);
}
[Fact]
public void Template_ExplicitExpressionInBind_CreatesDiagnostic()
{
// Arrange
// Act
var generated = CompileToCSharp(@"<input type=""text"" bind=""@(@<div></div>)"" />");
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
Assert.Equal("BL9994", diagnostic.Id);
}
[Fact]
public void Template_ExplicitExpressionInEventHandler_CreatesDiagnostic()
{
// Arrange
// Act
var generated = CompileToCSharp(@"<input type=""text"" onchange=""@(@<div></div>)"" />");
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
Assert.Equal("BL9994", diagnostic.Id);
}
}
}

View File

@ -0,0 +1,60 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
global::System.Object __typeHelper = "*, TestAssembly";
}
))();
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
RenderFragment<Person> template =
#line default
#line hidden
(builder2, context) => {
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = context.Name;
#line default
#line hidden
}
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
;
#line default
#line hidden
__o = new Microsoft.AspNetCore.Blazor.RenderFragment<Test.Person>(
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
template
#line default
#line hidden
);
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => {
}
));
}
#pragma warning restore 1998
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,38 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [33] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [44] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
DesignTimeDirective -
DirectiveToken - (14:0,14 [32] ) - "*, Microsoft.AspNetCore.Blazor"
DirectiveToken - (14:0,14 [9] ) - "*, Test"
DirectiveToken - (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) - "*, TestAssembly"
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
CSharpCode -
IntermediateToken - - CSharp - private static System.Object __o = null;
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
HtmlContent - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (35:1,2 [35] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (35:1,2 [35] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment<Person> template =
Template - (71:1,38 [23] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (71:1,38 [24] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (77:1,44 [12] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (77:1,44 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Name
CSharpCode - (95:1,62 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (95:1,62 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;
ComponentExtensionNode - (100:2,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent
ComponentAttributeExtensionNode - (129:2,29 [9] x:\dir\subdir\Test\TestComponent.cshtml) - PersonTemplate - PersonTemplate
CSharpExpression - (130:2,30 [8] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (130:2,30 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - template
HtmlContent - (141:2,41 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (141:2,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n

View File

@ -0,0 +1,25 @@
Source Location: (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml)
|"*, TestAssembly"|
Generated Location: (558:16,37 [17] )
|"*, TestAssembly"|
Source Location: (35:1,2 [35] x:\dir\subdir\Test\TestComponent.cshtml)
| RenderFragment<Person> template = |
Generated Location: (1039:29,2 [35] )
| RenderFragment<Person> template = |
Source Location: (77:1,44 [12] x:\dir\subdir\Test\TestComponent.cshtml)
|context.Name|
Generated Location: (1240:35,44 [12] )
|context.Name|
Source Location: (95:1,62 [2] x:\dir\subdir\Test\TestComponent.cshtml)
|; |
Generated Location: (1414:41,62 [2] )
|; |
Source Location: (130:2,30 [8] x:\dir\subdir\Test\TestComponent.cshtml)
|template|
Generated Location: (1610:47,30 [8] )
|template|

View File

@ -0,0 +1,65 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
global::System.Object __typeHelper = "*, TestAssembly";
}
))();
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
RenderFragment<Test.Context> template =
#line default
#line hidden
(builder2, context) => {
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = context.Index;
#line default
#line hidden
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = context.Item.ToLower();
#line default
#line hidden
}
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
;
#line default
#line hidden
__o = new Microsoft.AspNetCore.Blazor.RenderFragment<Test.Context>(
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
template
#line default
#line hidden
);
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => {
}
));
}
#pragma warning restore 1998
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,44 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [33] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [44] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
DesignTimeDirective -
DirectiveToken - (14:0,14 [32] ) - "*, Microsoft.AspNetCore.Blazor"
DirectiveToken - (14:0,14 [9] ) - "*, Test"
DirectiveToken - (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) - "*, TestAssembly"
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
CSharpCode -
IntermediateToken - - CSharp - private static System.Object __o = null;
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
HtmlContent - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (35:1,2 [41] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (35:1,2 [41] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment<Test.Context> template =
Template - (77:1,44 [48] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (77:1,44 [50] x:\dir\subdir\Test\TestComponent.cshtml) - li
HtmlContent - (81:1,48 [1] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (81:1,48 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - #
CSharpExpression - (83:1,50 [13] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (83:1,50 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Index
HtmlContent - (96:1,63 [3] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (96:1,63 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \-
CSharpExpression - (100:1,67 [22] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (100:1,67 [22] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Item.ToLower()
CSharpCode - (127:1,94 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (127:1,94 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;
ComponentExtensionNode - (132:2,0 [35] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent
ComponentAttributeExtensionNode - (155:2,23 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Template - Template
CSharpExpression - (156:2,24 [8] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (156:2,24 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - template
HtmlContent - (167:2,35 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (167:2,35 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n

View File

@ -0,0 +1,30 @@
Source Location: (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml)
|"*, TestAssembly"|
Generated Location: (558:16,37 [17] )
|"*, TestAssembly"|
Source Location: (35:1,2 [41] x:\dir\subdir\Test\TestComponent.cshtml)
| RenderFragment<Test.Context> template = |
Generated Location: (1039:29,2 [41] )
| RenderFragment<Test.Context> template = |
Source Location: (83:1,50 [13] x:\dir\subdir\Test\TestComponent.cshtml)
|context.Index|
Generated Location: (1252:35,50 [13] )
|context.Index|
Source Location: (100:1,67 [22] x:\dir\subdir\Test\TestComponent.cshtml)
|context.Item.ToLower()|
Generated Location: (1417:40,67 [22] )
|context.Item.ToLower()|
Source Location: (127:1,94 [2] x:\dir\subdir\Test\TestComponent.cshtml)
|; |
Generated Location: (1633:46,94 [2] )
|; |
Source Location: (156:2,24 [8] x:\dir\subdir\Test\TestComponent.cshtml)
|template|
Generated Location: (1824:52,24 [8] )
|template|

View File

@ -0,0 +1,65 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
global::System.Object __typeHelper = "*, TestAssembly";
}
))();
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
RenderFragment<Person> p =
#line default
#line hidden
(builder2, context) => {
__o = Microsoft.AspNetCore.Blazor.Components.RuntimeHelpers.TypeCheck<System.String>(
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
context.Name
#line default
#line hidden
);
builder2.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder3) => {
}
));
}
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
;
#line default
#line hidden
}
#pragma warning restore 1998
#line 5 "x:\dir\subdir\Test\TestComponent.cshtml"
class Person
{
public string Name { get; set; }
}
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,36 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [33] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [44] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
DesignTimeDirective -
DirectiveToken - (14:0,14 [32] ) - "*, Microsoft.AspNetCore.Blazor"
DirectiveToken - (14:0,14 [9] ) - "*, Test"
DirectiveToken - (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) - "*, TestAssembly"
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
CSharpCode -
IntermediateToken - - CSharp - private static System.Object __o = null;
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
HtmlContent - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (35:1,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (35:1,2 [33] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment<Person> p =
Template - (69:2,32 [46] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (69:2,32 [46] x:\dir\subdir\Test\TestComponent.cshtml) - div
ComponentExtensionNode - (74:2,37 [35] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent
ComponentAttributeExtensionNode - (93:2,56 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Name - Name
CSharpExpression - (94:2,57 [12] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (94:2,57 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Name
CSharpCode - (115:2,78 [3] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (115:2,78 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n
CSharpCode - (133:4,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (133:4,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n

View File

@ -0,0 +1,39 @@
Source Location: (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml)
|"*, TestAssembly"|
Generated Location: (558:16,37 [17] )
|"*, TestAssembly"|
Source Location: (35:1,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
|
RenderFragment<Person> p = |
Generated Location: (1039:29,2 [33] )
|
RenderFragment<Person> p = |
Source Location: (94:2,57 [12] x:\dir\subdir\Test\TestComponent.cshtml)
|context.Name|
Generated Location: (1354:37,57 [12] )
|context.Name|
Source Location: (115:2,78 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|;
|
Generated Location: (1723:47,78 [3] )
|;
|
Source Location: (133:4,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
|
class Person
{
public string Name { get; set; }
}
|
Generated Location: (1869:54,12 [76] )
|
class Person
{
public string Name { get; set; }
}
|

View File

@ -0,0 +1,73 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
global::System.Object __typeHelper = "*, TestAssembly";
}
))();
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
RenderFragment<Person> p =
#line default
#line hidden
(builder2, context) => {
__o = Microsoft.AspNetCore.Blazor.Components.RuntimeHelpers.TypeCheck<System.String>(
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
context.Name
#line default
#line hidden
);
builder2.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder3) => {
}
));
}
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
;
#line default
#line hidden
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => {
#line 6 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = "hello, world!";
#line default
#line hidden
}
));
}
#pragma warning restore 1998
#line 9 "x:\dir\subdir\Test\TestComponent.cshtml"
class Person
{
public string Name { get; set; }
}
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,45 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [33] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [44] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
DesignTimeDirective -
DirectiveToken - (14:0,14 [32] ) - "*, Microsoft.AspNetCore.Blazor"
DirectiveToken - (14:0,14 [9] ) - "*, Test"
DirectiveToken - (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) - "*, TestAssembly"
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
CSharpCode -
IntermediateToken - - CSharp - private static System.Object __o = null;
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
HtmlContent - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (35:1,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (35:1,2 [33] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment<Person> p =
Template - (69:2,32 [46] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (69:2,32 [46] x:\dir\subdir\Test\TestComponent.cshtml) - div
ComponentExtensionNode - (74:2,37 [35] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent
ComponentAttributeExtensionNode - (93:2,56 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Name - Name
CSharpExpression - (94:2,57 [12] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (94:2,57 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Name
CSharpCode - (115:2,78 [3] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (115:2,78 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n
ComponentExtensionNode - (121:4,0 [49] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent
HtmlContent - (134:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (134:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpExpression - (138:5,2 [15] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (138:5,2 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hello, world!"
HtmlContent - (154:5,18 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (154:5,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
HtmlContent - (170:6,14 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (170:6,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
CSharpCode - (186:8,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (186:8,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n

View File

@ -0,0 +1,44 @@
Source Location: (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml)
|"*, TestAssembly"|
Generated Location: (558:16,37 [17] )
|"*, TestAssembly"|
Source Location: (35:1,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
|
RenderFragment<Person> p = |
Generated Location: (1039:29,2 [33] )
|
RenderFragment<Person> p = |
Source Location: (94:2,57 [12] x:\dir\subdir\Test\TestComponent.cshtml)
|context.Name|
Generated Location: (1354:37,57 [12] )
|context.Name|
Source Location: (115:2,78 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|;
|
Generated Location: (1723:47,78 [3] )
|;
|
Source Location: (138:5,2 [15] x:\dir\subdir\Test\TestComponent.cshtml)
|"hello, world!"|
Generated Location: (1929:53,6 [15] )
|"hello, world!"|
Source Location: (186:8,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
|
class Person
{
public string Name { get; set; }
}
|
Generated Location: (2122:62,12 [76] )
|
class Person
{
public string Name { get; set; }
}
|

View File

@ -0,0 +1,43 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = ;
#line default
#line hidden
}
#pragma warning restore 1998
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
class Person
{
public string Name { get; set; }
}
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1 @@
x:\dir\subdir\Test\TestComponent.cshtml(1,15): Error BL9994: Razor templates cannot be used in markup-attribute, bind attributes, ref attributes, or event handler attributes.

View File

@ -0,0 +1,29 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [33] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [44] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
DesignTimeDirective -
DirectiveToken - (14:0,14 [32] ) - "*, Microsoft.AspNetCore.Blazor"
DirectiveToken - (14:0,14 [9] ) - "*, Test"
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
CSharpCode -
IntermediateToken - - CSharp - private static System.Object __o = null;
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
HtmlElement - (0:0,0 [44] x:\dir\subdir\Test\TestComponent.cshtml) - div
HtmlAttribute - (4:0,4 [33] x:\dir\subdir\Test\TestComponent.cshtml) - attr=" - "
CSharpExpressionAttributeValue - (11:0,11 [25] x:\dir\subdir\Test\TestComponent.cshtml) -
IntermediateToken - (35:0,35 [0] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp -
HtmlContent - (44:0,44 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (44:0,44 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (58:1,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (58:1,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n

View File

@ -0,0 +1,20 @@
Source Location: (35:0,35 [0] x:\dir\subdir\Test\TestComponent.cshtml)
||
Generated Location: (955:25,35 [0] )
||
Source Location: (58:1,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
|
class Person
{
public string Name { get; set; }
}
|
Generated Location: (1101:32,12 [76] )
|
class Person
{
public string Name { get; set; }
}
|

View File

@ -0,0 +1,56 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
RenderFragment<Person> p =
#line default
#line hidden
(builder2, context) => {
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = context.Name;
#line default
#line hidden
}
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
;
#line default
#line hidden
}
#pragma warning restore 1998
#line 4 "x:\dir\subdir\Test\TestComponent.cshtml"
class Person
{
public string Name { get; set; }
}
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,31 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [33] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [44] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
DesignTimeDirective -
DirectiveToken - (14:0,14 [32] ) - "*, Microsoft.AspNetCore.Blazor"
DirectiveToken - (14:0,14 [9] ) - "*, Test"
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
CSharpCode -
IntermediateToken - - CSharp - private static System.Object __o = null;
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
CSharpCode - (2:0,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (2:0,2 [33] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment<Person> p =
Template - (36:1,32 [23] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (36:1,32 [24] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (42:1,38 [12] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (42:1,38 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Name
CSharpCode - (60:1,56 [3] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (60:1,56 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n
CSharpCode - (78:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (78:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n

View File

@ -0,0 +1,34 @@
Source Location: (2:0,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
|
RenderFragment<Person> p = |
Generated Location: (922:25,2 [33] )
|
RenderFragment<Person> p = |
Source Location: (42:1,38 [12] x:\dir\subdir\Test\TestComponent.cshtml)
|context.Name|
Generated Location: (1115:32,38 [12] )
|context.Name|
Source Location: (60:1,56 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|;
|
Generated Location: (1283:38,56 [3] )
|;
|
Source Location: (78:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
|
class Person
{
public string Name { get; set; }
}
|
Generated Location: (1429:45,12 [76] )
|
class Person
{
public string Name { get; set; }
}
|

View File

@ -0,0 +1,56 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
RenderFragment<dynamic> p =
#line default
#line hidden
(builder2, item) => {
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = item.Name;
#line default
#line hidden
}
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
;
#line default
#line hidden
}
#pragma warning restore 1998
#line 4 "x:\dir\subdir\Test\TestComponent.cshtml"
class Person
{
public string Name { get; set; }
}
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,31 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [33] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [44] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
DesignTimeDirective -
DirectiveToken - (14:0,14 [32] ) - "*, Microsoft.AspNetCore.Blazor"
DirectiveToken - (14:0,14 [9] ) - "*, Test"
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
CSharpCode -
IntermediateToken - - CSharp - private static System.Object __o = null;
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
CSharpCode - (2:0,2 [34] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (2:0,2 [34] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment<dynamic> p =
Template - (37:1,33 [20] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (37:1,33 [21] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (43:1,39 [9] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (43:1,39 [9] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - item.Name
CSharpCode - (58:1,54 [3] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (58:1,54 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n
CSharpCode - (76:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (76:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n

View File

@ -0,0 +1,34 @@
Source Location: (2:0,2 [34] x:\dir\subdir\Test\TestComponent.cshtml)
|
RenderFragment<dynamic> p = |
Generated Location: (922:25,2 [34] )
|
RenderFragment<dynamic> p = |
Source Location: (43:1,39 [9] x:\dir\subdir\Test\TestComponent.cshtml)
|item.Name|
Generated Location: (1114:32,39 [9] )
|item.Name|
Source Location: (58:1,54 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|;
|
Generated Location: (1277:38,54 [3] )
|;
|
Source Location: (76:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
|
class Person
{
public string Name { get; set; }
}
|
Generated Location: (1423:45,12 [76] )
|
class Person
{
public string Name { get; set; }
}
|

View File

@ -0,0 +1,52 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = RenderPerson((builder2, context) => {
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = context.Name;
#line default
#line hidden
}
);
#line default
#line hidden
}
#pragma warning restore 1998
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,32 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [33] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [44] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
DesignTimeDirective -
DirectiveToken - (14:0,14 [32] ) - "*, Microsoft.AspNetCore.Blazor"
DirectiveToken - (14:0,14 [9] ) - "*, Test"
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
CSharpCode -
IntermediateToken - - CSharp - private static System.Object __o = null;
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
CSharpExpression - (2:0,2 [37] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderPerson(
Template - (16:0,16 [23] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (16:0,16 [24] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (22:0,22 [12] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (22:0,22 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Name
IntermediateToken - (40:0,40 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - )
HtmlContent - (42:0,42 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (42:0,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (56:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (56:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n\n object RenderPerson(RenderFragment<Person> p) => null;\n

View File

@ -0,0 +1,34 @@
Source Location: (2:0,2 [13] x:\dir\subdir\Test\TestComponent.cshtml)
|RenderPerson(|
Generated Location: (926:25,6 [13] )
|RenderPerson(|
Source Location: (22:0,22 [12] x:\dir\subdir\Test\TestComponent.cshtml)
|context.Name|
Generated Location: (1038:27,22 [12] )
|context.Name|
Source Location: (40:0,40 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|)|
Generated Location: (1087:32,0 [1] )
|)|
Source Location: (56:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml)
|
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
|
Generated Location: (1234:39,12 [138] )
|
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
|

View File

@ -0,0 +1,52 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = RenderPerson((builder2, context) => {
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = context.Name;
#line default
#line hidden
}
);
#line default
#line hidden
}
#pragma warning restore 1998
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,32 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [33] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [44] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
DesignTimeDirective -
DirectiveToken - (14:0,14 [32] ) - "*, Microsoft.AspNetCore.Blazor"
DirectiveToken - (14:0,14 [9] ) - "*, Test"
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
CSharpCode -
IntermediateToken - - CSharp - private static System.Object __o = null;
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
CSharpExpression - (1:0,1 [37] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (1:0,1 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderPerson(
Template - (15:0,15 [23] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (15:0,15 [24] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (21:0,21 [12] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (21:0,21 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Name
IntermediateToken - (39:0,39 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - )
HtmlContent - (40:0,40 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (40:0,40 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (54:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (54:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n\n object RenderPerson(RenderFragment<Person> p) => null;\n

View File

@ -0,0 +1,34 @@
Source Location: (1:0,1 [13] x:\dir\subdir\Test\TestComponent.cshtml)
|RenderPerson(|
Generated Location: (926:25,6 [13] )
|RenderPerson(|
Source Location: (21:0,21 [12] x:\dir\subdir\Test\TestComponent.cshtml)
|context.Name|
Generated Location: (1037:27,21 [12] )
|context.Name|
Source Location: (39:0,39 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|)|
Generated Location: (1086:32,0 [1] )
|)|
Source Location: (54:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml)
|
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
|
Generated Location: (1233:39,12 [138] )
|
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
|

View File

@ -0,0 +1,56 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
RenderFragment<Person> p =
#line default
#line hidden
(builder2, item) => {
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = item.Name;
#line default
#line hidden
}
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
<div>another</div>;
#line default
#line hidden
}
#pragma warning restore 1998
#line 4 "x:\dir\subdir\Test\TestComponent.cshtml"
class Person
{
public string Name { get; set; }
}
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,31 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [33] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [44] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
DesignTimeDirective -
DirectiveToken - (14:0,14 [32] ) - "*, Microsoft.AspNetCore.Blazor"
DirectiveToken - (14:0,14 [9] ) - "*, Test"
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
CSharpCode -
IntermediateToken - - CSharp - private static System.Object __o = null;
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
CSharpCode - (2:0,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (2:0,2 [33] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment<Person> p =
Template - (36:1,32 [20] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (36:1,32 [21] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (42:1,38 [9] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (42:1,38 [9] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - item.Name
CSharpCode - (57:1,53 [21] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (57:1,53 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - <div>another</div>;\n
CSharpCode - (93:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (93:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n

View File

@ -0,0 +1,34 @@
Source Location: (2:0,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
|
RenderFragment<Person> p = |
Generated Location: (922:25,2 [33] )
|
RenderFragment<Person> p = |
Source Location: (42:1,38 [9] x:\dir\subdir\Test\TestComponent.cshtml)
|item.Name|
Generated Location: (1112:32,38 [9] )
|item.Name|
Source Location: (57:1,53 [21] x:\dir\subdir\Test\TestComponent.cshtml)
|<div>another</div>;
|
Generated Location: (1274:38,53 [21] )
|<div>another</div>;
|
Source Location: (93:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
|
class Person
{
public string Name { get; set; }
}
|
Generated Location: (1438:45,12 [76] )
|
class Person
{
public string Name { get; set; }
}
|

View File

@ -0,0 +1,40 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
RenderFragment<Person> template =
#line default
#line hidden
(builder2, context) => {
builder2.OpenElement(0, "div");
builder2.AddContent(1, context.Name);
builder2.CloseElement();
}
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
;
#line default
#line hidden
builder.OpenComponent<Test.MyComponent>(2);
builder.AddAttribute(3, "PersonTemplate", new Microsoft.AspNetCore.Blazor.RenderFragment<Test.Person>(template));
builder.CloseComponent();
}
#pragma warning restore 1998
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,24 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [14] ) - System
UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
UsingDirective - (53:3,1 [19] ) - System.Linq
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [35] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [46] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
CSharpCode - (35:1,2 [35] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (35:1,2 [35] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment<Person> template =
Template - (71:1,38 [23] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (71:1,38 [24] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (77:1,44 [12] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (77:1,44 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Name
CSharpCode - (95:1,62 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (95:1,62 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;
ComponentExtensionNode - (100:2,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent
ComponentAttributeExtensionNode - (129:2,29 [9] x:\dir\subdir\Test\TestComponent.cshtml) - PersonTemplate - PersonTemplate
CSharpExpression - (130:2,30 [8] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (130:2,30 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - template

View File

@ -0,0 +1,10 @@
Source Location: (35:1,2 [35] x:\dir\subdir\Test\TestComponent.cshtml)
| RenderFragment<Person> template = |
Generated Location: (654:18,2 [35] )
| RenderFragment<Person> template = |
Source Location: (95:1,62 [2] x:\dir\subdir\Test\TestComponent.cshtml)
|; |
Generated Location: (1034:28,62 [2] )
|; |

View File

@ -0,0 +1,43 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
RenderFragment<Test.Context> template =
#line default
#line hidden
(builder2, context) => {
builder2.OpenElement(0, "li");
builder2.AddContent(1, "#");
builder2.AddContent(2, context.Index);
builder2.AddContent(3, " - ");
builder2.AddContent(4, context.Item.ToLower());
builder2.CloseElement();
}
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
;
#line default
#line hidden
builder.OpenComponent<Test.MyComponent>(5);
builder.AddAttribute(6, "Template", new Microsoft.AspNetCore.Blazor.RenderFragment<Test.Context>(template));
builder.CloseComponent();
}
#pragma warning restore 1998
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,30 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [14] ) - System
UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
UsingDirective - (53:3,1 [19] ) - System.Linq
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [35] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [46] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
CSharpCode - (35:1,2 [41] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (35:1,2 [41] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment<Test.Context> template =
Template - (77:1,44 [48] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (77:1,44 [50] x:\dir\subdir\Test\TestComponent.cshtml) - li
HtmlContent - (81:1,48 [1] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (81:1,48 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - #
CSharpExpression - (83:1,50 [13] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (83:1,50 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Index
HtmlContent - (96:1,63 [3] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (96:1,63 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \-
CSharpExpression - (100:1,67 [22] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (100:1,67 [22] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Item.ToLower()
CSharpCode - (127:1,94 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (127:1,94 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;
ComponentExtensionNode - (132:2,0 [35] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent
ComponentAttributeExtensionNode - (155:2,23 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Template - Template
CSharpExpression - (156:2,24 [8] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (156:2,24 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - template

View File

@ -0,0 +1,10 @@
Source Location: (35:1,2 [41] x:\dir\subdir\Test\TestComponent.cshtml)
| RenderFragment<Test.Context> template = |
Generated Location: (654:18,2 [41] )
| RenderFragment<Test.Context> template = |
Source Location: (127:1,94 [2] x:\dir\subdir\Test\TestComponent.cshtml)
|; |
Generated Location: (1231:31,94 [2] )
|; |

View File

@ -0,0 +1,49 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
RenderFragment<Person> p =
#line default
#line hidden
(builder2, context) => {
builder2.OpenElement(0, "div");
builder2.OpenComponent<Test.MyComponent>(1);
builder2.AddAttribute(2, "Name", Microsoft.AspNetCore.Blazor.Components.RuntimeHelpers.TypeCheck<System.String>(context.Name));
builder2.CloseComponent();
builder2.CloseElement();
}
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
;
#line default
#line hidden
}
#pragma warning restore 1998
#line 5 "x:\dir\subdir\Test\TestComponent.cshtml"
class Person
{
public string Name { get; set; }
}
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,24 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [14] ) - System
UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
UsingDirective - (53:3,1 [19] ) - System.Linq
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [35] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [46] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
CSharpCode - (35:1,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (35:1,2 [33] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment<Person> p =
Template - (69:2,32 [46] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (69:2,32 [46] x:\dir\subdir\Test\TestComponent.cshtml) - div
ComponentExtensionNode - (74:2,37 [35] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent
ComponentAttributeExtensionNode - (93:2,56 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Name - Name
CSharpExpression - (94:2,57 [12] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (94:2,57 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Name
CSharpCode - (115:2,78 [3] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (115:2,78 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n
CSharpCode - (133:4,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (133:4,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n

View File

@ -0,0 +1,29 @@
Source Location: (35:1,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
|
RenderFragment<Person> p = |
Generated Location: (654:18,2 [33] )
|
RenderFragment<Person> p = |
Source Location: (115:2,78 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|;
|
Generated Location: (1244:31,78 [3] )
|;
|
Source Location: (133:4,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
|
class Person
{
public string Name { get; set; }
}
|
Generated Location: (1390:38,12 [76] )
|
class Person
{
public string Name { get; set; }
}
|

View File

@ -0,0 +1,57 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
RenderFragment<Person> p =
#line default
#line hidden
(builder2, context) => {
builder2.OpenElement(0, "div");
builder2.OpenComponent<Test.MyComponent>(1);
builder2.AddAttribute(2, "Name", Microsoft.AspNetCore.Blazor.Components.RuntimeHelpers.TypeCheck<System.String>(context.Name));
builder2.CloseComponent();
builder2.CloseElement();
}
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
;
#line default
#line hidden
builder.OpenComponent<Test.MyComponent>(3);
builder.AddAttribute(4, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => {
builder2.AddContent(5, "\n");
builder2.AddContent(6, "hello, world!");
builder2.AddContent(7, "\n");
}
));
builder.CloseComponent();
}
#pragma warning restore 1998
#line 9 "x:\dir\subdir\Test\TestComponent.cshtml"
class Person
{
public string Name { get; set; }
}
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,31 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [14] ) - System
UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
UsingDirective - (53:3,1 [19] ) - System.Linq
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [35] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [46] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
CSharpCode - (35:1,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (35:1,2 [33] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment<Person> p =
Template - (69:2,32 [46] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (69:2,32 [46] x:\dir\subdir\Test\TestComponent.cshtml) - div
ComponentExtensionNode - (74:2,37 [35] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent
ComponentAttributeExtensionNode - (93:2,56 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Name - Name
CSharpExpression - (94:2,57 [12] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (94:2,57 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Name
CSharpCode - (115:2,78 [3] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (115:2,78 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n
ComponentExtensionNode - (121:4,0 [49] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent
HtmlContent - (134:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (134:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpExpression - (138:5,2 [15] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (138:5,2 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hello, world!"
HtmlContent - (154:5,18 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (154:5,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (186:8,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (186:8,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n

View File

@ -0,0 +1,29 @@
Source Location: (35:1,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
|
RenderFragment<Person> p = |
Generated Location: (654:18,2 [33] )
|
RenderFragment<Person> p = |
Source Location: (115:2,78 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|;
|
Generated Location: (1244:31,78 [3] )
|;
|
Source Location: (186:8,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
|
class Person
{
public string Name { get; set; }
}
|
Generated Location: (1784:46,12 [76] )
|
class Person
{
public string Name { get; set; }
}
|

View File

@ -0,0 +1,47 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
RenderFragment<Person> p =
#line default
#line hidden
(builder2, context) => {
builder2.OpenElement(0, "div");
builder2.AddContent(1, context.Name);
builder2.CloseElement();
}
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
;
#line default
#line hidden
}
#pragma warning restore 1998
#line 4 "x:\dir\subdir\Test\TestComponent.cshtml"
class Person
{
public string Name { get; set; }
}
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,22 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [14] ) - System
UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
UsingDirective - (53:3,1 [19] ) - System.Linq
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [35] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [46] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
CSharpCode - (2:0,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (2:0,2 [33] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment<Person> p =
Template - (36:1,32 [23] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (36:1,32 [24] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (42:1,38 [12] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (42:1,38 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Name
CSharpCode - (60:1,56 [3] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (60:1,56 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n
CSharpCode - (78:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (78:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n

View File

@ -0,0 +1,29 @@
Source Location: (2:0,2 [33] x:\dir\subdir\Test\TestComponent.cshtml)
|
RenderFragment<Person> p = |
Generated Location: (654:18,2 [33] )
|
RenderFragment<Person> p = |
Source Location: (60:1,56 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|;
|
Generated Location: (1026:29,56 [3] )
|;
|
Source Location: (78:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml)
|
class Person
{
public string Name { get; set; }
}
|
Generated Location: (1172:36,12 [76] )
|
class Person
{
public string Name { get; set; }
}
|

View File

@ -0,0 +1,39 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
builder.AddContent(0, RenderPerson((builder2, context) => {
builder2.OpenElement(1, "div");
builder2.AddContent(2, context.Name);
builder2.CloseElement();
}
));
}
#pragma warning restore 1998
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,21 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [14] ) - System
UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
UsingDirective - (53:3,1 [19] ) - System.Linq
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [35] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [46] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
CSharpExpression - (2:0,2 [37] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (2:0,2 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderPerson(
Template - (16:0,16 [23] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (16:0,16 [24] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (22:0,22 [12] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (22:0,22 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Name
IntermediateToken - (40:0,40 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - )
CSharpCode - (56:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (56:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n\n object RenderPerson(RenderFragment<Person> p) => null;\n

View File

@ -0,0 +1,19 @@
Source Location: (56:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml)
|
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
|
Generated Location: (964:26,12 [138] )
|
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
|

View File

@ -0,0 +1,39 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
builder.AddContent(0, RenderPerson((builder2, context) => {
builder2.OpenElement(1, "div");
builder2.AddContent(2, context.Name);
builder2.CloseElement();
}
));
}
#pragma warning restore 1998
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,21 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [14] ) - System
UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
UsingDirective - (53:3,1 [19] ) - System.Linq
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [35] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [46] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
CSharpExpression - (1:0,1 [37] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (1:0,1 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderPerson(
Template - (15:0,15 [23] x:\dir\subdir\Test\TestComponent.cshtml)
HtmlElement - (15:0,15 [24] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (21:0,21 [12] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (21:0,21 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Name
IntermediateToken - (39:0,39 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - )
CSharpCode - (54:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (54:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n\n object RenderPerson(RenderFragment<Person> p) => null;\n

View File

@ -0,0 +1,19 @@
Source Location: (54:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml)
|
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
|
Generated Location: (964:26,12 [138] )
|
class Person
{
public string Name { get; set; }
}
object RenderPerson(RenderFragment<Person> p) => null;
|

View File

@ -493,6 +493,20 @@ namespace Microsoft.AspNetCore.Blazor.E2ETest.Tests
appElement.FindElement(By.CssSelector("#dynamic-markup-block span em")).Text);
}
[Fact]
public void CanRenderRazorTemplates()
{
var appElement = MountTestComponent<RazorTemplates>();
// code block template (component parameter)
var element = appElement.FindElement(By.CssSelector("div#codeblocktemplate ol"));
Assert.Collection(
element.FindElements(By.TagName("li")),
e => Assert.Equal("#1 - a", e.Text),
e => Assert.Equal("#2 - b", e.Text),
e => Assert.Equal("#3 - c", e.Text));
}
static IAlert SwitchToAlert(IWebDriver driver)
{
try

View File

@ -1,45 +1,46 @@
@using Microsoft.AspNetCore.Blazor.RenderTree
<div id="test-selector">
Select test:
<select bind=@SelectedComponentTypeName>
<option value="none">Choose...</option>
<option value="BasicTestApp.InteropComponent">Interop component</option>
<option value="BasicTestApp.AsyncEventHandlerComponent">Async event handlers</option>
<option value="BasicTestApp.AddRemoveChildComponents">Add/remove child components</option>
<option value="BasicTestApp.CounterComponent">Counter</option>
<option value="BasicTestApp.CounterComponentUsingChild">Counter using child component</option>
<option value="BasicTestApp.CounterComponentWrapper">Counter wrapped in parent</option>
<option value="BasicTestApp.FocusEventComponent">Focus events</option>
<option value="BasicTestApp.KeyPressEventComponent">Key press event</option>
<option value="BasicTestApp.MouseEventComponent">Mouse events</option>
<option value="BasicTestApp.TouchEventComponent">Touch events</option>
<option value="BasicTestApp.ParentChildComponent">Parent component with child</option>
<option value="BasicTestApp.PropertiesChangedHandlerParent">Parent component that changes parameters on child</option>
<option value="BasicTestApp.RedTextComponent">Red text</option>
<option value="BasicTestApp.RenderFragmentToggler">Render fragment renderer</option>
<option value="BasicTestApp.TextOnlyComponent">Plain text</option>
<option value="BasicTestApp.MarkupBlockComponent">Markup blocks</option>
<option value="BasicTestApp.HierarchicalImportsTest.Subdir.ComponentUsingImports">Imports statement</option>
<option value="BasicTestApp.HttpClientTest.HttpRequestsComponent">HttpClient tester</option>
<option value="BasicTestApp.HttpClientTest.BinaryHttpRequestsComponent">Binary HttpClient tester</option>
<option value="BasicTestApp.HttpClientTest.CookieCounterComponent">HttpClient cookies</option>
<option value="BasicTestApp.BindCasesComponent">bind cases</option>
<option value="BasicTestApp.DataDashComponent">data-* attribute rendering</option>
<option value="BasicTestApp.ExternalContentPackage">External content package</option>
<option value="BasicTestApp.SvgComponent">SVG</option>
<option value="BasicTestApp.SvgWithChildComponent">SVG with child component</option>
<option value="BasicTestApp.LogicalElementInsertionCases">Logical element insertion cases</option>
<option value="BasicTestApp.ElementRefComponent">Element ref component</option>
<option value="BasicTestApp.ComponentRefComponent">Component ref component</option>
<option value="BasicTestApp.AfterRenderInteropComponent">After-render interop component</option>
<option value="BasicTestApp.EventCasesComponent">Event cases</option>
<option value="BasicTestApp.EventBubblingComponent">Event bubbling</option>
<option value="BasicTestApp.EventPreventDefaultComponent">Event preventDefault</option>
<option value="BasicTestApp.RouterTest.TestRouter">Router</option>
<option value="BasicTestApp.HtmlBlockChildContent">ChildContent HTML Block</option>
<option value="BasicTestApp.HtmlMixedChildContent">ChildContent Mixed Block</option>
<option value="BasicTestApp.HtmlEncodedChildContent">ChildContent HTML Encoded Block</option>
</select>
<select bind=@SelectedComponentTypeName>
<option value="none">Choose...</option>
<option value="BasicTestApp.InteropComponent">Interop component</option>
<option value="BasicTestApp.AsyncEventHandlerComponent">Async event handlers</option>
<option value="BasicTestApp.AddRemoveChildComponents">Add/remove child components</option>
<option value="BasicTestApp.CounterComponent">Counter</option>
<option value="BasicTestApp.CounterComponentUsingChild">Counter using child component</option>
<option value="BasicTestApp.CounterComponentWrapper">Counter wrapped in parent</option>
<option value="BasicTestApp.FocusEventComponent">Focus events</option>
<option value="BasicTestApp.KeyPressEventComponent">Key press event</option>
<option value="BasicTestApp.MouseEventComponent">Mouse events</option>
<option value="BasicTestApp.TouchEventComponent">Touch events</option>
<option value="BasicTestApp.ParentChildComponent">Parent component with child</option>
<option value="BasicTestApp.PropertiesChangedHandlerParent">Parent component that changes parameters on child</option>
<option value="BasicTestApp.RedTextComponent">Red text</option>
<option value="BasicTestApp.RenderFragmentToggler">Render fragment renderer</option>
<option value="BasicTestApp.TextOnlyComponent">Plain text</option>
<option value="BasicTestApp.MarkupBlockComponent">Markup blocks</option>
<option value="BasicTestApp.HierarchicalImportsTest.Subdir.ComponentUsingImports">Imports statement</option>
<option value="BasicTestApp.HttpClientTest.HttpRequestsComponent">HttpClient tester</option>
<option value="BasicTestApp.HttpClientTest.BinaryHttpRequestsComponent">Binary HttpClient tester</option>
<option value="BasicTestApp.HttpClientTest.CookieCounterComponent">HttpClient cookies</option>
<option value="BasicTestApp.BindCasesComponent">bind cases</option>
<option value="BasicTestApp.DataDashComponent">data-* attribute rendering</option>
<option value="BasicTestApp.ExternalContentPackage">External content package</option>
<option value="BasicTestApp.SvgComponent">SVG</option>
<option value="BasicTestApp.SvgWithChildComponent">SVG with child component</option>
<option value="BasicTestApp.LogicalElementInsertionCases">Logical element insertion cases</option>
<option value="BasicTestApp.ElementRefComponent">Element ref component</option>
<option value="BasicTestApp.ComponentRefComponent">Component ref component</option>
<option value="BasicTestApp.AfterRenderInteropComponent">After-render interop component</option>
<option value="BasicTestApp.EventCasesComponent">Event cases</option>
<option value="BasicTestApp.EventBubblingComponent">Event bubbling</option>
<option value="BasicTestApp.EventPreventDefaultComponent">Event preventDefault</option>
<option value="BasicTestApp.RouterTest.TestRouter">Router</option>
<option value="BasicTestApp.HtmlBlockChildContent">ChildContent HTML Block</option>
<option value="BasicTestApp.HtmlMixedChildContent">ChildContent Mixed Block</option>
<option value="BasicTestApp.HtmlEncodedChildContent">ChildContent HTML Encoded Block</option>
<option value="BasicTestApp.RazorTemplates">Razor Templates</option>
</select>
@if (SelectedComponentType != null)
{

View File

@ -0,0 +1,22 @@
<ol>
@{
var index = 1;
}
@foreach (var item in Items)
{
@Template.WithValue(new Context() { Index = index++, Item = item, });
}
</ol>
@functions{
[Parameter] IEnumerable<string> Items { get; set; }
[Parameter] RenderFragment<Context> Template { get; set; }
public class Context
{
public int Index { get; set; }
public string Item { get; set; }
}
}

View File

@ -0,0 +1,10 @@
@{
var items = new string[] { "A", "B", "c", };
}
<div id="codeblocktemplate">
@{
RenderFragment<OrderedList.Context> template = @<li>#@context.Index - @context.Item.ToLower()</li>;
}
<OrderedList Items="@items" Template="@template" />
</div>