diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentGenericTypePass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentGenericTypePass.cs index 6be200e659..09ba98516f 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentGenericTypePass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentGenericTypePass.cs @@ -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)) { diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentNodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentNodeWriter.cs index a10cdba86d..6ab28d04ff 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentNodeWriter.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentNodeWriter.cs @@ -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) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs index 98404ef88e..6690b64d17 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs @@ -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) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index b331afa4ca..727f3ccca4 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -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 Event { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@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 : ComponentBase + { + [Parameter] public TItem Item { get; set; } + [Parameter] public EventCallback MyEvent { get; set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" +@using Test + {}"" /> +"); + + // 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 : ComponentBase + { + [Parameter] public TItem Item { get; set; } + [Parameter] public EventCallback MyEvent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Test + {}"" /> +"); + + // 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 : ComponentBase + { + [Parameter] public TItem Item { get; set; } + [Parameter] public EventCallback>> MyEvent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Test + {}"" /> +"); + + // 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 : ComponentBase + { + [Parameter] public TItem Item { get; set; } + [Parameter] public EventCallback MyEvent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Test + {}"" /> +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + #endregion #region Key diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.codegen.cs new file mode 100644 index 0000000000..6d96332596 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,72 @@ +// +#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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "MyEvent", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.ir.txt new file mode 100644 index 0000000000..93f6af217c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.ir.txt @@ -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 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.mappings.txt new file mode 100644 index 0000000000..d4e36b5bbf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.mappings.txt @@ -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) => {}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.codegen.cs new file mode 100644 index 0000000000..fcd22ff1cf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,72 @@ +// +#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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "MyEvent", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.ir.txt new file mode 100644 index 0000000000..2b4c766c99 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.ir.txt @@ -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 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.mappings.txt new file mode 100644 index 0000000000..ff8f8bdd6b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.mappings.txt @@ -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 => {}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.codegen.cs new file mode 100644 index 0000000000..ec34ae46b9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,72 @@ +// +#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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback>> __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "MyEvent", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.ir.txt new file mode 100644 index 0000000000..2b4c766c99 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.ir.txt @@ -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 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.mappings.txt new file mode 100644 index 0000000000..c1e1122d16 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.mappings.txt @@ -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 => {}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.codegen.cs new file mode 100644 index 0000000000..b4b5ccbb6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,72 @@ +// +#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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "MyEvent", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.ir.txt new file mode 100644 index 0000000000..2b4c766c99 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.ir.txt @@ -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 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.mappings.txt new file mode 100644 index 0000000000..97cd8d797e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.mappings.txt @@ -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 => {}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.codegen.cs new file mode 100644 index 0000000000..4d182075ef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.codegen.cs @@ -0,0 +1,47 @@ +// +#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 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.ir.txt new file mode 100644 index 0000000000..7a231f2e1a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.ir.txt @@ -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 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.mappings.txt new file mode 100644 index 0000000000..b206d1f78f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.mappings.txt @@ -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() {} +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.codegen.cs new file mode 100644 index 0000000000..84e9d3db48 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "MyEvent", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.ir.txt new file mode 100644 index 0000000000..2214655b97 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference/TestComponent.ir.txt @@ -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 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.codegen.cs new file mode 100644 index 0000000000..f3f9065268 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "MyEvent", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.ir.txt new file mode 100644 index 0000000000..033d43f1e1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_GenericEventCallback_TypeInference/TestComponent.ir.txt @@ -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 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.codegen.cs new file mode 100644 index 0000000000..99bcfbb9ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback>> __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "MyEvent", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.ir.txt new file mode 100644 index 0000000000..033d43f1e1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_NestedGenericEventCallback_TypeInference/TestComponent.ir.txt @@ -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 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.codegen.cs new file mode 100644 index 0000000000..f7a895d896 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "MyEvent", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.ir.txt new file mode 100644 index 0000000000..033d43f1e1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_NonGenericEventCallback_TypeInference/TestComponent.ir.txt @@ -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 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.codegen.cs new file mode 100644 index 0000000000..5cddba9bfe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.codegen.cs @@ -0,0 +1,32 @@ +// +#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(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 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.ir.txt new file mode 100644 index 0000000000..72984229f1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.ir.txt @@ -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 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.mappings.txt new file mode 100644 index 0000000000..ef96ec79b3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/NonGenericComponent_WithGenericEventHandler/TestComponent.mappings.txt @@ -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() {} +| +