Use globally qualified type name when generating TypeInference (dotnet/aspnetcore-tooling#946)

The code-generated TypeInference type resides in a custom namespace.
Any types that it refers to in user code must be qualified using the "global::" prefix
to avoid type \ namespace conflicts.

Fixes https://github.com/aspnet/AspNetCore/issues/12116\n\nCommit migrated from f0e09e4a97
This commit is contained in:
Pranav K 2019-08-13 12:35:37 -07:00 committed by GitHub
parent 7e8807ae64
commit 32196f8023
30 changed files with 1095 additions and 5 deletions

View File

@ -207,11 +207,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
foreach (var attribute in node.Attributes)
{
string globallyQualifiedTypeName = null;
if (attribute.TypeName != null)
{
globallyQualifiedTypeName = rewriter.Rewrite(attribute.TypeName);
attribute.GloballyQualifiedTypeName = globallyQualifiedTypeName;
}
if (attribute.BoundAttribute?.IsGenericTypedProperty() ?? false && attribute.TypeName != null)
{
// If we know the type name, then replace any generic type parameter inside it with
// the known types.
attribute.TypeName = rewriter.Rewrite(attribute.TypeName);
attribute.TypeName = globallyQualifiedTypeName;
}
else if (attribute.TypeName == null && (attribute.BoundAttribute?.IsDelegateProperty() ?? false))
{

View File

@ -209,11 +209,20 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
{
if (child is ComponentAttributeIntermediateNode attribute)
{
var typeName = attribute.TypeName;
if (attribute.BoundAttribute != null && !attribute.BoundAttribute.IsGenericTypedProperty())
string typeName;
if (attribute.GloballyQualifiedTypeName != null)
{
typeName = "global::" + typeName;
typeName = attribute.GloballyQualifiedTypeName;
}
else
{
typeName = attribute.TypeName;
if (attribute.BoundAttribute != null && !attribute.BoundAttribute.IsGenericTypedProperty())
{
typeName = "global::" + typeName;
}
}
p.Add(($"__seq{p.Count}", typeName, $"__arg{p.Count}"));
}
else if (child is SplatIntermediateNode splat)

View File

@ -102,6 +102,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
public string TypeName { get; set; }
public string GloballyQualifiedTypeName { get; set; }
public override void Accept(IntermediateNodeVisitor visitor)
{
if (visitor == null)
@ -127,6 +129,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
formatter.WriteProperty(nameof(PropertyName), PropertyName);
formatter.WriteProperty(nameof(TagHelper), TagHelper?.DisplayName);
formatter.WriteProperty(nameof(TypeName), TypeName);
formatter.WriteProperty(nameof(GloballyQualifiedTypeName), GloballyQualifiedTypeName);
}
public bool TryParseEventCallbackTypeArgument(out string argument)

View File

@ -1289,7 +1289,7 @@ namespace Test
[Fact]
public void BuiltIn_BindToInputWithDefaultFormat()
{
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using System;
@ -3190,6 +3190,40 @@ namespace Test
CompileToAssembly(generated);
}
[Fact]
public void NonGenericComponent_WithGenericEventHandler()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Components;
namespace Test
{
public class MyEventArgs { }
public class MyComponent : ComponentBase
{
[Parameter] public string Item { get; set; }
[Parameter] public EventCallback<MyEventArgs> Event { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
<MyComponent Item=""Hello"" MyEvent=""MyEventHandler"" />
@code {
public void MyEventHandler() {}
}
");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void GenericComponent_WithKey()
{
@ -3418,6 +3452,130 @@ namespace Test.Shared
CompileToAssembly(generated);
}
[Fact]
public void GenericComponent_NonGenericEventCallback_TypeInference()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Components;
namespace Test
{
public class MyEventArgs { }
public class MyComponent<TItem> : ComponentBase
{
[Parameter] public TItem Item { get; set; }
[Parameter] public EventCallback MyEvent { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@using Test
<MyComponent Item=""3"" MyEvent=""x => {}"" />
");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void GenericComponent_GenericEventCallback_TypeInference()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Components;
namespace Test
{
public class MyEventArgs { }
public class MyComponent<TItem> : ComponentBase
{
[Parameter] public TItem Item { get; set; }
[Parameter] public EventCallback<MyEventArgs> MyEvent { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@using Test
<MyComponent Item=""3"" MyEvent=""x => {}"" />
");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void GenericComponent_NestedGenericEventCallback_TypeInference()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using System.Collections.Generic;
using Microsoft.AspNetCore.Components;
namespace Test
{
public class MyEventArgs { }
public class MyComponent<TItem> : ComponentBase
{
[Parameter] public TItem Item { get; set; }
[Parameter] public EventCallback<List<Dictionary<string, MyEventArgs[]>>> MyEvent { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@using Test
<MyComponent Item=""3"" MyEvent=""x => {}"" />
");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Components;
namespace Test
{
public class MyEventArgs { }
public class MyComponent<TItem> : ComponentBase
{
[Parameter] public TItem Item { get; set; }
[Parameter] public EventCallback<TItem> MyEvent { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@using Test
<MyComponent Item=""3"" MyEvent=""(int x) => {}"" />
");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
#endregion
#region Key

View File

@ -0,0 +1,72 @@
// <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.Components;
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
using Test;
#line default
#line hidden
#nullable disable
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
{
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
3
#line default
#line hidden
#nullable disable
, -1, Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
(int x) => {}
#line default
#line hidden
#nullable disable
));
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = typeof(MyComponent<>);
#line default
#line hidden
#nullable disable
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback<TItem> __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "MyEvent", __arg1);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,29 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
UsingDirective - (1:0,1 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Test
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
DesignTimeDirective -
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
HtmlContent - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
Component - (13:1,0 [48] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
IntermediateToken - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
ComponentAttribute - (44:1,31 [13] x:\dir\subdir\Test\TestComponent.cshtml) - MyEvent - AttributeStructure.DoubleQuotes
IntermediateToken - (44:1,31 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - (int x) => {}
HtmlContent - (61:1,48 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (61:1,48 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,15 @@
Source Location: (1:0,1 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|using Test|
Generated Location: (320:12,0 [10] )
|using Test|
Source Location: (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|3|
Generated Location: (1087:32,19 [1] )
|3|
Source Location: (44:1,31 [13] x:\dir\subdir\Test\TestComponent.cshtml)
|(int x) => {}|
Generated Location: (1328:40,31 [13] )
|(int x) => {}|

View File

@ -0,0 +1,72 @@
// <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.Components;
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
using Test;
#line default
#line hidden
#nullable disable
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
{
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
3
#line default
#line hidden
#nullable disable
, -1, Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Test.MyEventArgs>(this,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
x => {}
#line default
#line hidden
#nullable disable
));
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = typeof(MyComponent<>);
#line default
#line hidden
#nullable disable
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback<global::Test.MyEventArgs> __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "MyEvent", __arg1);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,29 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
UsingDirective - (1:0,1 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Test
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
DesignTimeDirective -
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
HtmlContent - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
Component - (13:1,0 [42] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
IntermediateToken - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
ComponentAttribute - (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml) - MyEvent - AttributeStructure.DoubleQuotes
IntermediateToken - (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - x => {}
HtmlContent - (55:1,42 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (55:1,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,15 @@
Source Location: (1:0,1 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|using Test|
Generated Location: (320:12,0 [10] )
|using Test|
Source Location: (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|3|
Generated Location: (1087:32,19 [1] )
|3|
Source Location: (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml)
|x => {}|
Generated Location: (1346:40,31 [7] )
|x => {}|

View File

@ -0,0 +1,72 @@
// <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.Components;
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
using Test;
#line default
#line hidden
#nullable disable
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
{
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
3
#line default
#line hidden
#nullable disable
, -1, Microsoft.AspNetCore.Components.EventCallback.Factory.Create<System.Collections.Generic.List<System.Collections.Generic.Dictionary<System.String, Test.MyEventArgs[]>>>(this,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
x => {}
#line default
#line hidden
#nullable disable
));
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = typeof(MyComponent<>);
#line default
#line hidden
#nullable disable
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback<global::System.Collections.Generic.List<global::System.Collections.Generic.Dictionary<global::System.String, global::Test.MyEventArgs[]>>> __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "MyEvent", __arg1);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,29 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
UsingDirective - (1:0,1 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Test
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
DesignTimeDirective -
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
HtmlContent - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
Component - (13:1,0 [42] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
IntermediateToken - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
ComponentAttribute - (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml) - MyEvent - AttributeStructure.DoubleQuotes
IntermediateToken - (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - x => {}
HtmlContent - (55:1,42 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (55:1,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,15 @@
Source Location: (1:0,1 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|using Test|
Generated Location: (320:12,0 [10] )
|using Test|
Source Location: (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|3|
Generated Location: (1087:32,19 [1] )
|3|
Source Location: (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml)
|x => {}|
Generated Location: (1435:40,31 [7] )
|x => {}|

View File

@ -0,0 +1,72 @@
// <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.Components;
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
using Test;
#line default
#line hidden
#nullable disable
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
{
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
3
#line default
#line hidden
#nullable disable
, -1, Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
x => {}
#line default
#line hidden
#nullable disable
));
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = typeof(MyComponent<>);
#line default
#line hidden
#nullable disable
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "MyEvent", __arg1);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,29 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
UsingDirective - (1:0,1 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Test
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
DesignTimeDirective -
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
HtmlContent - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
Component - (13:1,0 [42] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
IntermediateToken - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
ComponentAttribute - (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml) - MyEvent - AttributeStructure.DoubleQuotes
IntermediateToken - (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - x => {}
HtmlContent - (55:1,42 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (55:1,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,15 @@
Source Location: (1:0,1 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|using Test|
Generated Location: (320:12,0 [10] )
|using Test|
Source Location: (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml)
|3|
Generated Location: (1087:32,19 [1] )
|3|
Source Location: (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml)
|x => {}|
Generated Location: (1328:40,31 [7] )
|x => {}|

View File

@ -0,0 +1,47 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
{
__o = "";
__o = "";
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => {
}
));
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = typeof(MyComponent);
#line default
#line hidden
#nullable disable
}
#pragma warning restore 1998
#nullable restore
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
public void MyEventHandler() {}
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,29 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
DesignTimeDirective -
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
Component - (0:0,0 [53] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
HtmlContent - (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
ComponentAttribute - - MyEvent - AttributeStructure.DoubleQuotes
HtmlContent - (35:0,35 [14] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (35:0,35 [14] x:\dir\subdir\Test\TestComponent.cshtml) - Html - MyEventHandler
HtmlContent - (53:0,53 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (53:0,53 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
HtmlContent - (104:4,1 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (104:4,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (64:2,7 [39] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (64:2,7 [39] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public void MyEventHandler() {}\n

View File

@ -0,0 +1,9 @@
Source Location: (64:2,7 [39] x:\dir\subdir\Test\TestComponent.cshtml)
|
public void MyEventHandler() {}
|
Generated Location: (1243:38,7 [39] )
|
public void MyEventHandler() {}
|

View File

@ -0,0 +1,58 @@
// <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.Components;
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
using Test;
#line default
#line hidden
#nullable disable
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
{
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
3
#line default
#line hidden
#nullable disable
, 2, Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
(int x) => {}
#line default
#line hidden
#nullable disable
));
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback<TItem> __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "MyEvent", __arg1);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,18 @@
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 [39] ) - Microsoft.AspNetCore.Components
UsingDirective - (1:0,1 [12] x:\dir\subdir\Test\TestComponent.cshtml) - Test
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
MethodDeclaration - - protected override - void - BuildRenderTree
Component - (13:1,0 [48] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
IntermediateToken - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
ComponentAttribute - (44:1,31 [13] x:\dir\subdir\Test\TestComponent.cshtml) - MyEvent - AttributeStructure.DoubleQuotes
IntermediateToken - (44:1,31 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - (int x) => {}
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,58 @@
// <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.Components;
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
using Test;
#line default
#line hidden
#nullable disable
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
{
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
3
#line default
#line hidden
#nullable disable
, 2, Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Test.MyEventArgs>(this,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
x => {}
#line default
#line hidden
#nullable disable
));
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback<global::Test.MyEventArgs> __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "MyEvent", __arg1);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,18 @@
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 [39] ) - Microsoft.AspNetCore.Components
UsingDirective - (1:0,1 [12] x:\dir\subdir\Test\TestComponent.cshtml) - Test
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
MethodDeclaration - - protected override - void - BuildRenderTree
Component - (13:1,0 [42] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
IntermediateToken - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
ComponentAttribute - (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml) - MyEvent - AttributeStructure.DoubleQuotes
IntermediateToken - (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - x => {}
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,58 @@
// <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.Components;
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
using Test;
#line default
#line hidden
#nullable disable
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
{
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
3
#line default
#line hidden
#nullable disable
, 2, Microsoft.AspNetCore.Components.EventCallback.Factory.Create<System.Collections.Generic.List<System.Collections.Generic.Dictionary<System.String, Test.MyEventArgs[]>>>(this,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
x => {}
#line default
#line hidden
#nullable disable
));
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback<global::System.Collections.Generic.List<global::System.Collections.Generic.Dictionary<global::System.String, global::Test.MyEventArgs[]>>> __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "MyEvent", __arg1);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,18 @@
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 [39] ) - Microsoft.AspNetCore.Components
UsingDirective - (1:0,1 [12] x:\dir\subdir\Test\TestComponent.cshtml) - Test
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
MethodDeclaration - - protected override - void - BuildRenderTree
Component - (13:1,0 [42] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
IntermediateToken - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
ComponentAttribute - (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml) - MyEvent - AttributeStructure.DoubleQuotes
IntermediateToken - (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - x => {}
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,58 @@
// <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.Components;
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
using Test;
#line default
#line hidden
#nullable disable
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
{
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
3
#line default
#line hidden
#nullable disable
, 2, Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this,
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
x => {}
#line default
#line hidden
#nullable disable
));
}
#pragma warning restore 1998
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddAttribute(__seq1, "MyEvent", __arg1);
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,18 @@
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 [39] ) - Microsoft.AspNetCore.Components
UsingDirective - (1:0,1 [12] x:\dir\subdir\Test\TestComponent.cshtml) - Test
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
MethodDeclaration - - protected override - void - BuildRenderTree
Component - (13:1,0 [42] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
IntermediateToken - (32:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
ComponentAttribute - (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml) - MyEvent - AttributeStructure.DoubleQuotes
IntermediateToken - (44:1,31 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - x => {}
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

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.Components;
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
{
builder.OpenComponent<Test.MyComponent>(0);
builder.AddAttribute(1, "Item", "Hello");
builder.AddAttribute(2, "MyEvent", "MyEventHandler");
builder.CloseComponent();
}
#pragma warning restore 1998
#nullable restore
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
public void MyEventHandler() {}
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,18 @@
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 [39] ) - Microsoft.AspNetCore.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
MethodDeclaration - - protected override - void - BuildRenderTree
Component - (0:0,0 [53] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
HtmlContent - (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
ComponentAttribute - - MyEvent - AttributeStructure.DoubleQuotes
HtmlContent - (35:0,35 [14] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (35:0,35 [14] x:\dir\subdir\Test\TestComponent.cshtml) - Html - MyEventHandler
CSharpCode - (64:2,7 [39] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (64:2,7 [39] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public void MyEventHandler() {}\n

View File

@ -0,0 +1,9 @@
Source Location: (64:2,7 [39] x:\dir\subdir\Test\TestComponent.cshtml)
|
public void MyEventHandler() {}
|
Generated Location: (848:23,7 [39] )
|
public void MyEventHandler() {}
|