Add Type Inference for Generic-Typed Components

This change allows you to use generic-typed components without
explicitly specify type arguments.

**Before:**
```
<Grid Items="@MyItems" TItem="Person">
...
</Grid>
```

**After:**
```
<Grid Items="@MyItems">
...
</Grid>
```

Where possible, the type of the component will be inferred based on the
values passed to component parameters. This won't work like magic, you
have to specify parameters that provide type arguments for all of the
component's type parameters.

This is a best effort system, and it's largely based on the limitations
and behaviours of generic type inference in C#. We think it will work
well with most Blazor features and for most reasonable components. You
should not forget it's easy to specify type arguments, because you may
still have to in some cases.

In particular you may notice issues if you are trying to use a generic
typed component where all of the parameters are delegates or templates.
Type inference for delegates/lambdas in C# is based on the context. Any
time you combine generics and delegates it's easy to get into a scenario
where the compiler won't infer the correct type, or will give up.

----
The type inference feature works by generating a 'thunk' method in
*caller* that can act as a site for type inference (C# does not support
inference on constructors).

For our grid example above, the non-inferenced code will look something
like:
```
builder.OpenComponent<Grid<Person>>(0);
builder.AddAttribute(1, "Items", MyItems);
builder.CloseComponent();
```

Note that we can only write the type `Grid<Person>` because you wrote
`Person` in your code. What you type in the `TItem` attribute value gets
inserted into the generated code such that it fills in the generic type
parameter.

On the other hand, if you want is to infer the type, we have to do some
compiler magic. That looks like:
```
__Blazor.(long generated name).TypeInference.CreateGrid_0();
...

// elsewhere in the file
internal static class TypeInference
{
    public static void CreateGrid_0<TItem>(RenderTreeBuilder builder,
    int seq, int __seq0, global::System.Collections.Generic.List<TItem>
    __arg0)
        {
	        builder.OpenComponent<Grid<TItem>>(seq);
		        builder.AddAttribute(__seq0, "Items", __arg0);
			        builder.CloseComponent();
				    }
				    }
				    ```

				    This allows us to rely on the C#
				    compiler for itype inference.
This commit is contained in:
Ryan Nowak 2018-09-18 14:54:35 -07:00
parent b2f73492f5
commit 100382bf71
98 changed files with 3679 additions and 196 deletions

View File

@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
{
private readonly ScopeStack _scopeStack = new ScopeStack();
private readonly static string DesignTimeVariable = "__o";
private static readonly string DesignTimeVariable = "__o";
public override void WriteHtmlBlock(CodeRenderingContext context, HtmlBlockIntermediateNode node)
{
@ -343,40 +343,121 @@ namespace Microsoft.AspNetCore.Blazor.Razor
throw new ArgumentNullException(nameof(node));
}
foreach (var typeArgument in node.TypeArguments)
if (node.TypeInferenceNode == null)
{
context.RenderNode(typeArgument);
}
foreach (var attribute in node.Attributes)
{
context.RenderNode(attribute);
}
if (node.ChildContents.Any())
{
foreach (var childContent in node.ChildContents)
// Writes something like:
//
// builder.OpenComponent<MyComponent>(0);
// builder.AddAttribute(1, "Foo", ...);
// builder.AddAttribute(2, "ChildContent", ...);
// builder.AddElementCapture(3, (__value) => _field = __value);
// builder.CloseComponent();
foreach (var typeArgument in node.TypeArguments)
{
context.RenderNode(childContent);
context.RenderNode(typeArgument);
}
foreach (var attribute in node.Attributes)
{
context.RenderNode(attribute);
}
if (node.ChildContents.Any())
{
foreach (var childContent in node.ChildContents)
{
context.RenderNode(childContent);
}
}
else
{
// We eliminate 'empty' child content when building the tree so that usage like
// '<MyComponent>\r\n</MyComponent>' doesn't create a child content.
//
// Consider what would happen if the user's cursor was inside the element. At
// design -time we want to render an empty lambda to provide proper scoping
// for any code that the user types.
context.RenderNode(new ComponentChildContentIntermediateNode()
{
TypeName = BlazorApi.RenderFragment.FullTypeName,
});
}
foreach (var capture in node.Captures)
{
context.RenderNode(capture);
}
}
else
{
// We eliminate 'empty' child content when building the tree so that usage like
// '<MyComponent>\r\n</MyComponent>' doesn't create a child content.
// When we're doing type inference, we can't write all of the code inline to initialize
// the component on the builder. We generate a method elsewhere, and then pass all of the information
// to that method. We pass in all of the attribute values + the sequence numbers.
//
// Consider what would happen if the user's cursor was inside the element. At
// design -time we want to render an empty lambda to provide proper scoping
// for any code that the user types.
context.RenderNode(new ComponentChildContentIntermediateNode()
{
TypeName = BlazorApi.RenderFragment.FullTypeName,
});
}
// __Blazor.MyComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, ..., 2, ..., 3, ....);
var attributes = node.Attributes.ToList();
var childContents = node.ChildContents.ToList();
var captures = node.Captures.ToList();
var remaining = attributes.Count + childContents.Count + captures.Count;
foreach (var capture in node.Captures)
{
context.RenderNode(capture);
context.CodeWriter.Write(node.TypeInferenceNode.FullTypeName);
context.CodeWriter.Write(".");
context.CodeWriter.Write(node.TypeInferenceNode.MethodName);
context.CodeWriter.Write("(");
context.CodeWriter.Write(_scopeStack.BuilderVarName);
context.CodeWriter.Write(", ");
context.CodeWriter.Write("-1");
context.CodeWriter.Write(", ");
for (var i = 0; i < attributes.Count; i++)
{
context.CodeWriter.Write("-1");
context.CodeWriter.Write(", ");
// Don't type check generics, since we can't actually write the type name.
// The type checking with happen anyway since we defined a method and we're generating
// a call to it.
WriteComponentAttributeInnards(context, attributes[i], canTypeCheck: false);
remaining--;
if (remaining > 0)
{
context.CodeWriter.Write(", ");
}
}
for (var i = 0; i < childContents.Count; i++)
{
context.CodeWriter.Write("-1");
context.CodeWriter.Write(", ");
WriteComponentChildContentInnards(context, childContents[i]);
remaining--;
if (remaining > 0)
{
context.CodeWriter.Write(", ");
}
}
for (var i = 0; i < captures.Count; i++)
{
context.CodeWriter.Write("-1");
context.CodeWriter.Write(", ");
WriteReferenceCaptureInnards(context, captures[i], shouldTypeCheck: false);
remaining--;
if (remaining > 0)
{
context.CodeWriter.Write(", ");
}
}
context.CodeWriter.Write(");");
context.CodeWriter.WriteLine();
}
}
@ -392,15 +473,28 @@ namespace Microsoft.AspNetCore.Blazor.Razor
throw new ArgumentNullException(nameof(node));
}
// For design time we only care about the case where the attribute has c# code.
//
// We also limit component attributes to simple cases. However there is still a lot of complexity
// Looks like:
// __o = 17;
context.CodeWriter.Write(DesignTimeVariable);
context.CodeWriter.Write(" = ");
// Following the same design pattern as the runtime codegen
WriteComponentAttributeInnards(context, node, canTypeCheck: true);
context.CodeWriter.Write(";");
context.CodeWriter.WriteLine();
}
private void WriteComponentAttributeInnards(CodeRenderingContext context, ComponentAttributeExtensionNode node, bool canTypeCheck)
{
// We limit component attributes to simple cases. However there is still a lot of complexity
// to handle here, since there are a few different cases for how an attribute might be structured.
//
// This roughly follows the design of the runtime writer for simplicity.
if (node.AttributeStructure == AttributeStructure.Minimized)
{
// Do nothing
// Minimized attributes always map to 'true'
context.CodeWriter.Write("true");
}
else if (node.Children.Count > 1)
{
@ -409,7 +503,8 @@ namespace Microsoft.AspNetCore.Blazor.Razor
}
else if (node.Children.Count == 1 && node.Children[0] is HtmlContentIntermediateNode)
{
// Do nothing
// We don't actually need the content at designtime, an empty string will do.
context.CodeWriter.Write("\"\"");
}
else
{
@ -430,11 +525,12 @@ namespace Microsoft.AspNetCore.Blazor.Razor
{
// We always surround the expression with the delegate constructor. This makes type
// inference inside lambdas, and method group conversion do the right thing.
context.CodeWriter.Write(DesignTimeVariable);
context.CodeWriter.Write(" = ");
context.CodeWriter.Write("new ");
context.CodeWriter.Write(node.TypeName);
context.CodeWriter.Write("(");
if (canTypeCheck)
{
context.CodeWriter.Write("new ");
context.CodeWriter.Write(node.TypeName);
context.CodeWriter.Write("(");
}
context.CodeWriter.WriteLine();
for (var i = 0; i < tokens.Count; i++)
@ -442,17 +538,17 @@ namespace Microsoft.AspNetCore.Blazor.Razor
WriteCSharpToken(context, tokens[i]);
}
context.CodeWriter.Write(");");
context.CodeWriter.WriteLine();
if (canTypeCheck)
{
context.CodeWriter.Write(")");
}
}
else
{
// This is the case when an attribute contains C# code
context.CodeWriter.Write(DesignTimeVariable);
context.CodeWriter.Write(" = ");
//
// If we have a parameter type, then add a type check.
if (NeedsTypeCheck(node))
if (canTypeCheck && NeedsTypeCheck(node))
{
context.CodeWriter.Write(BlazorApi.RuntimeHelpers.TypeCheck);
context.CodeWriter.Write("<");
@ -466,13 +562,10 @@ namespace Microsoft.AspNetCore.Blazor.Razor
WriteCSharpToken(context, tokens[i]);
}
if (NeedsTypeCheck(node))
if (canTypeCheck && NeedsTypeCheck(node))
{
context.CodeWriter.Write(")");
}
context.CodeWriter.Write(";");
context.CodeWriter.WriteLine();
}
}
@ -500,10 +593,30 @@ namespace Microsoft.AspNetCore.Blazor.Razor
throw new ArgumentNullException(nameof(node));
}
// Writes something like:
//
// builder.AddAttribute(1, "ChildContent", (RenderFragment)((__builder73) => { ... }));
// OR
// builder.AddAttribute(1, "ChildContent", (RenderFragment<Person>)((person) => (__builder73) => { ... }));
BeginWriteAttribute(context.CodeWriter, node.AttributeName);
context.CodeWriter.Write($"({node.TypeName})(");
WriteComponentChildContentInnards(context, node);
context.CodeWriter.Write(")");
context.CodeWriter.WriteEndMethodInvocation();
}
private void WriteComponentChildContentInnards(CodeRenderingContext context, ComponentChildContentIntermediateNode node)
{
// Writes something like:
//
// ((__builder73) => { ... })
// OR
// ((person) => (__builder73) => { })
_scopeStack.OpenComponentScope(
context,
node.AttributeName,
node.TypeName,
node.IsParameterized ? node.ParameterName : null);
for (var i = 0; i < node.Children.Count; i++)
{
@ -559,42 +672,83 @@ namespace Microsoft.AspNetCore.Blazor.Razor
throw new ArgumentNullException(nameof(node));
}
// Looks like:
//
// (__builder73) => { ... }
_scopeStack.OpenTemplateScope(context);
context.RenderChildren(node);
_scopeStack.CloseScope(context);
}
public override void WriteReferenceCapture(CodeRenderingContext context, RefExtensionNode refNode)
public override void WriteReferenceCapture(CodeRenderingContext context, RefExtensionNode node)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (refNode == null)
if (node == null)
{
throw new ArgumentNullException(nameof(refNode));
throw new ArgumentNullException(nameof(node));
}
// The runtime node writer moves the call elsewhere. At design time we
// just want sufficiently similar code that any unknown-identifier or type
// errors will be equivalent
var captureTypeName = refNode.IsComponentCapture
? refNode.ComponentCaptureTypeName
: BlazorApi.ElementRef.FullTypeName;
WriteCSharpCode(context, new CSharpCodeIntermediateNode
// Looks like:
//
// __field = default(MyComponent);
WriteReferenceCaptureInnards(context, node, shouldTypeCheck: true);
}
protected override void WriteReferenceCaptureInnards(CodeRenderingContext context, RefExtensionNode node, bool shouldTypeCheck)
{
// We specialize this code based on whether or not we can type check. When we're calling into
// a type-inferenced component, we can't do the type check. See the comments in WriteTypeInferenceMethod.
if (shouldTypeCheck)
{
Source = refNode.Source,
Children =
// The runtime node writer moves the call elsewhere. At design time we
// just want sufficiently similar code that any unknown-identifier or type
// errors will be equivalent
var captureTypeName = node.IsComponentCapture
? node.ComponentCaptureTypeName
: BlazorApi.ElementRef.FullTypeName;
WriteCSharpCode(context, new CSharpCodeIntermediateNode
{
refNode.IdentifierToken,
new IntermediateToken
Source = node.Source,
Children =
{
Kind = TokenKind.CSharp,
Content = $" = default({captureTypeName});"
node.IdentifierToken,
new IntermediateToken
{
Kind = TokenKind.CSharp,
Content = $" = default({captureTypeName});"
}
}
});
}
else
{
// Looks like:
//
// (__value) = { _field = (MyComponent)__value; }
// OR
// (__value) = { _field = (ElementRef)__value; }
const string refCaptureParamName = "__value";
using (var lambdaScope = context.CodeWriter.BuildLambda(refCaptureParamName))
{
WriteCSharpCode(context, new CSharpCodeIntermediateNode
{
Source = node.Source,
Children =
{
node.IdentifierToken,
new IntermediateToken
{
Kind = TokenKind.CSharp,
Content = $" = {refCaptureParamName};"
}
}
});
}
});
}
}
private void WriteCSharpToken(CodeRenderingContext context, IntermediateToken token)

View File

@ -280,6 +280,24 @@ namespace Microsoft.AspNetCore.Blazor.Razor
var attributesText = string.Join(", ", attributes.Select(a => $"'{a.Name}'"));
return RazorDiagnostic.Create(GenericComponentMissingTypeArgument, source ?? SourceSpan.Undefined, component.TagName, attributesText);
}
public static readonly RazorDiagnosticDescriptor GenericComponentTypeInferenceUnderspecified =
new RazorDiagnosticDescriptor(
"BL10001",
() => "The type of component '{0}' cannot be inferred based on the values provided. Consider specifying the type arguments " +
"directly using the following attributes: {1}.",
RazorDiagnosticSeverity.Error);
public static RazorDiagnostic Create_GenericComponentTypeInferenceUnderspecified(
SourceSpan? source,
ComponentExtensionNode component,
IEnumerable<BoundAttributeDescriptor> attributes)
{
Debug.Assert(component.Component.IsGenericTypedComponent());
var attributesText = string.Join(", ", attributes.Select(a => $"'{a.Name}'"));
return RazorDiagnostic.Create(GenericComponentTypeInferenceUnderspecified, source ?? SourceSpan.Undefined, component.TagName, attributesText);
}
}
}

View File

@ -1,11 +1,13 @@
// 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;
using System.Linq;
using Microsoft.AspNetCore.Blazor.Shared;
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.AspNetCore.Blazor.Razor
{
@ -27,6 +29,8 @@ namespace Microsoft.AspNetCore.Blazor.Razor
public abstract void WriteReferenceCapture(CodeRenderingContext context, RefExtensionNode node);
protected abstract void WriteReferenceCaptureInnards(CodeRenderingContext context, RefExtensionNode node, bool shouldTypeCheck);
public abstract void WriteTemplate(CodeRenderingContext context, TemplateIntermediateNode node);
public sealed override void BeginWriterScope(CodeRenderingContext context, string writer)
@ -49,5 +53,166 @@ namespace Microsoft.AspNetCore.Blazor.Razor
context.Diagnostics.Add(BlazorDiagnosticFactory.Create_CodeBlockInAttribute(node.Source, content));
return;
}
// Currently the same for design time and runtime
public void WriteComponentTypeInferenceMethod(CodeRenderingContext context, ComponentTypeInferenceMethodIntermediateNode node)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (node == null)
{
throw new ArgumentNullException(nameof(node));
}
// This is ugly because CodeWriter doesn't allow us to erase, but we need to comma-delimit. So we have to
// materizalize something can iterate, or use string.Join. We'll need this multiple times, so materializing
// it.
var parameters = GetParameterDeclarations();
// This is really similar to the code in WriteComponentAttribute and WriteComponentChildContent - except simpler because
// attributes and child contents look like variables.
//
// Looks like:
//
// public static void CreateFoo_0<T1, T2>(RenderTreeBuilder builder, int seq, int __seq0, T1 __arg0, int __seq1, global::System.Collections.Generic.List<T2> __arg1, int __seq2, string __arg2)
// {
// builder.OpenComponent<Foo<T1, T2>>();
// builder.AddAttribute(__seq0, "Attr0", __arg0);
// builder.AddAttribute(__seq1, "Attr1", __arg1);
// builder.AddAttribute(__seq2, "Attr2", __arg2);
// builder.CloseComponent();
// }
//
// As a special case, we need to generate a thunk for captures in this block instead of using
// them verbatim.
//
// The problem is that RenderTreeBuilder wants an Action<object>. The caller can't write the type
// name if it contains generics, and we can't write the variable they want to assign to.
var writer = context.CodeWriter;
writer.Write("public static void ");
writer.Write(node.MethodName);
writer.Write("<");
writer.Write(string.Join(", ", node.Component.Component.GetTypeParameters().Select(a => a.Name)));
writer.Write(">");
writer.Write("(");
writer.Write("global::");
writer.Write(BlazorApi.RenderTreeBuilder.FullTypeName);
writer.Write(" builder");
writer.Write(", ");
writer.Write("int seq");
if (parameters.Count > 0)
{
writer.Write(", ");
}
for (var i = 0; i < parameters.Count; i++)
{
writer.Write("int ");
writer.Write(parameters[i].seqName);
writer.Write(", ");
writer.Write(parameters[i].typeName);
writer.Write(" ");
writer.Write(parameters[i].parameterName);
if (i < parameters.Count - 1)
{
writer.Write(", ");
}
}
writer.Write(")");
writer.WriteLine();
writer.WriteLine("{");
// builder.OpenComponent<TComponent>(42);
context.CodeWriter.Write("builder");
context.CodeWriter.Write(".");
context.CodeWriter.Write(BlazorApi.RenderTreeBuilder.OpenComponent);
context.CodeWriter.Write("<");
context.CodeWriter.Write(node.Component.TypeName);
context.CodeWriter.Write(">(");
context.CodeWriter.Write("seq");
context.CodeWriter.Write(");");
context.CodeWriter.WriteLine();
var index = 0;
foreach (var attribute in node.Component.Attributes)
{
context.CodeWriter.WriteStartInstanceMethodInvocation("builder", BlazorApi.RenderTreeBuilder.AddAttribute);
context.CodeWriter.Write(parameters[index].seqName);
context.CodeWriter.Write(", ");
context.CodeWriter.Write($"\"{attribute.AttributeName}\"");
context.CodeWriter.Write(", ");
context.CodeWriter.Write(parameters[index].parameterName);
context.CodeWriter.WriteEndMethodInvocation();
index++;
}
foreach (var childContent in node.Component.ChildContents)
{
context.CodeWriter.WriteStartInstanceMethodInvocation("builder", BlazorApi.RenderTreeBuilder.AddAttribute);
context.CodeWriter.Write(parameters[index].seqName);
context.CodeWriter.Write(", ");
context.CodeWriter.Write($"\"{childContent.AttributeName}\"");
context.CodeWriter.Write(", ");
context.CodeWriter.Write(parameters[index].parameterName);
context.CodeWriter.WriteEndMethodInvocation();
index++;
}
foreach (var capture in node.Component.Captures)
{
context.CodeWriter.WriteStartInstanceMethodInvocation("builder", capture.IsComponentCapture ? BlazorApi.RenderTreeBuilder.AddComponentReferenceCapture : BlazorApi.RenderTreeBuilder.AddElementReferenceCapture);
context.CodeWriter.Write(parameters[index].seqName);
context.CodeWriter.Write(", ");
var cast = capture.IsComponentCapture ? $"({capture.ComponentCaptureTypeName})" : string.Empty;
context.CodeWriter.Write($"(__value) => {{ {parameters[index].parameterName}({cast}__value); }}");
context.CodeWriter.WriteEndMethodInvocation();
index++;
}
context.CodeWriter.WriteInstanceMethodInvocation("builder", BlazorApi.RenderTreeBuilder.CloseComponent);
writer.WriteLine("}");
List<(string seqName, string typeName, string parameterName)> GetParameterDeclarations()
{
var p = new List<(string seqName, string typeName, string parameterName)>();
foreach (var attribute in node.Component.Attributes)
{
p.Add(($"__seq{p.Count}", attribute.TypeName, $"__arg{p.Count}"));
}
foreach (var childContent in node.Component.ChildContents)
{
p.Add(($"__seq{p.Count}", childContent.TypeName, $"__arg{p.Count}"));
}
foreach (var capture in node.Component.Captures)
{
p.Add(($"__seq{p.Count}", capture.TypeName, $"__arg{p.Count}"));
}
return p;
}
}
}
}

View File

@ -197,16 +197,12 @@ namespace Microsoft.AspNetCore.Blazor.Razor
context.RenderNode(capture);
}
_scopeStack.OpenElementScope(node.TagName);
// Render body of the tag inside the scope
foreach (var child in node.Body)
{
context.RenderNode(child);
}
_scopeStack.CloseScope(context);
context.CodeWriter
.WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{BlazorApi.RenderTreeBuilder.CloseElement}")
.WriteEndMethodInvocation();
@ -296,41 +292,126 @@ namespace Microsoft.AspNetCore.Blazor.Razor
throw new ArgumentNullException(nameof(node));
}
// builder.OpenComponent<TComponent>(42);
context.CodeWriter.Write(_scopeStack.BuilderVarName);
context.CodeWriter.Write(".");
context.CodeWriter.Write(BlazorApi.RenderTreeBuilder.OpenComponent);
context.CodeWriter.Write("<");
context.CodeWriter.Write(node.TypeName);
context.CodeWriter.Write(">(");
context.CodeWriter.Write((_sourceSequence++).ToString());
context.CodeWriter.Write(");");
context.CodeWriter.WriteLine();
// We can skip type arguments during runtime codegen, they are handled in the
// type/parameter declarations.
foreach (var attribute in node.Attributes)
if (node.TypeInferenceNode == null)
{
context.RenderNode(attribute);
}
foreach (var childContent in node.ChildContents)
{
context.RenderNode(childContent);
}
// If the component is using not using type inference then we just write an open/close with a series
// of add attribute calls in between.
//
// Writes something like:
//
// builder.OpenComponent<MyComponent>(0);
// builder.AddAttribute(1, "Foo", ...);
// builder.AddAttribute(2, "ChildContent", ...);
// builder.AddElementCapture(3, (__value) => _field = __value);
// builder.CloseComponent();
foreach (var capture in node.Captures)
{
context.RenderNode(capture);
}
// builder.OpenComponent<TComponent>(42);
context.CodeWriter.Write(_scopeStack.BuilderVarName);
context.CodeWriter.Write(".");
context.CodeWriter.Write(BlazorApi.RenderTreeBuilder.OpenComponent);
context.CodeWriter.Write("<");
context.CodeWriter.Write(node.TypeName);
context.CodeWriter.Write(">(");
context.CodeWriter.Write((_sourceSequence++).ToString());
context.CodeWriter.Write(");");
context.CodeWriter.WriteLine();
// builder.CloseComponent();
context.CodeWriter.Write(_scopeStack.BuilderVarName);
context.CodeWriter.Write(".");
context.CodeWriter.Write(BlazorApi.RenderTreeBuilder.CloseComponent);
context.CodeWriter.Write("();");
context.CodeWriter.WriteLine();
// We can skip type arguments during runtime codegen, they are handled in the
// type/parameter declarations.
foreach (var attribute in node.Attributes)
{
context.RenderNode(attribute);
}
foreach (var childContent in node.ChildContents)
{
context.RenderNode(childContent);
}
foreach (var capture in node.Captures)
{
context.RenderNode(capture);
}
// builder.CloseComponent();
context.CodeWriter.Write(_scopeStack.BuilderVarName);
context.CodeWriter.Write(".");
context.CodeWriter.Write(BlazorApi.RenderTreeBuilder.CloseComponent);
context.CodeWriter.Write("();");
context.CodeWriter.WriteLine();
}
else
{
// When we're doing type inference, we can't write all of the code inline to initialize
// the component on the builder. We generate a method elsewhere, and then pass all of the information
// to that method. We pass in all of the attribute values + the sequence numbers.
//
// __Blazor.MyComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, ..., 2, ..., 3, ...);
var attributes = node.Attributes.ToList();
var childContents = node.ChildContents.ToList();
var captures = node.Captures.ToList();
var remaining = attributes.Count + childContents.Count + captures.Count;
context.CodeWriter.Write(node.TypeInferenceNode.FullTypeName);
context.CodeWriter.Write(".");
context.CodeWriter.Write(node.TypeInferenceNode.MethodName);
context.CodeWriter.Write("(");
context.CodeWriter.Write(_scopeStack.BuilderVarName);
context.CodeWriter.Write(", ");
context.CodeWriter.Write((_sourceSequence++).ToString());
context.CodeWriter.Write(", ");
for (var i = 0; i < attributes.Count; i++)
{
context.CodeWriter.Write((_sourceSequence++).ToString());
context.CodeWriter.Write(", ");
// Don't type check generics, since we can't actually write the type name.
// The type checking with happen anyway since we defined a method and we're generating
// a call to it.
WriteComponentAttributeInnards(context, attributes[i], canTypeCheck: false);
remaining--;
if (remaining > 0)
{
context.CodeWriter.Write(", ");
}
}
for (var i = 0; i < childContents.Count; i++)
{
context.CodeWriter.Write((_sourceSequence++).ToString());
context.CodeWriter.Write(", ");
WriteComponentChildContentInnards(context, childContents[i]);
remaining--;
if (remaining > 0)
{
context.CodeWriter.Write(", ");
}
}
for (var i = 0; i < captures.Count; i++)
{
context.CodeWriter.Write((_sourceSequence++).ToString());
context.CodeWriter.Write(", ");
WriteReferenceCaptureInnards(context, captures[i], shouldTypeCheck: false);
remaining--;
if (remaining > 0)
{
context.CodeWriter.Write(", ");
}
}
context.CodeWriter.Write(");");
context.CodeWriter.WriteLine();
}
}
public override void WriteComponentAttribute(CodeRenderingContext context, ComponentAttributeExtensionNode node)
@ -345,7 +426,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
throw new ArgumentNullException(nameof(node));
}
// builder.OpenComponent<TComponent>(42);
// builder.AddAttribute(1, "Foo", 42);
context.CodeWriter.Write(_scopeStack.BuilderVarName);
context.CodeWriter.Write(".");
context.CodeWriter.Write(BlazorApi.RenderTreeBuilder.AddAttribute);
@ -355,6 +436,14 @@ namespace Microsoft.AspNetCore.Blazor.Razor
context.CodeWriter.WriteStringLiteral(node.AttributeName);
context.CodeWriter.Write(", ");
WriteComponentAttributeInnards(context, node, canTypeCheck: true);
context.CodeWriter.Write(");");
context.CodeWriter.WriteLine();
}
private void WriteComponentAttributeInnards(CodeRenderingContext context, ComponentAttributeExtensionNode node, bool canTypeCheck)
{
if (node.AttributeStructure == AttributeStructure.Minimized)
{
// Minimized attributes always map to 'true'
@ -378,20 +467,26 @@ namespace Microsoft.AspNetCore.Blazor.Razor
if ((node.BoundAttribute?.IsDelegateProperty() ?? false) ||
(node.BoundAttribute?.IsChildContentProperty() ?? false))
{
context.CodeWriter.Write("new ");
context.CodeWriter.Write(node.TypeName);
context.CodeWriter.Write("(");
if (canTypeCheck)
{
context.CodeWriter.Write("new ");
context.CodeWriter.Write(node.TypeName);
context.CodeWriter.Write("(");
}
for (var i = 0; i < tokens.Count; i++)
{
context.CodeWriter.Write(tokens[i].Content);
}
context.CodeWriter.Write(")");
if (canTypeCheck)
{
context.CodeWriter.Write(")");
}
}
else
{
if (NeedsTypeCheck(node))
if (canTypeCheck && NeedsTypeCheck(node))
{
context.CodeWriter.Write(BlazorApi.RuntimeHelpers.TypeCheck);
context.CodeWriter.Write("<");
@ -405,16 +500,13 @@ namespace Microsoft.AspNetCore.Blazor.Razor
context.CodeWriter.Write(tokens[i].Content);
}
if (NeedsTypeCheck(node))
if (canTypeCheck && NeedsTypeCheck(node))
{
context.CodeWriter.Write(")");
}
}
}
context.CodeWriter.Write(");");
context.CodeWriter.WriteLine();
IReadOnlyList<IntermediateToken> GetCSharpTokens(ComponentAttributeExtensionNode attribute)
{
// We generally expect all children to be CSharp, this is here just in case.
@ -445,10 +537,30 @@ namespace Microsoft.AspNetCore.Blazor.Razor
throw new ArgumentNullException(nameof(node));
}
// Writes something like:
//
// builder.AddAttribute(1, "ChildContent", (RenderFragment)((__builder73) => { ... }));
// OR
// builder.AddAttribute(1, "ChildContent", (RenderFragment<Person>)((person) => (__builder73) => { ... }));
BeginWriteAttribute(context.CodeWriter, node.AttributeName);
context.CodeWriter.Write($"({node.TypeName})(");
WriteComponentChildContentInnards(context, node);
context.CodeWriter.Write(")");
context.CodeWriter.WriteEndMethodInvocation();
}
private void WriteComponentChildContentInnards(CodeRenderingContext context, ComponentChildContentIntermediateNode node)
{
// Writes something like:
//
// ((__builder73) => { ... })
// OR
// ((person) => (__builder73) => { })
_scopeStack.OpenComponentScope(
context,
node.AttributeName,
node.TypeName,
node.IsParameterized ? node.ParameterName : null);
for (var i = 0; i < node.Children.Count; i++)
{
@ -475,6 +587,9 @@ namespace Microsoft.AspNetCore.Blazor.Razor
throw new ArgumentNullException(nameof(node));
}
// Looks like:
//
// (__builder73) => { ... }
_scopeStack.OpenTemplateScope(context);
context.RenderChildren(node);
_scopeStack.CloseScope(context);
@ -482,6 +597,11 @@ namespace Microsoft.AspNetCore.Blazor.Razor
public override void WriteReferenceCapture(CodeRenderingContext context, RefExtensionNode node)
{
// Looks like:
//
// builder.AddComponentReferenceCapture(2, (__value) = { _field = (MyComponent)__value; });
// OR
// builder.AddElementReferenceCapture(2, (__value) = { _field = (ElementRef)__value; });
var codeWriter = context.CodeWriter;
var methodName = node.IsComponentCapture
@ -492,25 +612,36 @@ namespace Microsoft.AspNetCore.Blazor.Razor
.Write((_sourceSequence++).ToString())
.WriteParameterSeparator();
WriteReferenceCaptureInnards(context, node, shouldTypeCheck: true);
codeWriter.WriteEndMethodInvocation();
}
protected override void WriteReferenceCaptureInnards(CodeRenderingContext context, RefExtensionNode node, bool shouldTypeCheck)
{
// Looks like:
//
// (__value) = { _field = (MyComponent)__value; }
// OR
// (__value) = { _field = (ElementRef)__value; }
const string refCaptureParamName = "__value";
using (var lambdaScope = codeWriter.BuildLambda(refCaptureParamName))
using (var lambdaScope = context.CodeWriter.BuildLambda(refCaptureParamName))
{
var typecastIfNeeded = node.IsComponentCapture ? $"({node.ComponentCaptureTypeName})" : string.Empty;
var typecastIfNeeded = shouldTypeCheck && node.IsComponentCapture ? $"({node.ComponentCaptureTypeName})" : string.Empty;
WriteCSharpCode(context, new CSharpCodeIntermediateNode
{
Source = node.Source,
Children =
{
node.IdentifierToken,
new IntermediateToken {
new IntermediateToken
{
Kind = TokenKind.CSharp,
Content = $" = {typecastIfNeeded}{refCaptureParamName};"
}
}
});
}
codeWriter.WriteEndMethodInvocation();
}
private void WriteAttribute(CodeWriter codeWriter, string key, IList<IntermediateToken> value)

View File

@ -27,6 +27,10 @@ namespace Microsoft.AspNetCore.Blazor.Razor
public string TagName { get; set; }
// An optional type inference node. This will be populated (and point to a different part of the tree)
// if this component call site requires type inference.
public ComponentTypeInferenceMethodIntermediateNode TypeInferenceNode { get; set; }
public string TypeName { get; set; }
public override void Accept(IntermediateNodeVisitor visitor)

View File

@ -0,0 +1,61 @@
// 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;
using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
namespace Microsoft.AspNetCore.Blazor.Razor
{
/// <summary>
/// Represents a type-inference thunk that is used by the generated component code.
/// </summary>
internal class ComponentTypeInferenceMethodIntermediateNode : ExtensionIntermediateNode
{
public Dictionary<string, GenericTypeNameRewriter.Binding> Bindings { get; set; }
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
/// <summary>
/// Gets the component usage linked to this type inference method.
/// </summary>
public ComponentExtensionNode Component { get; set; }
/// <summary>
/// Gets the full type name of the generated class containing this method.
/// </summary>
public string FullTypeName { get; internal set; }
/// <summary>
/// Gets the name of the generated method.
/// </summary>
public string MethodName { get; set; }
public override void Accept(IntermediateNodeVisitor visitor)
{
if (visitor == null)
{
throw new ArgumentNullException(nameof(visitor));
}
AcceptExtensionNode<ComponentTypeInferenceMethodIntermediateNode>(this, visitor);
}
public override void WriteNode(CodeTarget target, CodeRenderingContext context)
{
if (target == null)
{
throw new ArgumentNullException(nameof(target));
}
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
var writer = (BlazorNodeWriter)context.NodeWriter;
writer.WriteComponentTypeInferenceMethod(context, this);
}
}
}

View File

@ -1,12 +1,11 @@
// 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;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Blazor.Shared;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@ -28,9 +27,12 @@ namespace Microsoft.AspNetCore.Blazor.Razor
visitor.Visit(documentNode);
}
private class Visitor : IntermediateNodeWalker, IExtensionIntermediateNodeVisitor<ComponentExtensionNode>
{
// Incrementing ID for type inference method names
private int _id;
public void VisitExtension(ComponentExtensionNode node)
{
if (node.Component.IsGenericTypedComponent())
@ -45,20 +47,112 @@ namespace Microsoft.AspNetCore.Blazor.Razor
private void Process(ComponentExtensionNode node)
{
// First collect all of the information we have about each type parameter
//
// Listing all type parameters that exist
var bindings = new Dictionary<string, GenericTypeNameRewriter.Binding>();
foreach (var attribute in node.Component.GetTypeParameters())
{
bindings.Add(attribute.Name, new GenericTypeNameRewriter.Binding() { Attribute = attribute, });
}
// Listing all type arguments that have been specified.
var hasTypeArgumentSpecified = false;
foreach (var typeArgumentNode in node.TypeArguments)
{
hasTypeArgumentSpecified = true;
var binding = bindings[typeArgumentNode.TypeParameterName];
binding.Node = typeArgumentNode;
binding.Content = GetContent(typeArgumentNode);
}
// Right now we don't have type inference, so all type arguments are required.
if (hasTypeArgumentSpecified)
{
// OK this means that the developer has specified at least one type parameter.
// Either they specified everything and its OK to rewrite, or its an error.
if (ValidateTypeArguments(node, bindings))
{
RewriteTypeNames(new GenericTypeNameRewriter(bindings), node);
}
return;
}
// OK if we get here that means that no type arguments were specified, so we will try to infer
// the type.
//
// The actual inference is done by the C# compiler, we just emit an a method that represents the
// use of this component.
// Since we're generating code in a different namespace, we need to 'global qualify' all of the types
// to avoid clashes with our generated code.
RewriteTypeNames(new GlobalQualifiedTypeNameRewriter(bindings.Keys), node);
//
// We need to verify that an argument was provided that 'covers' each type parameter.
//
// For example, consider a repeater where the generic type is the 'item' type, but the developer has
// not set the items. We won't be able to do type inference on this and so it will just be nonesense.
var attributes = node.Attributes.Select(a => a.BoundAttribute).Concat(node.ChildContents.Select(c => c.BoundAttribute));
foreach (var attribute in attributes)
{
if (attribute == null)
{
// Will be null for attributes set on the component that don't match a declared component parameter
continue;
}
// Now we need to parse the type name and extract the generic parameters.
//
// Two cases;
// 1. name is a simple identifier like TItem
// 2. name contains type parameters like Dictionary<string, TItem>
if (!attribute.IsGenericTypedProperty())
{
continue;
}
var parsed = SyntaxFactory.ParseTypeName(attribute.TypeName);
if (parsed is IdentifierNameSyntax identifier)
{
bindings.Remove(identifier.ToString());
}
else
{
var typeParameters = parsed.DescendantNodesAndSelf().OfType<TypeArgumentListSyntax>().SelectMany(arg => arg.Arguments);
foreach (var typeParameter in typeParameters)
{
bindings.Remove(typeParameter.ToString());
}
}
}
// If any bindings remain then this means we would never be able to infer the arguments of this
// component usage because the user hasn't set properties that include all of the types.
if (bindings.Count > 0)
{
// However we still want to generate 'type inference' code because we want the errors to be as
// helpful as possible. So let's substitute 'object' for all of those type parameters, and add
// an error.
RewriteTypeNames(new GenericTypeNameRewriter(bindings), node);
node.Diagnostics.Add(BlazorDiagnosticFactory.Create_GenericComponentTypeInferenceUnderspecified(node.Source, node, node.Component.GetTypeParameters()));
}
// Next we need to generate a type inference 'method' node. This repesents a method that we will codegen that
// contains all of the operations on the render tree building. Calling a method to operate on the builder
// will allow the C# compiler to perform type inference.
var documentNode = (DocumentIntermediateNode)Ancestors[Ancestors.Count - 1];
CreateTypeInferenceMethod(documentNode, node, bindings);
}
private string GetContent(ComponentTypeArgumentExtensionNode node)
{
return string.Join(string.Empty, node.FindDescendantNodes<IntermediateToken>().Where(t => t.IsCSharp).Select(t => t.Content));
}
private static bool ValidateTypeArguments(ComponentExtensionNode node, Dictionary<string, GenericTypeNameRewriter.Binding> bindings)
{
var missing = new List<BoundAttributeDescriptor>();
foreach (var binding in bindings)
{
@ -74,10 +168,14 @@ namespace Microsoft.AspNetCore.Blazor.Razor
// to incorrect codegen without the types. Our errors message will pretty clearly indicate
// what to do, whereas the other errors might be confusing.
node.Diagnostics.Add(BlazorDiagnosticFactory.Create_GenericComponentMissingTypeArgument(node.Source, node, missing));
return false;
}
var rewriter = new GenericTypeNameRewriter(bindings);
return true;
}
private void RewriteTypeNames(CSharpSyntaxRewriter rewriter, ComponentExtensionNode node)
{
// Rewrite the component type name
node.TypeName = RewriteTypeName(rewriter, node.TypeName);
@ -89,6 +187,28 @@ namespace Microsoft.AspNetCore.Blazor.Razor
// the known types.
attribute.TypeName = RewriteTypeName(rewriter, attribute.TypeName);
}
else if (attribute.TypeName == null && (attribute.BoundAttribute?.IsDelegateProperty() ?? false))
{
// This is a weakly typed delegate, treat it as Action<object>
attribute.TypeName = "System.Action<System.Object>";
}
else if (attribute.TypeName == null)
{
// This is a weakly typed attribute, treat it as System.Object
attribute.TypeName = "System.Object";
}
}
foreach (var capture in node.Captures)
{
if (capture.IsComponentCapture && capture.ComponentCaptureTypeName != null)
{
capture.ComponentCaptureTypeName = RewriteTypeName(rewriter, capture.ComponentCaptureTypeName);
}
else if (capture.IsComponentCapture)
{
capture.ComponentCaptureTypeName = "System.Object";
}
}
foreach (var childContent in node.ChildContents)
@ -99,19 +219,86 @@ namespace Microsoft.AspNetCore.Blazor.Razor
// the known types.
childContent.TypeName = RewriteTypeName(rewriter, childContent.TypeName);
}
else if (childContent.IsParameterized)
{
// This is a weakly typed parameterized child content, treat it as RenderFragment<object>
childContent.TypeName = BlazorApi.RenderFragment.FullTypeName + "<System.Object>";
}
else
{
// This is a weakly typed child content, treat it as RenderFragment
childContent.TypeName = BlazorApi.RenderFragment.FullTypeName;
}
}
}
private string RewriteTypeName(GenericTypeNameRewriter rewriter, string typeName)
private string RewriteTypeName(CSharpSyntaxRewriter rewriter, string typeName)
{
var parsed = SyntaxFactory.ParseTypeName(typeName);
var rewritten = (TypeSyntax)rewriter.Visit(parsed);
return rewritten.ToFullString();
}
private string GetContent(ComponentTypeArgumentExtensionNode node)
private void CreateTypeInferenceMethod(
DocumentIntermediateNode documentNode,
ComponentExtensionNode node,
Dictionary<string, GenericTypeNameRewriter.Binding> bindings)
{
return string.Join(string.Empty, node.FindDescendantNodes<IntermediateToken>().Where(t => t.IsCSharp).Select(t => t.Content));
var @namespace = documentNode.FindPrimaryNamespace().Content;
@namespace = string.IsNullOrEmpty(@namespace) ? "__Blazor" : "__Blazor." + @namespace;
@namespace += "." + documentNode.FindPrimaryClass().ClassName;
var typeInferenceNode = new ComponentTypeInferenceMethodIntermediateNode()
{
Bindings = bindings,
Component = node,
// Method name is generated and guaraneteed not to collide, since it's unique for each
// component call site.
MethodName = $"Create{node.TagName}_{_id++}",
FullTypeName = @namespace + ".TypeInference",
};
node.TypeInferenceNode = typeInferenceNode;
// Now we need to insert the type inference node into the tree.
var namespaceNode = documentNode.Children
.OfType<NamespaceDeclarationIntermediateNode>()
.Where(n => n.Annotations.Contains(new KeyValuePair<object, object>(BlazorMetadata.Component.GenericTypedKey, bool.TrueString)))
.FirstOrDefault();
if (namespaceNode == null)
{
namespaceNode = new NamespaceDeclarationIntermediateNode()
{
Annotations =
{
{ BlazorMetadata.Component.GenericTypedKey, bool.TrueString },
},
Content = @namespace,
};
documentNode.Children.Add(namespaceNode);
}
var classNode = namespaceNode.Children
.OfType<ClassDeclarationIntermediateNode>()
.Where(n => n.ClassName == "TypeInference")
.FirstOrDefault();
if (classNode == null)
{
classNode = new ClassDeclarationIntermediateNode()
{
ClassName = "TypeInference",
Modifiers =
{
"internal",
"static",
},
};
namespaceNode.Children.Add(classNode);
}
classNode.Children.Add(typeInferenceNode);
}
}
}

View File

@ -0,0 +1,62 @@
// 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 Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace Microsoft.AspNetCore.Blazor.Razor
{
// Rewrites type names to use the 'global::' prefix for identifiers.
//
// This is useful when we're generating code in a different namespace than
// what the user code lives in. When we synthesize a namespace it's easy to have
// clashes.
internal class GlobalQualifiedTypeNameRewriter : CSharpSyntaxRewriter
{
// List of names to ignore.
//
// NOTE: this is the list of type parameters defined on the component.
private readonly HashSet<string> _ignore;
public GlobalQualifiedTypeNameRewriter(IEnumerable<string> ignore)
{
_ignore = new HashSet<string>(ignore);
}
public override SyntaxNode Visit(SyntaxNode node)
{
return base.Visit(node);
}
public override SyntaxNode VisitQualifiedName(QualifiedNameSyntax node)
{
if (node.Parent is QualifiedNameSyntax)
{
return base.VisitQualifiedName(node);
}
// Need to rewrite postorder so we can rewrite the names of generic type arguments.
node = (QualifiedNameSyntax)base.VisitQualifiedName(node);
// Rewriting these is complicated, best to just tostring and parse again.
return SyntaxFactory.ParseTypeName("global::" + node.ToString());
}
public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax node)
{
if (_ignore.Contains(node.ToString()))
{
return node;
}
if (node.Parent != null)
{
return node;
}
return SyntaxFactory.AliasQualifiedName(SyntaxFactory.IdentifierName(SyntaxFactory.Token(SyntaxKind.GlobalKeyword)), node);
}
}
}

View File

@ -1,6 +1,7 @@
// 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;
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
using System;
@ -9,14 +10,6 @@ namespace Microsoft.AspNetCore.Blazor.Razor
{
internal class RefExtensionNode : ExtensionIntermediateNode
{
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
public IntermediateToken IdentifierToken { get; }
public bool IsComponentCapture { get; }
public string ComponentCaptureTypeName { get; }
public RefExtensionNode(IntermediateToken identifierToken)
{
IdentifierToken = identifierToken ?? throw new ArgumentNullException(nameof(identifierToken));
@ -35,6 +28,16 @@ namespace Microsoft.AspNetCore.Blazor.Razor
ComponentCaptureTypeName = componentCaptureTypeName;
}
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
public IntermediateToken IdentifierToken { get; }
public bool IsComponentCapture { get; }
public string ComponentCaptureTypeName { get; set; }
public string TypeName => $"global::System.Action<{(IsComponentCapture ? ComponentCaptureTypeName : "global::" + BlazorApi.ElementRef.FullTypeName)}>";
public override void Accept(IntermediateNodeVisitor visitor)
{
if (visitor == null)

View File

@ -1,11 +1,9 @@
// 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;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
namespace Microsoft.AspNetCore.Blazor.Razor
{
@ -21,27 +19,18 @@ namespace Microsoft.AspNetCore.Blazor.Razor
public string BuilderVarName { get; private set; } = "builder";
public void OpenElementScope(string tagName)
{
_stack.Push(new ScopeEntry(tagName, ScopeKind.Element));
}
public void OpenComponentScope(CodeRenderingContext context, string name, string type, string parameterName)
public void OpenComponentScope(CodeRenderingContext context, string name, string parameterName)
{
var scope = new ScopeEntry(name, ScopeKind.Component);
_stack.Push(scope);
var blazorNodeWriter = (BlazorNodeWriter)context.NodeWriter;
blazorNodeWriter.BeginWriteAttribute(context.CodeWriter, name);
OffsetBuilderVarNumber(1);
// Writes code that looks like:
//
// builder.AddAttribute(0, "{name}", ({type})((__builder) => { ... }));
// ((__builder) => { ... })
// OR
// builder.AddAttribute(0, "{name}", ({type})((context) => (__builder) => { ... }));
context.CodeWriter.Write($"({type})(");
// ((context) => (__builder) => { ... })
if (parameterName != null)
{
@ -59,26 +48,13 @@ namespace Microsoft.AspNetCore.Blazor.Razor
// Templates always get a lambda scope, because they are defined as a lambda.
OffsetBuilderVarNumber(1);
currentScope.LambdaScope = context.CodeWriter.BuildLambda(BuilderVarName);
}
public void CloseScope(CodeRenderingContext context)
{
var currentScope = _stack.Pop();
// When closing the scope for a component with children, it's time to close the lambda
if (currentScope.LambdaScope != null)
{
currentScope.LambdaScope.Dispose();
if (currentScope.Kind == ScopeKind.Component)
{
context.CodeWriter.Write(")");
context.CodeWriter.WriteEndMethodInvocation();
}
OffsetBuilderVarNumber(-1);
}
currentScope.LambdaScope.Dispose();
OffsetBuilderVarNumber(-1);
}
private void OffsetBuilderVarNumber(int delta)
@ -108,7 +84,6 @@ namespace Microsoft.AspNetCore.Blazor.Razor
private enum ScopeKind
{
Element,
Component,
Template,
}

View File

@ -1258,6 +1258,116 @@ namespace Test
CompileToAssembly(generated);
}
[Fact]
public void ChildComponent_Generic_TypeInference()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent<TItem> : BlazorComponent
{
[Parameter] TItem Item { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper *, TestAssembly
<MyComponent Item=""@(""hi"")""/>");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void ChildComponent_Generic_TypeInference_Multiple()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent<TItem> : BlazorComponent
{
[Parameter] TItem Item { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper *, TestAssembly
<MyComponent Item=""@(""hi"")""/>
<MyComponent Item=""@(""how are you?"")""/>
<MyComponent Item=""@(""bye!"")""/>");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void ChildComponent_GenericWeaklyTypedAttribute()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent<TItem> : BlazorComponent
{
[Parameter] TItem Item { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper *, TestAssembly
<MyComponent TItem=string Item=""@(""hi"")"" Other=""@(17)""/>");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void ChildComponent_GenericWeaklyTypedAttribute_TypeInference()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent<TItem> : BlazorComponent
{
[Parameter] TItem Item { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper *, TestAssembly
<MyComponent Item=""@(""hi"")"" Other=""@(17)""/>");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void ChildComponent_GenericBind()
{
@ -1271,10 +1381,10 @@ namespace Test
public class MyComponent<TItem> : BlazorComponent
{
[Parameter]
TItem Value { get; set; }
TItem Item { get; set; }
[Parameter]
Action<TItem> ValueChanged { get; set; }
Action<TItem> ItemChanged { get; set; }
}
}
"));
@ -1293,6 +1403,102 @@ namespace Test
CompileToAssembly(generated);
}
[Fact]
public void ChildComponent_GenericBind_TypeInference()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using System;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent<TItem> : BlazorComponent
{
[Parameter]
TItem Item { get; set; }
[Parameter]
Action<TItem> ItemChanged { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper *, TestAssembly
<MyComponent bind-Item=Value/>
@functions {
string Value;
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void ChildComponent_GenericBindWeaklyTyped()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using System;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent<TItem> : BlazorComponent
{
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper *, TestAssembly
<MyComponent TItem=string bind-Item=Value/>
@functions {
string Value;
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void ChildComponent_GenericBindWeaklyTyped_TypeInference()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using System;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent<TItem> : BlazorComponent
{
[Parameter] TItem Value { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper *, TestAssembly
<MyComponent bind-Item=Value Value=@(18)/>
@functions {
string Value;
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void ChildComponent_GenericChildContent()
{
@ -1325,6 +1531,38 @@ namespace Test
CompileToAssembly(generated);
}
[Fact]
public void ChildComponent_GenericChildContent_TypeInference()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent<TItem> : BlazorComponent
{
[Parameter] TItem Item { get; set; }
[Parameter] RenderFragment<TItem> ChildContent { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper *, TestAssembly
<MyComponent Item=""@(""hi"")"">
<div>@context.ToLower()</div>
</MyComponent>");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void ChildComponent_MultipleGenerics()
{
@ -1367,6 +1605,119 @@ namespace Test
CompileToAssembly(generated);
}
[Fact]
public void ChildComponent_MultipleGenerics_TypeInference()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using System.Collections.Generic;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent<TItem1, TItem2> : BlazorComponent
{
[Parameter] TItem1 Item { get; set; }
[Parameter] List<TItem2> Items { get; set; }
[Parameter] RenderFragment<TItem1> ChildContent { get; set; }
[Parameter] RenderFragment<Context> AnotherChildContent { get; set; }
public class Context
{
public TItem2 Item { get; set; }
}
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper *, TestAssembly
<MyComponent Item=""@(""hi"")"" Items=@(new List<long>())>
<ChildContent><div>@context.ToLower()</div></ChildContent>
<AnotherChildContent Context=""item"">
@System.Math.Max(0, item.Item);
</AnotherChildContent>
</MyComponent>");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void GenericComponent_WithComponentRef()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent<TItem> : BlazorComponent
{
[Parameter] TItem Item { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper *, TestAssembly
<MyComponent TItem=int Item=""3"" ref=""_my"" />
@functions {
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
}
");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void GenericComponent_WithComponentRef_TypeInference()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class MyComponent<TItem> : BlazorComponent
{
[Parameter] TItem Item { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper *, TestAssembly
<MyComponent Item=""3"" ref=""_my"" />
@functions {
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
}
");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
#endregion
#region Ref

View File

@ -1,10 +1,12 @@
// 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.Components;
using Microsoft.AspNetCore.Blazor.Razor;
using Microsoft.AspNetCore.Blazor.RenderTree;
using Microsoft.AspNetCore.Blazor.Test.Helpers;
using Microsoft.CodeAnalysis.CSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
@ -28,7 +30,14 @@ namespace Test
var items = (IReadOnlyList<TItem>)Items ?? Array.Empty<TItem>();
for (var i = 0; i < items.Count; i++)
{
builder.AddContent(i, ChildContent, new Context() { Index = i, Item = items[i], });
if (ChildContent == null)
{
builder.AddContent(i, Items[i]);
}
else
{
builder.AddContent(i, ChildContent, new Context() { Index = i, Item = items[i], });
}
}
}
@ -76,6 +85,66 @@ namespace Test
internal override bool UseTwoPhaseCompilation => true;
[Fact]
public void Render_GenericComponent_WithoutChildContent()
{
// Arrange
AdditionalSyntaxTrees.Add(GenericContextComponent);
var component = CompileToComponent(@"
@addTagHelper *, TestAssembly
<GenericContext TItem=int Items=""@(new List<int>() { 1, 2, })"" />");
// Act
var frames = GetRenderTree(component);
// Assert
var genericComponentType = component.GetType().Assembly.DefinedTypes
.Where(t => t.Name == "GenericContext`1")
.Single()
.MakeGenericType(typeof(int));
Assert.Collection(
frames,
frame => AssertFrame.Component(frame, genericComponentType.FullName, 2, 0),
frame => AssertFrame.Attribute(frame, "Items", typeof(List<int>), 1),
frame => AssertFrame.Text(frame, "1", 0),
frame => AssertFrame.Text(frame, "2", 1));
}
[Fact]
public void Render_GenericComponent_WithRef()
{
// Arrange
AdditionalSyntaxTrees.Add(GenericContextComponent);
var component = CompileToComponent(@"
@addTagHelper *, TestAssembly
<GenericContext TItem=int Items=""@(new List<int>() { 1, 2, })"" ref=""_my"" />
@functions {
GenericContext<int> _my;
void Foo() { GC.KeepAlive(_my); }
}");
// Act
var frames = GetRenderTree(component);
// Assert
var genericComponentType = component.GetType().Assembly.DefinedTypes
.Where(t => t.Name == "GenericContext`1")
.Single()
.MakeGenericType(typeof(int));
Assert.Collection(
frames,
frame => AssertFrame.Component(frame, genericComponentType.FullName, 3, 0),
frame => AssertFrame.Attribute(frame, "Items", typeof(List<int>), 1),
frame => AssertFrame.ComponentReferenceCapture(frame, 2),
frame => AssertFrame.Text(frame, "1", 0),
frame => AssertFrame.Text(frame, "2", 1));
}
[Fact]
public void Render_GenericComponent_WithChildContent()
{
@ -112,6 +181,105 @@ namespace Test
frame => AssertFrame.Whitespace(frame, 6));
}
[Fact]
public void Render_GenericComponent_TypeInference_WithRef()
{
// Arrange
AdditionalSyntaxTrees.Add(GenericContextComponent);
var component = CompileToComponent(@"
@addTagHelper *, TestAssembly
<GenericContext Items=""@(new List<int>() { 1, 2, })"" ref=""_my"" />
@functions {
GenericContext<int> _my;
void Foo() { GC.KeepAlive(_my); }
}");
// Act
var frames = GetRenderTree(component);
// Assert
var genericComponentType = component.GetType().Assembly.DefinedTypes
.Where(t => t.Name == "GenericContext`1")
.Single()
.MakeGenericType(typeof(int));
Assert.Collection(
frames,
frame => AssertFrame.Component(frame, genericComponentType.FullName, 3, 0),
frame => AssertFrame.Attribute(frame, "Items", typeof(List<int>), 1),
frame => AssertFrame.ComponentReferenceCapture(frame, 2),
frame => AssertFrame.Text(frame, "1", 0),
frame => AssertFrame.Text(frame, "2", 1));
}
[Fact]
public void Render_GenericComponent_TypeInference_WithRef_Recursive()
{
// Arrange
AdditionalSyntaxTrees.Add(GenericContextComponent);
var assembly = CompileToAssembly("Test.cshtml", @"
@addTagHelper *, TestAssembly
@typeparam TItem
<GenericContext Items=""@MyItems"" ref=""_my"" />
@functions {
[Parameter] List<TItem> MyItems { get; set; }
GenericContext<TItem> _my;
void Foo() { GC.KeepAlive(_my); }
}");
var componentType = assembly.Assembly.DefinedTypes
.Where(t => t.Name == "Test`1")
.Single()
.MakeGenericType(typeof(int));
var component = (IComponent)Activator.CreateInstance(componentType);
// Act
var frames = GetRenderTree(component);
// Assert
var genericComponentType = assembly.Assembly.DefinedTypes
.Where(t => t.Name == "GenericContext`1")
.Single()
.MakeGenericType(typeof(int));
Assert.Collection(
frames,
frame => AssertFrame.Component(frame, genericComponentType.FullName, 3, 0),
frame => AssertFrame.Attribute(frame, "Items", 1),
frame => AssertFrame.ComponentReferenceCapture(frame, 2));
}
[Fact]
public void Render_GenericComponent_TypeInference_WithoutChildContent()
{
// Arrange
AdditionalSyntaxTrees.Add(GenericContextComponent);
var component = CompileToComponent(@"
@addTagHelper *, TestAssembly
<GenericContext Items=""@(new List<int>() { 1, 2, })"" />");
// Act
var frames = GetRenderTree(component);
// Assert
var genericComponentType = component.GetType().Assembly.DefinedTypes
.Where(t => t.Name == "GenericContext`1")
.Single()
.MakeGenericType(typeof(int));
Assert.Collection(
frames,
frame => AssertFrame.Component(frame, genericComponentType.FullName, 2, 0),
frame => AssertFrame.Attribute(frame, "Items", typeof(List<int>), 1),
frame => AssertFrame.Text(frame, "1", 0),
frame => AssertFrame.Text(frame, "2", 1));
}
[Fact]
public void Render_GenericComponent_MultipleParameters_WithChildContent()
{
@ -161,9 +329,10 @@ namespace Test
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
Assert.Same(BlazorDiagnosticFactory.GenericComponentMissingTypeArgument.Id, diagnostic.Id);
Assert.Same(BlazorDiagnosticFactory.GenericComponentTypeInferenceUnderspecified.Id, diagnostic.Id);
Assert.Equal(
"The component 'GenericContext' is missing required type arguments. Specify the missing types using the attributes: 'TItem'.",
"The type of component 'GenericContext' cannot be inferred based on the values provided. Consider " +
"specifying the type arguments directly using the following attributes: 'TItem'.",
diagnostic.GetMessage());
}

View File

@ -20,6 +20,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
IExtensionIntermediateNodeVisitor<ComponentAttributeExtensionNode>,
IExtensionIntermediateNodeVisitor<ComponentChildContentIntermediateNode>,
IExtensionIntermediateNodeVisitor<ComponentTypeArgumentExtensionNode>,
IExtensionIntermediateNodeVisitor<ComponentTypeInferenceMethodIntermediateNode>,
IExtensionIntermediateNodeVisitor<RouteAttributeExtensionNode>,
IExtensionIntermediateNodeVisitor<RefExtensionNode>
{
@ -297,6 +298,11 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
WriteContentNode(node, node.TypeParameterName);
}
void IExtensionIntermediateNodeVisitor<ComponentTypeInferenceMethodIntermediateNode>.VisitExtension(ComponentTypeInferenceMethodIntermediateNode node)
{
WriteContentNode(node, node.FullTypeName, node.MethodName);
}
void IExtensionIntermediateNodeVisitor<RouteAttributeExtensionNode>.VisitExtension(RouteAttributeExtensionNode node)
{
WriteContentNode(node, node.Template);

View File

@ -33,14 +33,15 @@ global::System.Object __typeHelper = "*, TestAssembly";
#line default
#line hidden
);
__o = Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
__o = Microsoft.AspNetCore.Blazor.Components.RuntimeHelpers.TypeCheck<string>(Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
Value
#line default
#line hidden
);
__o = Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => Value = __value, Value);
));
__o = new System.Action<string>(
__value => Value = __value);
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => {
}
));

View File

@ -25,14 +25,14 @@ Document -
ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent<string>
ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem
IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string
ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item -
ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
IntermediateToken - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value
IntermediateToken - - CSharp - )
ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged -
ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - ItemChanged
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => Value = __value, Value)
IntermediateToken - - CSharp - __value => Value = __value
HtmlContent - (74:1,43 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (74:1,43 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)

View File

@ -10,14 +10,14 @@ Generated Location: (1083:30,19 [6] )
Source Location: (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml)
|Value|
Generated Location: (1305:37,36 [5] )
Generated Location: (1377:37,36 [5] )
|Value|
Source Location: (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
|
string Value;
|
Generated Location: (1740:49,12 [21] )
Generated Location: (1779:50,12 [21] )
|
string Value;
|

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 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);
__o = typeof(
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
string
#line default
#line hidden
);
__o = Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
Value
#line default
#line hidden
);
__o = Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => Value = __value, Value);
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => {
}
));
}
#pragma warning restore 1998
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
string Value;
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,39 @@
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 [15] 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 - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent<string>
ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem
IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string
ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
IntermediateToken - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value
IntermediateToken - - CSharp - )
ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => Value = __value, Value)
HtmlContent - (74:1,43 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (74:1,43 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n

View File

@ -0,0 +1,24 @@
Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml)
|*, TestAssembly|
Generated Location: (559:16,38 [15] )
|*, TestAssembly|
Source Location: (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|string|
Generated Location: (1083:30,19 [6] )
|string|
Source Location: (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml)
|Value|
Generated Location: (1305:37,36 [5] )
|Value|
Source Location: (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
|
string Value;
|
Generated Location: (1740:49,12 [21] )
|
string Value;
|

View File

@ -0,0 +1,67 @@
// <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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1,
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
18
#line default
#line hidden
, -1, Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
Value
#line default
#line hidden
), -1, Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => Value = __value, Value));
}
#pragma warning restore 1998
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
string Value;
#line default
#line hidden
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, System.Object __arg1, int __seq2, System.Object __arg2)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Value", __arg0);
builder.AddAttribute(__seq1, "Item", __arg1);
builder.AddAttribute(__seq2, "ItemChanged", __arg2);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,43 @@
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 [15] 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 - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (31:1,0 [42] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (66:1,35 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value
CSharpExpression - (67:1,36 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (68:1,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 18
ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
IntermediateToken - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value
IntermediateToken - - CSharp - )
ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => Value = __value, Value)
HtmlContent - (73:1,42 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (73:1,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (87:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (87:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,24 @@
Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml)
|*, TestAssembly|
Generated Location: (559:16,38 [15] )
|*, TestAssembly|
Source Location: (68:1,37 [2] x:\dir\subdir\Test\TestComponent.cshtml)
|18|
Generated Location: (1167:30,37 [2] )
|18|
Source Location: (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml)
|Value|
Generated Location: (1356:36,23 [5] )
|Value|
Source Location: (87:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
|
string Value;
|
Generated Location: (1630:44,12 [21] )
|
string Value;
|

View File

@ -0,0 +1,61 @@
// <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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1, Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
Value
#line default
#line hidden
), -1,
__value => Value = __value);
}
#pragma warning restore 1998
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
string Value;
#line default
#line hidden
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::System.Action<TItem> __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "ItemChanged", __arg1);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,40 @@
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 [15] 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 - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (31:1,0 [30] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
IntermediateToken - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value
IntermediateToken - - CSharp - )
ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - ItemChanged
CSharpExpression -
IntermediateToken - - CSharp - __value => Value = __value
HtmlContent - (61:1,30 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (61:1,30 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (75:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (75:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,19 @@
Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml)
|*, TestAssembly|
Generated Location: (559:16,38 [15] )
|*, TestAssembly|
Source Location: (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml)
|Value|
Generated Location: (1213:30,23 [5] )
|Value|
Source Location: (75:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
|
string Value;
|
Generated Location: (1426:39,12 [21] )
|
string Value;
|

View File

@ -0,0 +1,61 @@
// <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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1,
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
"hi"
#line default
#line hidden
, -1, (context) => (builder2) => {
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = context.ToLower();
#line default
#line hidden
}
);
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Blazor.RenderFragment<TItem> __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "ChildContent", __arg1);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,39 @@
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 [15] 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 - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (31:1,0 [77] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentChildContent - - ChildContent
HtmlContent - (59:1,28 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (59:1,28 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
HtmlElement - (63:2,2 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (69:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (69:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower()
HtmlContent - (92:2,31 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (92:2,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi"
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,15 @@
Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml)
|*, TestAssembly|
Generated Location: (559:16,38 [15] )
|*, TestAssembly|
Source Location: (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml)
|"hi"|
Generated Location: (1151:30,21 [4] )
|"hi"|
Source Location: (69:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml)
|context.ToLower()|
Generated Location: (1295:36,8 [17] )
|context.ToLower()|

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 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);
__o = typeof(
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
string
#line default
#line hidden
);
__o = Microsoft.AspNetCore.Blazor.Components.RuntimeHelpers.TypeCheck<string>(
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
"hi"
#line default
#line hidden
);
__o =
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
17
#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,33 @@
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 [15] 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 - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (31:1,0 [56] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent<string>
ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem
IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string
ComponentAttributeExtensionNode - (63:1,32 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (64:1,33 [6] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi"
ComponentAttributeExtensionNode - - Other -
CSharpExpression - (79:1,48 [5] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (81:1,50 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 17

View File

@ -0,0 +1,20 @@
Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml)
|*, TestAssembly|
Generated Location: (559:16,38 [15] )
|*, TestAssembly|
Source Location: (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|string|
Generated Location: (1083:30,19 [6] )
|string|
Source Location: (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml)
|"hi"|
Generated Location: (1315:37,34 [4] )
|"hi"|
Source Location: (81:1,50 [2] x:\dir\subdir\Test\TestComponent.cshtml)
|17|
Generated Location: (1489:44,50 [2] )
|17|

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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1,
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
"hi"
#line default
#line hidden
, -1,
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
17
#line default
#line hidden
);
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, System.Object __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "Other", __arg1);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,34 @@
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 [15] 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 - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi"
ComponentAttributeExtensionNode - - Other -
CSharpExpression - (66:1,35 [5] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (68:1,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 17
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,15 @@
Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml)
|*, TestAssembly|
Generated Location: (559:16,38 [15] )
|*, TestAssembly|
Source Location: (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml)
|"hi"|
Generated Location: (1151:30,21 [4] )
|"hi"|
Source Location: (68:1,37 [2] x:\dir\subdir\Test\TestComponent.cshtml)
|17|
Generated Location: (1296:36,37 [2] )
|17|

View File

@ -0,0 +1,53 @@
// <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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1,
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
"hi"
#line default
#line hidden
);
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.CloseComponent();
}
}
}
#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"
DirectiveToken - (14:0,14 [15] 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 - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (31:1,0 [29] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi"
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,10 @@
Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml)
|*, TestAssembly|
Generated Location: (559:16,38 [15] )
|*, TestAssembly|
Source Location: (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml)
|"hi"|
Generated Location: (1151:30,21 [4] )
|"hi"|

View File

@ -0,0 +1,79 @@
// <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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1,
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
"hi"
#line default
#line hidden
);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_1(builder, -1, -1,
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
"how are you?"
#line default
#line hidden
);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_2(builder, -1, -1,
#line 4 "x:\dir\subdir\Test\TestComponent.cshtml"
"bye!"
#line default
#line hidden
);
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.CloseComponent();
}
public static void CreateMyComponent_1<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.CloseComponent();
}
public static void CreateMyComponent_2<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.CloseComponent();
}
}
}
#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 [15] 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 - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (31:1,0 [29] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi"
HtmlContent - (60:1,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (60:1,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (62:2,0 [39] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (81:2,19 [17] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (82:2,20 [16] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (83:2,21 [14] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "how are you?"
HtmlContent - (101:2,39 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (101:2,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (103:3,0 [31] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (122:3,19 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (123:3,20 [8] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (124:3,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "bye!"
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_1
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_2

View File

@ -0,0 +1,20 @@
Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml)
|*, TestAssembly|
Generated Location: (559:16,38 [15] )
|*, TestAssembly|
Source Location: (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml)
|"hi"|
Generated Location: (1151:30,21 [4] )
|"hi"|
Source Location: (83:2,21 [14] x:\dir\subdir\Test\TestComponent.cshtml)
|"how are you?"|
Generated Location: (1369:37,21 [14] )
|"how are you?"|
Source Location: (124:3,21 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|"bye!"|
Generated Location: (1597:44,21 [6] )
|"bye!"|

View File

@ -0,0 +1,76 @@
// <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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1,
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
"hi"
#line default
#line hidden
, -1,
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
new List<long>()
#line default
#line hidden
, -1, (context) => (builder2) => {
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = context.ToLower();
#line default
#line hidden
}
, -1, (item) => (builder2) => {
#line 5 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = System.Math.Max(0, item.Item);
#line default
#line hidden
}
);
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem1, TItem2>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem1 __arg0, int __seq1, global::System.Collections.Generic.List<TItem2> __arg1, int __seq2, global::Microsoft.AspNetCore.Blazor.RenderFragment<TItem1> __arg2, int __seq3, global::Microsoft.AspNetCore.Blazor.RenderFragment<global::Test.MyComponent<TItem1, TItem2>.Context> __arg3)
{
builder.OpenComponent<global::Test.MyComponent<TItem1, TItem2>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "Items", __arg1);
builder.AddAttribute(__seq2, "ChildContent", __arg2);
builder.AddAttribute(__seq3, "AnotherChildContent", __arg3);
builder.CloseComponent();
}
}
}
#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 [15] 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 - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (31:1,0 [229] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem1, TItem2>
ComponentChildContent - (89:2,2 [58] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent
HtmlElement - (103:2,16 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (109:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (109:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower()
ComponentChildContent - (149:3,0 [95] x:\dir\subdir\Test\TestComponent.cshtml) - AnotherChildContent
HtmlContent - (185:3,36 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (185:3,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpExpression - (190:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (190:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - System.Math.Max(0, item.Item)
HtmlContent - (219:4,32 [3] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (219:4,32 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n
ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi"
ComponentAttributeExtensionNode - (65:1,34 [19] x:\dir\subdir\Test\TestComponent.cshtml) - Items - Items
CSharpExpression - (66:1,35 [18] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (67:1,36 [16] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - new List<long>()
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,25 @@
Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml)
|*, TestAssembly|
Generated Location: (559:16,38 [15] )
|*, TestAssembly|
Source Location: (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml)
|"hi"|
Generated Location: (1151:30,21 [4] )
|"hi"|
Source Location: (67:1,36 [16] x:\dir\subdir\Test\TestComponent.cshtml)
|new List<long>()|
Generated Location: (1295:36,36 [16] )
|new List<long>()|
Source Location: (109:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml)
|context.ToLower()|
Generated Location: (1465:42,22 [17] )
|context.ToLower()|
Source Location: (190:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml)
|System.Math.Max(0, item.Item)|
Generated Location: (1633:49,6 [29] )
|System.Math.Max(0, item.Item)|

View File

@ -26,6 +26,7 @@ global::System.Object __typeHelper = "*, TestAssembly";
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
__o = "";
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => {
}
));

View File

@ -26,6 +26,7 @@ global::System.Object __typeHelper = "*, TestAssembly";
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
__o = "";
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment<System.String>)((context) => (builder2) => {
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = context.ToLowerInvariant();

View File

@ -5,6 +5,6 @@ Generated Location: (559:16,38 [15] )
Source Location: (85:1,54 [26] x:\dir\subdir\Test\TestComponent.cshtml)
|context.ToLowerInvariant()|
Generated Location: (1234:30,54 [26] )
Generated Location: (1257:31,54 [26] )
|context.ToLowerInvariant()|

View File

@ -26,6 +26,7 @@ global::System.Object __typeHelper = "*, TestAssembly";
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
__o = "";
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment<System.String>)((item) => (builder2) => {
#line 4 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = item.ToLowerInvariant();

View File

@ -5,6 +5,6 @@ Generated Location: (559:16,38 [15] )
Source Location: (124:3,32 [23] x:\dir\subdir\Test\TestComponent.cshtml)
|item.ToLowerInvariant()|
Generated Location: (1209:30,32 [23] )
Generated Location: (1232:31,32 [23] )
|item.ToLowerInvariant()|

View File

@ -26,6 +26,7 @@ global::System.Object __typeHelper = "*, TestAssembly";
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
__o = "";
__o =
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
43.ToString()

View File

@ -5,6 +5,6 @@ Generated Location: (559:16,38 [15] )
Source Location: (86:1,55 [13] x:\dir\subdir\Test\TestComponent.cshtml)
|43.ToString()|
Generated Location: (1112:30,55 [13] )
Generated Location: (1135:31,55 [13] )
|43.ToString()|

View File

@ -40,6 +40,7 @@ global::System.Object __typeHelper = "*, TestAssembly";
#line default
#line hidden
);
__o = "";
__o = Microsoft.AspNetCore.Blazor.Components.RuntimeHelpers.TypeCheck<Test.SomeType>(
#line 6 "x:\dir\subdir\Test\TestComponent.cshtml"
new SomeType()

View File

@ -15,6 +15,6 @@ Generated Location: (1373:37,18 [4] )
Source Location: (146:5,20 [14] x:\dir\subdir\Test\TestComponent.cshtml)
|new SomeType()|
Generated Location: (1596:44,20 [14] )
Generated Location: (1619:45,20 [14] )
|new SomeType()|

View File

@ -26,6 +26,8 @@ global::System.Object __typeHelper = "*, TestAssembly";
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
__o = "";
__o = "";
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => {
}
));

View File

@ -5,7 +5,7 @@ Generated Location: (559:16,38 [15] )
Source Location: (70:1,39 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|myInstance|
Generated Location: (1223:32,39 [10] )
Generated Location: (1269:34,39 [10] )
|myInstance|
Source Location: (119:3,12 [104] x:\dir\subdir\Test\TestComponent.cshtml)
@ -13,7 +13,7 @@ Source Location: (119:3,12 [104] x:\dir\subdir\Test\TestComponent.cshtml)
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
|
Generated Location: (1407:39,12 [104] )
Generated Location: (1453:41,12 [104] )
|
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }

View File

@ -26,6 +26,7 @@ global::System.Object __typeHelper = "*, TestAssembly";
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
__o = "";
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => {
}
));

View File

@ -5,7 +5,7 @@ Generated Location: (559:16,38 [15] )
Source Location: (49:1,18 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|myInstance|
Generated Location: (1202:32,18 [10] )
Generated Location: (1225:33,18 [10] )
|myInstance|
Source Location: (143:5,12 [104] x:\dir\subdir\Test\TestComponent.cshtml)
@ -13,7 +13,7 @@ Source Location: (143:5,12 [104] x:\dir\subdir\Test\TestComponent.cshtml)
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
|
Generated Location: (1386:39,12 [104] )
Generated Location: (1409:40,12 [104] )
|
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }

View File

@ -0,0 +1,62 @@
// <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);
__o = typeof(
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
int
#line default
#line hidden
);
__o = Microsoft.AspNetCore.Blazor.Components.RuntimeHelpers.TypeCheck<int>(
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
3
#line default
#line hidden
);
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => {
}
));
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
_my = default(Test.MyComponent<int>);
#line default
#line hidden
}
#pragma warning restore 1998
#line 4 "x:\dir\subdir\Test\TestComponent.cshtml"
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
#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 [15] 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 - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (31:1,0 [44] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent<int>
ComponentTypeArgumentExtensionNode - (50:1,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) - TItem
IntermediateToken - (50:1,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - int
ComponentAttributeExtensionNode - (60:1,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
IntermediateToken - (60:1,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
RefExtensionNode - (68:1,37 [3] x:\dir\subdir\Test\TestComponent.cshtml) - _my - Test.MyComponent<int>
HtmlContent - (75:1,44 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (75:1,44 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
HtmlContent - (182:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (182:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (91:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (91:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent<int> _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n

View File

@ -0,0 +1,31 @@
Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml)
|*, TestAssembly|
Generated Location: (559:16,38 [15] )
|*, TestAssembly|
Source Location: (50:1,19 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|int|
Generated Location: (1083:30,19 [3] )
|int|
Source Location: (60:1,29 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|3|
Generated Location: (1304:37,29 [1] )
|3|
Source Location: (68:1,37 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|_my|
Generated Location: (1589:46,37 [3] )
|_my|
Source Location: (91:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
|
Generated Location: (1771:53,12 [90] )
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
|

View File

@ -0,0 +1,68 @@
// <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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1,
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
3
#line default
#line hidden
, -1, (__value) => {
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
_my = __value;
#line default
#line hidden
}
);
}
#pragma warning restore 1998
#line 4 "x:\dir\subdir\Test\TestComponent.cshtml"
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
#line default
#line hidden
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::System.Action<global::Test.MyComponent<TItem>> __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddComponentReferenceCapture(__seq1, (__value) => { __arg1((global::Test.MyComponent<TItem>)__value); });
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,37 @@
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 [15] 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 - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (31:1,0 [34] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (50:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
IntermediateToken - (50:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
RefExtensionNode - (58:1,27 [3] x:\dir\subdir\Test\TestComponent.cshtml) - _my - global::Test.MyComponent<TItem>
HtmlContent - (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
HtmlContent - (172:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (172:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (81:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (81:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent<int> _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,26 @@
Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml)
|*, TestAssembly|
Generated Location: (559:16,38 [15] )
|*, TestAssembly|
Source Location: (50:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|3|
Generated Location: (1149:30,19 [1] )
|3|
Source Location: (58:1,27 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|_my|
Generated Location: (1295:36,27 [3] )
|_my|
Source Location: (81:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
|
Generated Location: (1485:45,12 [90] )
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
|

View File

@ -31,6 +31,7 @@ global::System.Object __typeHelper = "/";
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
__o = "";
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => {
}
));

View File

@ -31,6 +31,7 @@ global::System.Object __typeHelper = "/";
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
__o = "";
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => {
}
));

View File

@ -16,8 +16,8 @@ namespace Test
{
base.BuildRenderTree(builder);
builder.OpenComponent<Test.MyComponent<string>>(0);
builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(Value));
builder.AddAttribute(2, "ItemChanged", Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => Value = __value, Value));
builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Blazor.Components.RuntimeHelpers.TypeCheck<string>(Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(Value)));
builder.AddAttribute(2, "ItemChanged", new System.Action<string>(__value => Value = __value));
builder.CloseComponent();
}
#pragma warning restore 1998

View File

@ -13,13 +13,13 @@ Document -
ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent<string>
ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem
IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string
ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item -
ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
IntermediateToken - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value
IntermediateToken - - CSharp - )
ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged -
ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - ItemChanged
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => Value = __value, Value)
IntermediateToken - - CSharp - __value => Value = __value
CSharpCode - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n

View File

@ -2,7 +2,7 @@ Source Location: (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
|
string Value;
|
Generated Location: (1087:24,12 [21] )
Generated Location: (1112:24,12 [21] )
|
string Value;
|

View File

@ -0,0 +1,32 @@
// <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.OpenComponent<Test.MyComponent<string>>(0);
builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(Value));
builder.AddAttribute(2, "ItemChanged", Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => Value = __value, Value));
builder.CloseComponent();
}
#pragma warning restore 1998
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
string Value;
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,25 @@
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);
ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent<string>
ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem
IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string
ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
IntermediateToken - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value
IntermediateToken - - CSharp - )
ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => Value = __value, Value)
CSharpCode - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n

View File

@ -0,0 +1,9 @@
Source Location: (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
|
string Value;
|
Generated Location: (1087:24,12 [21] )
|
string Value;
|

View File

@ -0,0 +1,44 @@
// <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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, 18, 2, Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(Value), 3, Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => Value = __value, Value));
}
#pragma warning restore 1998
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
string Value;
#line default
#line hidden
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, System.Object __arg1, int __seq2, System.Object __arg2)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Value", __arg0);
builder.AddAttribute(__seq1, "Item", __arg1);
builder.AddAttribute(__seq2, "ItemChanged", __arg2);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,29 @@
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);
ComponentExtensionNode - (31:1,0 [42] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (66:1,35 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value
CSharpExpression - (67:1,36 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (68:1,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 18
ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
IntermediateToken - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value
IntermediateToken - - CSharp - )
ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => Value = __value, Value)
CSharpCode - (87:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (87:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,9 @@
Source Location: (87:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
|
string Value;
|
Generated Location: (985:21,12 [21] )
|
string Value;
|

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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(Value), 2, __value => Value = __value);
}
#pragma warning restore 1998
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
string Value;
#line default
#line hidden
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::System.Action<TItem> __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "ItemChanged", __arg1);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,26 @@
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);
ComponentExtensionNode - (31:1,0 [30] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
IntermediateToken - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value
IntermediateToken - - CSharp - )
ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - ItemChanged
CSharpExpression -
IntermediateToken - - CSharp - __value => Value = __value
CSharpCode - (75:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (75:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,9 @@
Source Location: (75:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml)
|
string Value;
|
Generated Location: (903:21,12 [21] )
|
string Value;
|

View File

@ -0,0 +1,44 @@
// <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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, "hi", 2, (context) => (builder2) => {
builder2.AddContent(3, "\n ");
builder2.OpenElement(4, "div");
builder2.AddContent(5, context.ToLower());
builder2.CloseElement();
builder2.AddContent(6, "\n");
}
);
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Blazor.RenderFragment<TItem> __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "ChildContent", __arg1);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,27 @@
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);
ComponentExtensionNode - (31:1,0 [77] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentChildContent - - ChildContent
HtmlContent - (59:1,28 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (59:1,28 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
HtmlElement - (63:2,2 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (69:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (69:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower()
HtmlContent - (92:2,31 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (92:2,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi"
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,26 @@
// <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.OpenComponent<Test.MyComponent<string>>(0);
builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Blazor.Components.RuntimeHelpers.TypeCheck<string>("hi"));
builder.AddAttribute(2, "Other", 17);
builder.CloseComponent();
}
#pragma warning restore 1998
}
}
#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);
ComponentExtensionNode - (31:1,0 [56] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent<string>
ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem
IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string
ComponentAttributeExtensionNode - (63:1,32 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (64:1,33 [6] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi"
ComponentAttributeExtensionNode - - Other -
CSharpExpression - (79:1,48 [5] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (81:1,50 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 17

View File

@ -0,0 +1,37 @@
// <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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, "hi", 2, 17);
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, System.Object __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "Other", __arg1);
builder.CloseComponent();
}
}
}
#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);
ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi"
ComponentAttributeExtensionNode - - Other -
CSharpExpression - (66:1,35 [5] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (68:1,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 17
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,36 @@
// <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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, "hi");
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,19 @@
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);
ComponentExtensionNode - (31:1,0 [29] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi"
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

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 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, "hi");
builder.AddContent(2, "\n");
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_1(builder, 3, 4, "how are you?");
builder.AddContent(5, "\n");
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_2(builder, 6, 7, "bye!");
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.CloseComponent();
}
public static void CreateMyComponent_1<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.CloseComponent();
}
public static void CreateMyComponent_2<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,33 @@
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);
ComponentExtensionNode - (31:1,0 [29] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi"
HtmlContent - (60:1,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (60:1,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (62:2,0 [39] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (81:2,19 [17] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (82:2,20 [16] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (83:2,21 [14] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "how are you?"
HtmlContent - (101:2,39 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (101:2,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (103:3,0 [31] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (122:3,19 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (123:3,20 [8] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (124:3,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "bye!"
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_1
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, "hi", 2, new List<long>(), 3, (context) => (builder2) => {
builder2.OpenElement(4, "div");
builder2.AddContent(5, context.ToLower());
builder2.CloseElement();
}
, 6, (item) => (builder2) => {
builder2.AddContent(7, "\n ");
builder2.AddContent(8, System.Math.Max(0, item.Item));
builder2.AddContent(9, ";\n");
}
);
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem1, TItem2>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem1 __arg0, int __seq1, global::System.Collections.Generic.List<TItem2> __arg1, int __seq2, global::Microsoft.AspNetCore.Blazor.RenderFragment<TItem1> __arg2, int __seq3, global::Microsoft.AspNetCore.Blazor.RenderFragment<global::Test.MyComponent<TItem1, TItem2>.Context> __arg3)
{
builder.OpenComponent<global::Test.MyComponent<TItem1, TItem2>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "Items", __arg1);
builder.AddAttribute(__seq2, "ChildContent", __arg2);
builder.AddAttribute(__seq3, "AnotherChildContent", __arg3);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,33 @@
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);
ComponentExtensionNode - (31:1,0 [229] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem1, TItem2>
ComponentChildContent - (89:2,2 [58] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent
HtmlElement - (103:2,16 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div
CSharpExpression - (109:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (109:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower()
ComponentChildContent - (149:3,0 [95] x:\dir\subdir\Test\TestComponent.cshtml) - AnotherChildContent
HtmlContent - (185:3,36 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (185:3,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpExpression - (190:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (190:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - System.Math.Max(0, item.Item)
HtmlContent - (219:4,32 [3] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (219:4,32 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n
ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi"
ComponentAttributeExtensionNode - (65:1,34 [19] x:\dir\subdir\Test\TestComponent.cshtml) - Items - Items
CSharpExpression - (66:1,35 [18] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (67:1,36 [16] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - new List<long>()
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

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);
builder.OpenComponent<Test.MyComponent<int>>(0);
builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Blazor.Components.RuntimeHelpers.TypeCheck<int>(3));
builder.AddComponentReferenceCapture(2, (__value) => {
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
_my = (Test.MyComponent<int>)__value;
#line default
#line hidden
}
);
builder.CloseComponent();
}
#pragma warning restore 1998
#line 4 "x:\dir\subdir\Test\TestComponent.cshtml"
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,20 @@
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);
ComponentExtensionNode - (31:1,0 [44] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent<int>
ComponentTypeArgumentExtensionNode - (50:1,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) - TItem
IntermediateToken - (50:1,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - int
ComponentAttributeExtensionNode - (60:1,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
IntermediateToken - (60:1,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
RefExtensionNode - (68:1,37 [3] x:\dir\subdir\Test\TestComponent.cshtml) - _my - Test.MyComponent<int>
CSharpCode - (91:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (91:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent<int> _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n

View File

@ -0,0 +1,16 @@
Source Location: (68:1,37 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|_my|
Generated Location: (938:21,37 [3] )
|_my|
Source Location: (91:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
|
Generated Location: (1190:31,12 [90] )
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
|

View File

@ -0,0 +1,51 @@
// <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);
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, 3, 2, (__value) => {
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
_my = __value;
#line default
#line hidden
}
);
}
#pragma warning restore 1998
#line 4 "x:\dir\subdir\Test\TestComponent.cshtml"
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
#line default
#line hidden
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::System.Action<global::Test.MyComponent<TItem>> __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddComponentReferenceCapture(__seq1, (__value) => { __arg1((global::Test.MyComponent<TItem>)__value); });
builder.CloseComponent();
}
}
}
#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);
ComponentExtensionNode - (31:1,0 [34] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent<TItem>
ComponentAttributeExtensionNode - (50:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item
IntermediateToken - (50:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
RefExtensionNode - (58:1,27 [3] x:\dir\subdir\Test\TestComponent.cshtml) - _my - global::Test.MyComponent<TItem>
CSharpCode - (81:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (81:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent<int> _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,16 @@
Source Location: (58:1,27 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|_my|
Generated Location: (790:19,27 [3] )
|_my|
Source Location: (81:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
|
Generated Location: (980:28,12 [90] )
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
|

View File

@ -0,0 +1,38 @@
// 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 Microsoft.CodeAnalysis.CSharp;
using Xunit;
namespace Microsoft.AspNetCore.Blazor.Razor
{
public class GlobalQualifiedTypeNameRewriterTest
{
[Theory]
[InlineData("String", "global::String")]
[InlineData("System.String", "global::System.String")]
[InlineData("TItem2", "TItem2")]
[InlineData("System.Collections.Generic.List<System.String>", "global::System.Collections.Generic.List<global::System.String>")]
[InlineData("System.Collections.Generic.Dictionary<System.String, TItem1>", "global::System.Collections.Generic.Dictionary<global::System.String, TItem1>")]
[InlineData("System.Collections.TItem3.Dictionary<System.String, TItem1>", "global::System.Collections.TItem3.Dictionary<global::System.String, TItem1>")]
[InlineData("System.Collections.TItem3.TItem1<System.String, TItem1>", "global::System.Collections.TItem3.TItem1<global::System.String, TItem1>")]
// This case is interesting because we know TITem2 to be a generic type parameter,
// and we know that this will never be valid, which is why we don't bother rewriting.
[InlineData("TItem2<System.String, TItem1>", "TItem2<global::System.String, TItem1>")]
public void GlobalQualifiedTypeNameRewriter_CanQualifyNames(string original, string expected)
{
// Arrange
var visitor = new GlobalQualifiedTypeNameRewriter(new[] { "TItem1", "TItem2", "TItem3" });
var parsed = SyntaxFactory.ParseTypeName(original);
// Act
var actual = visitor.Visit(parsed);
// Assert
Assert.Equal(expected, actual.ToString());
}
}
}

View File

@ -123,6 +123,13 @@ namespace Microsoft.AspNetCore.Blazor.Test.Helpers
AssertFrame.Sequence(frame, sequence);
}
public static void ComponentReferenceCapture(RenderTreeFrame frame, int? sequence = null)
{
Assert.Equal(RenderTreeFrameType.ComponentReferenceCapture, frame.FrameType);
Assert.NotNull(frame.ComponentReferenceCaptureAction);
AssertFrame.Sequence(frame, sequence);
}
public static void ComponentReferenceCapture(RenderTreeFrame frame, Action<object> action, int? sequence = null)
{
Assert.Equal(RenderTreeFrameType.ComponentReferenceCapture, frame.FrameType);

View File

@ -1,4 +1,4 @@
<TemplatedTable Items="@Items" TItem="Item">
<TemplatedTable Items="@Items">
<Header><tr><th>Col1</th><th>Col2</th><th>Col3</th></tr></Header>
<Footer>
@if (ShowFooter)

View File

@ -6,5 +6,5 @@
@{
RenderFragment<OrderedList<string>.Context> template = (context) => @<li>#@context.Index - @context.Item.ToLower()</li>;
}
<OrderedList Items="@items" Template="@template" TItem="string"/>
<OrderedList Items="@items" Template="@template" />
</div>