From 64c9f3d789c603529166ba1e3099513e8d22a871 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Mon, 24 Jan 2022 11:22:21 -0800 Subject: [PATCH] Fixes additional scenarios with generic type constraints --- .../ComponentCodeGenerationTestBase.cs | 168 +++++++++++++++++- .../TestComponent.codegen.cs | 80 +++++++++ .../TestComponent.ir.txt | 45 +++++ .../TestComponent.mappings.txt | 10 ++ .../TestComponent.codegen.cs | 87 +++++++++ .../TestComponent.ir.txt | 48 +++++ .../TestComponent.mappings.txt | 15 ++ .../TestComponent.codegen.cs | 87 +++++++++ .../TestComponent.ir.txt | 48 +++++ .../TestComponent.mappings.txt | 15 ++ .../TestComponent.codegen.cs | 10 +- .../TestComponent.ir.txt | 44 ++--- .../TestComponent.mappings.txt | 8 +- .../UseTestComponent.codegen.cs | 6 +- .../UseTestComponent.codegen.cs | 6 +- .../TestComponent.codegen.cs | 52 ++++++ .../TestComponent.ir.txt | 32 ++++ .../TestComponent.codegen.cs | 59 ++++++ .../TestComponent.ir.txt | 33 ++++ .../TestComponent.codegen.cs | 59 ++++++ .../TestComponent.ir.txt | 33 ++++ .../TestComponent.codegen.cs | 4 +- .../TestComponent.ir.txt | 32 ++-- .../UseTestComponent.codegen.cs | 6 +- .../UseTestComponent.codegen.cs | 6 +- .../ComponentTagHelperDescriptorProvider.cs | 24 ++- .../RazorBaselineIntegrationTestBase.cs | 1 - 27 files changed, 944 insertions(+), 74 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.ir.txt diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index 2d3089741..6b9aa7cc8 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -3930,9 +3930,171 @@ public class WeatherForecast { } // Act var generated = CompileToCSharp(@" -())""> +())""> + + + + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void CascadingGenericInference_Inferred_MultipleConstraints() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [CascadingTypeParameter(nameof(TItem))] + public class Grid : ComponentBase + { + [Parameter] public RenderFragment ColumnsTemplate { get; set; } + } + + public abstract partial class BaseColumn : ComponentBase where TItem : class, new() + { + [CascadingParameter] + internal Grid Grid { get; set; } + } + + public class Column : BaseColumn, IGridFieldColumn where TItem : class, new() + { + [Parameter] + public string FieldName { get; set; } + } + + internal interface IGridFieldColumn where TItem : class + { + } + + public class WeatherForecast { } +} +")); + + // Act + var generated = CompileToCSharp(@" +())""> + + + + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; +using Models; + +namespace Test +{ + [CascadingTypeParameter(nameof(TItem))] + public class Grid : ComponentBase + { + [Parameter] public RenderFragment ColumnsTemplate { get; set; } + } + + public abstract partial class BaseColumn : ComponentBase where TItem : WeatherForecast, new() + { + [CascadingParameter] + internal Grid Grid { get; set; } + } + + public class Column : BaseColumn, IGridFieldColumn where TItem : WeatherForecast, new() + { + [Parameter] + public string FieldName { get; set; } + } + + internal interface IGridFieldColumn where TItem : class + { + } +} +namespace Models { + public class WeatherForecast { } +}")); + + // Act + var generated = CompileToCSharp(@" +@using Models; + +())""> + + + + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [CascadingTypeParameter(nameof(TItem))] + public class Grid : ComponentBase + { + [Parameter] public RenderFragment ColumnsTemplate { get; set; } + } + + public abstract partial class BaseColumn : ComponentBase where TItem : System.Collections.Generic.IEnumerable + { + [CascadingParameter] + internal Grid Grid { get; set; } + } + + public class Column : BaseColumn where TItem : System.Collections.Generic.IEnumerable + { + [Parameter] + public string FieldName { get; set; } + } +} + +namespace Models { + using System; + using System.Collections; + using System.Collections.Generic; + public class WeatherForecast : IEnumerable { + public IEnumerator GetEnumerator() + { + throw new NotImplementedException(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + throw new NotImplementedException(); + } + } +}")); + + // Act + var generated = CompileToCSharp(@" +@using Models; +())""> diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.codegen.cs new file mode 100644 index 000000000..aa8ae2840 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.codegen.cs @@ -0,0 +1,80 @@ +// +#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 partial class TestComponent : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = typeof( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + WeatherForecast + +#line default +#line hidden +#nullable disable + ); + __o = +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + Array.Empty() + +#line default +#line hidden +#nullable disable + ; + __builder.AddAttribute(-1, "ColumnsTemplate", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + global::__Blazor.Test.TestComponent.TypeInference.CreateColumn_0(__builder2, -1, default(WeatherForecast), -1, "", -1, "", -1, "", -1, ""); +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.Column<>); + +#line default +#line hidden +#nullable disable + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.Grid<>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateColumn_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, TItem __syntheticArg0, int __seq0, global::System.Object __arg0, int __seq1, global::System.String __arg1, int __seq2, global::System.Object __arg2, int __seq3, global::System.Object __arg3) + where TItem : class, new() + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Title", __arg0); + __builder.AddAttribute(__seq1, "FieldName", __arg1); + __builder.AddAttribute(__seq2, "Format", __arg2); + __builder.AddAttribute(__seq3, "Width", __arg3); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.ir.txt new file mode 100644 index 000000000..d81093038 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.ir.txt @@ -0,0 +1,45 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::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 [203] x:\dir\subdir\Test\TestComponent.cshtml) - Grid + ComponentChildContent - (78:1,4 [116] x:\dir\subdir\Test\TestComponent.cshtml) - ColumnsTemplate - context + HtmlContent - (95:1,21 [10] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (95:1,21 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + Component - (105:2,8 [65] x:\dir\subdir\Test\TestComponent.cshtml) - Column + ComponentAttribute - - Title - - AttributeStructure.DoubleQuotes + HtmlContent - (120:2,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (120:2,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - (137:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - FieldName - FieldName - AttributeStructure.DoubleQuotes + HtmlContent - (137:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (137:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - - Format - - AttributeStructure.DoubleQuotes + HtmlContent - (151:2,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (151:2,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - d + ComponentAttribute - - Width - - AttributeStructure.DoubleQuotes + HtmlContent - (161:2,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (161:2,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 10rem + HtmlContent - (170:2,73 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (170:2,73 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentTypeArgument - (13:0,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + LazyIntermediateToken - (13:0,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - WeatherForecast + ComponentAttribute - - Items - - AttributeStructure.DoubleQuotes + CSharpExpression - (37:0,37 [33] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (39:0,39 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Array.Empty() + HtmlContent - (203:4,7 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (203:4,7 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateColumn_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.mappings.txt new file mode 100644 index 000000000..f322aa0a9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (13:0,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|WeatherForecast| +Generated Location: (908:25,13 [15] ) +|WeatherForecast| + +Source Location: (39:0,39 [30] x:\dir\subdir\Test\TestComponent.cshtml) +|Array.Empty()| +Generated Location: (1120:34,39 [30] ) +|Array.Empty()| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.codegen.cs new file mode 100644 index 000000000..a9fe3af8f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.codegen.cs @@ -0,0 +1,87 @@ +// +#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 Models; + +#line default +#line hidden +#nullable disable + public partial class TestComponent : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = typeof( +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + WeatherForecast + +#line default +#line hidden +#nullable disable + ); + __o = +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + Array.Empty() + +#line default +#line hidden +#nullable disable + ; + __builder.AddAttribute(-1, "ColumnsTemplate", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + global::__Blazor.Test.TestComponent.TypeInference.CreateColumn_0(__builder2, -1, default(WeatherForecast), -1, "", -1, "", -1, "", -1, ""); +#nullable restore +#line 5 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.Column<>); + +#line default +#line hidden +#nullable disable + } + )); +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.Grid<>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateColumn_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, TItem __syntheticArg0, int __seq0, global::System.Object __arg0, int __seq1, global::System.String __arg1, int __seq2, global::System.Object __arg2, int __seq3, global::System.Object __arg3) + where TItem : global::Models.WeatherForecast, new() + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Title", __arg0); + __builder.AddAttribute(__seq1, "FieldName", __arg1); + __builder.AddAttribute(__seq2, "Format", __arg2); + __builder.AddAttribute(__seq3, "Width", __arg3); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.ir.txt new file mode 100644 index 000000000..2fd95175b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.ir.txt @@ -0,0 +1,48 @@ +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 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Models + ClassDeclaration - - public partial - TestComponent - global::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 - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + Component - (18:2,0 [203] x:\dir\subdir\Test\TestComponent.cshtml) - Grid + ComponentChildContent - (96:3,4 [116] x:\dir\subdir\Test\TestComponent.cshtml) - ColumnsTemplate - context + HtmlContent - (113:3,21 [10] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (113:3,21 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + Component - (123:4,8 [65] x:\dir\subdir\Test\TestComponent.cshtml) - Column + ComponentAttribute - - Title - - AttributeStructure.DoubleQuotes + HtmlContent - (138:4,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (138:4,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - (155:4,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - FieldName - FieldName - AttributeStructure.DoubleQuotes + HtmlContent - (155:4,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (155:4,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - - Format - - AttributeStructure.DoubleQuotes + HtmlContent - (169:4,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (169:4,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - d + ComponentAttribute - - Width - - AttributeStructure.DoubleQuotes + HtmlContent - (179:4,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (179:4,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 10rem + HtmlContent - (188:4,73 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (188:4,73 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentTypeArgument - (31:2,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + LazyIntermediateToken - (31:2,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - WeatherForecast + ComponentAttribute - - Items - - AttributeStructure.DoubleQuotes + CSharpExpression - (55:2,37 [33] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (57:2,39 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Array.Empty() + HtmlContent - (221:6,7 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (221:6,7 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateColumn_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.mappings.txt new file mode 100644 index 000000000..eeee3296d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (1:0,1 [13] x:\dir\subdir\Test\TestComponent.cshtml) +|using Models;| +Generated Location: (320:12,0 [13] ) +|using Models;| + +Source Location: (31:2,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|WeatherForecast| +Generated Location: (1043:32,13 [15] ) +|WeatherForecast| + +Source Location: (57:2,39 [30] x:\dir\subdir\Test\TestComponent.cshtml) +|Array.Empty()| +Generated Location: (1255:41,39 [30] ) +|Array.Empty()| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.codegen.cs new file mode 100644 index 000000000..f8a5fce70 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.codegen.cs @@ -0,0 +1,87 @@ +// +#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 Models; + +#line default +#line hidden +#nullable disable + public partial class TestComponent : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = typeof( +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + WeatherForecast + +#line default +#line hidden +#nullable disable + ); + __o = +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + Array.Empty() + +#line default +#line hidden +#nullable disable + ; + __builder.AddAttribute(-1, "ColumnsTemplate", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + global::__Blazor.Test.TestComponent.TypeInference.CreateColumn_0(__builder2, -1, default(WeatherForecast), -1, "", -1, "", -1, "", -1, ""); +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.Column<>); + +#line default +#line hidden +#nullable disable + } + )); +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.Grid<>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateColumn_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, TItem __syntheticArg0, int __seq0, global::System.Object __arg0, int __seq1, global::System.String __arg1, int __seq2, global::System.Object __arg2, int __seq3, global::System.Object __arg3) + where TItem : global::System.Collections.Generic.IEnumerable + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Title", __arg0); + __builder.AddAttribute(__seq1, "FieldName", __arg1); + __builder.AddAttribute(__seq2, "Format", __arg2); + __builder.AddAttribute(__seq3, "Width", __arg3); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.ir.txt new file mode 100644 index 000000000..5cddd5e3e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.ir.txt @@ -0,0 +1,48 @@ +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 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Models + ClassDeclaration - - public partial - TestComponent - global::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 - (14:0,14 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (14:0,14 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + Component - (16:1,0 [203] x:\dir\subdir\Test\TestComponent.cshtml) - Grid + ComponentChildContent - (94:2,4 [116] x:\dir\subdir\Test\TestComponent.cshtml) - ColumnsTemplate - context + HtmlContent - (111:2,21 [10] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (111:2,21 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + Component - (121:3,8 [65] x:\dir\subdir\Test\TestComponent.cshtml) - Column + ComponentAttribute - - Title - - AttributeStructure.DoubleQuotes + HtmlContent - (136:3,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (136:3,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - (153:3,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - FieldName - FieldName - AttributeStructure.DoubleQuotes + HtmlContent - (153:3,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (153:3,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - - Format - - AttributeStructure.DoubleQuotes + HtmlContent - (167:3,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (167:3,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - d + ComponentAttribute - - Width - - AttributeStructure.DoubleQuotes + HtmlContent - (177:3,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (177:3,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 10rem + HtmlContent - (186:3,73 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (186:3,73 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentTypeArgument - (29:1,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + LazyIntermediateToken - (29:1,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - WeatherForecast + ComponentAttribute - - Items - - AttributeStructure.DoubleQuotes + CSharpExpression - (53:1,37 [33] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (55:1,39 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Array.Empty() + HtmlContent - (219:5,7 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (219:5,7 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateColumn_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.mappings.txt new file mode 100644 index 000000000..46f871b69 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (1:0,1 [13] x:\dir\subdir\Test\TestComponent.cshtml) +|using Models;| +Generated Location: (320:12,0 [13] ) +|using Models;| + +Source Location: (29:1,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|WeatherForecast| +Generated Location: (1043:32,13 [15] ) +|WeatherForecast| + +Source Location: (55:1,39 [30] x:\dir\subdir\Test\TestComponent.cshtml) +|Array.Empty()| +Generated Location: (1255:41,39 [30] ) +|Array.Empty()| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.codegen.cs index a9aacbcae..9451e432c 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.codegen.cs @@ -22,8 +22,8 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. { __o = typeof( #nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - WeatherForecast +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + WeatherForecast #line default #line hidden @@ -31,8 +31,8 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. ); __o = #nullable restore -#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" - Array.Empty() +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + Array.Empty() #line default #line hidden @@ -41,7 +41,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. __builder.AddAttribute(-1, "ColumnsTemplate", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { global::__Blazor.Test.TestComponent.TypeInference.CreateColumn_0(__builder2, -1, default(WeatherForecast), -1, "", -1, "", -1, "", -1, ""); #nullable restore -#line 5 "x:\dir\subdir\Test\TestComponent.cshtml" +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" __o = typeof(global::Test.Column<>); #line default diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.ir.txt index d680b652d..d81093038 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.ir.txt @@ -14,32 +14,32 @@ Document - CSharpCode - IntermediateToken - - CSharp - #pragma warning restore 0414 MethodDeclaration - - protected override - void - BuildRenderTree - Component - (0:0,0 [205] x:\dir\subdir\Test\TestComponent.cshtml) - Grid - ComponentChildContent - (80:3,4 [116] x:\dir\subdir\Test\TestComponent.cshtml) - ColumnsTemplate - context - HtmlContent - (97:3,21 [10] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (97:3,21 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - Component - (107:4,8 [65] x:\dir\subdir\Test\TestComponent.cshtml) - Column + Component - (0:0,0 [203] x:\dir\subdir\Test\TestComponent.cshtml) - Grid + ComponentChildContent - (78:1,4 [116] x:\dir\subdir\Test\TestComponent.cshtml) - ColumnsTemplate - context + HtmlContent - (95:1,21 [10] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (95:1,21 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + Component - (105:2,8 [65] x:\dir\subdir\Test\TestComponent.cshtml) - Column ComponentAttribute - - Title - - AttributeStructure.DoubleQuotes - HtmlContent - (122:4,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (122:4,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date - ComponentAttribute - (139:4,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - FieldName - FieldName - AttributeStructure.DoubleQuotes - HtmlContent - (139:4,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (139:4,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + HtmlContent - (120:2,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (120:2,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - (137:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - FieldName - FieldName - AttributeStructure.DoubleQuotes + HtmlContent - (137:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (137:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date ComponentAttribute - - Format - - AttributeStructure.DoubleQuotes - HtmlContent - (153:4,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (153:4,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - d + HtmlContent - (151:2,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (151:2,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - d ComponentAttribute - - Width - - AttributeStructure.DoubleQuotes - HtmlContent - (163:4,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (163:4,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 10rem - HtmlContent - (172:4,73 [6] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (172:4,73 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - ComponentTypeArgument - (14:1,7 [15] x:\dir\subdir\Test\TestComponent.cshtml) - TItem - LazyIntermediateToken - (14:1,7 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - WeatherForecast + HtmlContent - (161:2,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (161:2,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 10rem + HtmlContent - (170:2,73 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (170:2,73 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentTypeArgument - (13:0,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + LazyIntermediateToken - (13:0,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - WeatherForecast ComponentAttribute - - Items - - AttributeStructure.DoubleQuotes - CSharpExpression - (39:2,7 [33] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (41:2,9 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Array.Empty() - HtmlContent - (205:6,7 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (205:6,7 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (37:0,37 [33] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (39:0,39 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Array.Empty() + HtmlContent - (203:4,7 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (203:4,7 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n NamespaceDeclaration - - __Blazor.Test.TestComponent ClassDeclaration - - internal static - TypeInference - - ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateColumn_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.mappings.txt index 4fde5dac3..f322aa0a9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.mappings.txt @@ -1,10 +1,10 @@ -Source Location: (14:1,7 [15] x:\dir\subdir\Test\TestComponent.cshtml) +Source Location: (13:0,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) |WeatherForecast| -Generated Location: (902:25,7 [15] ) +Generated Location: (908:25,13 [15] ) |WeatherForecast| -Source Location: (41:2,9 [30] x:\dir\subdir\Test\TestComponent.cshtml) +Source Location: (39:0,39 [30] x:\dir\subdir\Test\TestComponent.cshtml) |Array.Empty()| -Generated Location: (1084:34,9 [30] ) +Generated Location: (1120:34,39 [30] ) |Array.Empty()| diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/UseTestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/UseTestComponent.codegen.cs index c34accb6a..7686eda68 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/UseTestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/UseTestComponent.codegen.cs @@ -89,9 +89,9 @@ namespace __Blazor.Test.UseTestComponent internal static class TypeInference { public static void CreateTestComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, TItem1 __arg0, int __seq1, global::System.Collections.Generic.List __arg1, int __seq2, TItem3 __arg2, int __seq3, global::Microsoft.AspNetCore.Components.RenderFragment __arg3) - where TItem1 : Image - where TItem2 : ITag - where TItem3 : Image, new() + where TItem1 : global::Image + where TItem2 : global::ITag + where TItem3 : global::Image, new() { __builder.OpenComponent>(seq); __builder.AddAttribute(__seq0, "Item1", __arg0); diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs index c34accb6a..7686eda68 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs @@ -89,9 +89,9 @@ namespace __Blazor.Test.UseTestComponent internal static class TypeInference { public static void CreateTestComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, TItem1 __arg0, int __seq1, global::System.Collections.Generic.List __arg1, int __seq2, TItem3 __arg2, int __seq3, global::Microsoft.AspNetCore.Components.RenderFragment __arg3) - where TItem1 : Image - where TItem2 : ITag - where TItem3 : Image, new() + where TItem1 : global::Image + where TItem2 : global::ITag + where TItem3 : global::Image, new() { __builder.OpenComponent>(seq); __builder.AddAttribute(__seq0, "Item1", __arg0); diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.codegen.cs new file mode 100644 index 000000000..3d35956ea --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.codegen.cs @@ -0,0 +1,52 @@ +// +#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 partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent>(0); + __builder.AddAttribute(1, "Items", +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + Array.Empty() + +#line default +#line hidden +#nullable disable + ); + __builder.AddAttribute(2, "ColumnsTemplate", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + global::__Blazor.Test.TestComponent.TypeInference.CreateColumn_0(__builder2, 3, default(WeatherForecast), 4, "Date", 5, "Date", 6, "d", 7, "10rem"); + } + )); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateColumn_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, TItem __syntheticArg0, int __seq0, global::System.Object __arg0, int __seq1, global::System.String __arg1, int __seq2, global::System.Object __arg2, int __seq3, global::System.Object __arg3) + where TItem : class, new() + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Title", __arg0); + __builder.AddAttribute(__seq1, "FieldName", __arg1); + __builder.AddAttribute(__seq2, "Format", __arg2); + __builder.AddAttribute(__seq3, "Width", __arg3); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.ir.txt new file mode 100644 index 000000000..043cbd8a8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints/TestComponent.ir.txt @@ -0,0 +1,32 @@ +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 partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [203] x:\dir\subdir\Test\TestComponent.cshtml) - Grid + ComponentChildContent - (78:1,4 [116] x:\dir\subdir\Test\TestComponent.cshtml) - ColumnsTemplate - context + Component - (105:2,8 [65] x:\dir\subdir\Test\TestComponent.cshtml) - Column + ComponentAttribute - - Title - - AttributeStructure.DoubleQuotes + HtmlContent - (120:2,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (120:2,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - (137:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - FieldName - FieldName - AttributeStructure.DoubleQuotes + HtmlContent - (137:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (137:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - - Format - - AttributeStructure.DoubleQuotes + HtmlContent - (151:2,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (151:2,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - d + ComponentAttribute - - Width - - AttributeStructure.DoubleQuotes + HtmlContent - (161:2,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (161:2,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 10rem + ComponentTypeArgument - (13:0,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + LazyIntermediateToken - (13:0,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - WeatherForecast + ComponentAttribute - - Items - - AttributeStructure.DoubleQuotes + CSharpExpression - (37:0,37 [33] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (39:0,39 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Array.Empty() + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateColumn_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.codegen.cs new file mode 100644 index 000000000..2a23b800e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.codegen.cs @@ -0,0 +1,59 @@ +// +#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 Models; + +#line default +#line hidden +#nullable disable + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent>(0); + __builder.AddAttribute(1, "Items", +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + Array.Empty() + +#line default +#line hidden +#nullable disable + ); + __builder.AddAttribute(2, "ColumnsTemplate", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + global::__Blazor.Test.TestComponent.TypeInference.CreateColumn_0(__builder2, 3, default(WeatherForecast), 4, "Date", 5, "Date", 6, "d", 7, "10rem"); + } + )); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateColumn_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, TItem __syntheticArg0, int __seq0, global::System.Object __arg0, int __seq1, global::System.String __arg1, int __seq2, global::System.Object __arg2, int __seq3, global::System.Object __arg3) + where TItem : global::Models.WeatherForecast, new() + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Title", __arg0); + __builder.AddAttribute(__seq1, "FieldName", __arg1); + __builder.AddAttribute(__seq2, "Format", __arg2); + __builder.AddAttribute(__seq3, "Width", __arg3); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.ir.txt new file mode 100644 index 000000000..af26e187a --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_ClassesAndInterfaces/TestComponent.ir.txt @@ -0,0 +1,33 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + UsingDirective - (1:0,1 [15] x:\dir\subdir\Test\TestComponent.cshtml) - Models + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (18:2,0 [203] x:\dir\subdir\Test\TestComponent.cshtml) - Grid + ComponentChildContent - (96:3,4 [116] x:\dir\subdir\Test\TestComponent.cshtml) - ColumnsTemplate - context + Component - (123:4,8 [65] x:\dir\subdir\Test\TestComponent.cshtml) - Column + ComponentAttribute - - Title - - AttributeStructure.DoubleQuotes + HtmlContent - (138:4,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (138:4,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - (155:4,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - FieldName - FieldName - AttributeStructure.DoubleQuotes + HtmlContent - (155:4,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (155:4,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - - Format - - AttributeStructure.DoubleQuotes + HtmlContent - (169:4,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (169:4,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - d + ComponentAttribute - - Width - - AttributeStructure.DoubleQuotes + HtmlContent - (179:4,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (179:4,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 10rem + ComponentTypeArgument - (31:2,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + LazyIntermediateToken - (31:2,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - WeatherForecast + ComponentAttribute - - Items - - AttributeStructure.DoubleQuotes + CSharpExpression - (55:2,37 [33] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (57:2,39 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Array.Empty() + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateColumn_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.codegen.cs new file mode 100644 index 000000000..c1bd2101f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.codegen.cs @@ -0,0 +1,59 @@ +// +#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 Models; + +#line default +#line hidden +#nullable disable + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent>(0); + __builder.AddAttribute(1, "Items", +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + Array.Empty() + +#line default +#line hidden +#nullable disable + ); + __builder.AddAttribute(2, "ColumnsTemplate", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + global::__Blazor.Test.TestComponent.TypeInference.CreateColumn_0(__builder2, 3, default(WeatherForecast), 4, "Date", 5, "Date", 6, "d", 7, "10rem"); + } + )); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateColumn_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, TItem __syntheticArg0, int __seq0, global::System.Object __arg0, int __seq1, global::System.String __arg1, int __seq2, global::System.Object __arg2, int __seq3, global::System.Object __arg3) + where TItem : global::System.Collections.Generic.IEnumerable + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Title", __arg0); + __builder.AddAttribute(__seq1, "FieldName", __arg1); + __builder.AddAttribute(__seq2, "Format", __arg2); + __builder.AddAttribute(__seq3, "Width", __arg3); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.ir.txt new file mode 100644 index 000000000..e8f504b23 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_MultipleConstraints_GenericClassConstraints/TestComponent.ir.txt @@ -0,0 +1,33 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + UsingDirective - (1:0,1 [15] x:\dir\subdir\Test\TestComponent.cshtml) - Models + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (16:1,0 [203] x:\dir\subdir\Test\TestComponent.cshtml) - Grid + ComponentChildContent - (94:2,4 [116] x:\dir\subdir\Test\TestComponent.cshtml) - ColumnsTemplate - context + Component - (121:3,8 [65] x:\dir\subdir\Test\TestComponent.cshtml) - Column + ComponentAttribute - - Title - - AttributeStructure.DoubleQuotes + HtmlContent - (136:3,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (136:3,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - (153:3,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - FieldName - FieldName - AttributeStructure.DoubleQuotes + HtmlContent - (153:3,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (153:3,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - - Format - - AttributeStructure.DoubleQuotes + HtmlContent - (167:3,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (167:3,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - d + ComponentAttribute - - Width - - AttributeStructure.DoubleQuotes + HtmlContent - (177:3,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (177:3,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 10rem + ComponentTypeArgument - (29:1,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + LazyIntermediateToken - (29:1,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - WeatherForecast + ComponentAttribute - - Items - - AttributeStructure.DoubleQuotes + CSharpExpression - (53:1,37 [33] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (55:1,39 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Array.Empty() + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateColumn_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.codegen.cs index a6952ac36..8ffe8fb64 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.codegen.cs @@ -16,8 +16,8 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. __builder.OpenComponent>(0); __builder.AddAttribute(1, "Items", #nullable restore -#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" - Array.Empty() +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + Array.Empty() #line default #line hidden diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.ir.txt index 663cb7285..043cbd8a8 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/CascadingGenericInference_Inferred_WithConstraints/TestComponent.ir.txt @@ -7,26 +7,26 @@ Document - UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree - Component - (0:0,0 [205] x:\dir\subdir\Test\TestComponent.cshtml) - Grid - ComponentChildContent - (80:3,4 [116] x:\dir\subdir\Test\TestComponent.cshtml) - ColumnsTemplate - context - Component - (107:4,8 [65] x:\dir\subdir\Test\TestComponent.cshtml) - Column + Component - (0:0,0 [203] x:\dir\subdir\Test\TestComponent.cshtml) - Grid + ComponentChildContent - (78:1,4 [116] x:\dir\subdir\Test\TestComponent.cshtml) - ColumnsTemplate - context + Component - (105:2,8 [65] x:\dir\subdir\Test\TestComponent.cshtml) - Column ComponentAttribute - - Title - - AttributeStructure.DoubleQuotes - HtmlContent - (122:4,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (122:4,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date - ComponentAttribute - (139:4,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - FieldName - FieldName - AttributeStructure.DoubleQuotes - HtmlContent - (139:4,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (139:4,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + HtmlContent - (120:2,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (120:2,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date + ComponentAttribute - (137:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - FieldName - FieldName - AttributeStructure.DoubleQuotes + HtmlContent - (137:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (137:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Date ComponentAttribute - - Format - - AttributeStructure.DoubleQuotes - HtmlContent - (153:4,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (153:4,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - d + HtmlContent - (151:2,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (151:2,54 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - d ComponentAttribute - - Width - - AttributeStructure.DoubleQuotes - HtmlContent - (163:4,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (163:4,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 10rem - ComponentTypeArgument - (14:1,7 [15] x:\dir\subdir\Test\TestComponent.cshtml) - TItem - LazyIntermediateToken - (14:1,7 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - WeatherForecast + HtmlContent - (161:2,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (161:2,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 10rem + ComponentTypeArgument - (13:0,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + LazyIntermediateToken - (13:0,13 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - WeatherForecast ComponentAttribute - - Items - - AttributeStructure.DoubleQuotes - CSharpExpression - (39:2,7 [33] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (41:2,9 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Array.Empty() + CSharpExpression - (37:0,37 [33] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (39:0,39 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Array.Empty() NamespaceDeclaration - - __Blazor.Test.TestComponent ClassDeclaration - - internal static - TypeInference - - ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateColumn_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/UseTestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/UseTestComponent.codegen.cs index 7125827d8..5bcdd7194 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/UseTestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/UseTestComponent.codegen.cs @@ -77,9 +77,9 @@ namespace __Blazor.Test.UseTestComponent internal static class TypeInference { public static void CreateTestComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, TItem1 __arg0, int __seq1, global::System.Collections.Generic.List __arg1, int __seq2, TItem3 __arg2, int __seq3, global::Microsoft.AspNetCore.Components.RenderFragment __arg3) - where TItem1 : Image - where TItem2 : ITag - where TItem3 : Image, new() + where TItem1 : global::Image + where TItem2 : global::ITag + where TItem3 : global::Image, new() { __builder.OpenComponent>(seq); __builder.AddAttribute(__seq0, "Item1", __arg0); diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs index 7125827d8..5bcdd7194 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs @@ -77,9 +77,9 @@ namespace __Blazor.Test.UseTestComponent internal static class TypeInference { public static void CreateTestComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, TItem1 __arg0, int __seq1, global::System.Collections.Generic.List __arg1, int __seq2, TItem3 __arg2, int __seq3, global::Microsoft.AspNetCore.Components.RenderFragment __arg3) - where TItem1 : Image - where TItem2 : ITag - where TItem3 : Image, new() + where TItem1 : global::Image + where TItem2 : global::ITag + where TItem3 : global::Image, new() { __builder.OpenComponent>(seq); __builder.AddAttribute(__seq0, "Item1", __arg0); diff --git a/src/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs b/src/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs index 09efbd722..761d8e160 100644 --- a/src/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs +++ b/src/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs @@ -18,6 +18,11 @@ internal class ComponentTagHelperDescriptorProvider : RazorEngineFeatureBase, IT .WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted) .WithMiscellaneousOptions(SymbolDisplayFormat.FullyQualifiedFormat.MiscellaneousOptions & (~SymbolDisplayMiscellaneousOptions.UseSpecialTypes)); + private static readonly SymbolDisplayFormat GloballyQualifiedFullNameTypeDisplayFormat = + SymbolDisplayFormat.FullyQualifiedFormat + .WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Included) + .WithMiscellaneousOptions(SymbolDisplayFormat.FullyQualifiedFormat.MiscellaneousOptions & (~SymbolDisplayMiscellaneousOptions.UseSpecialTypes)); + public bool IncludeDocumentation { get; set; } public int Order { get; set; } @@ -273,27 +278,28 @@ private void CreateTypeParameterProperty(TagHelperDescriptorBuilder builder, ITy var list = new List(); for (var i = 0; i < typeParameter.ConstraintTypes.Length; i++) { - list.Add(typeParameter.ConstraintTypes[i].Name); + var constraintType = typeParameter.ConstraintTypes[i]; + list.Add(constraintType.ToDisplayString(GloballyQualifiedFullNameTypeDisplayFormat)); } - if (typeParameter.HasConstructorConstraint) + if (typeParameter.HasReferenceTypeConstraint) { - list.Add("new()"); + list.Add("class"); } - if (typeParameter.HasNotNullConstraint) + if (typeParameter.HasValueTypeConstraint) { - list.Add("notnull"); + list.Add("struct"); } - if (typeParameter.HasReferenceTypeConstraint) + if (typeParameter.HasNotNullConstraint) { - list.Add("class"); + list.Add("notnull"); } if (typeParameter.HasUnmanagedTypeConstraint) { list.Add("unmanaged"); } - if (typeParameter.HasValueTypeConstraint) + if (typeParameter.HasConstructorConstraint) { - list.Add("struct"); + list.Add("new()"); } if (list.Count > 0) diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs index 5eabd9c16..03d12a3c3 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs @@ -186,7 +186,6 @@ protected void AssertLinePragmas(RazorCodeDocument codeDocument) } else { - var syntaxTree = codeDocument.GetSyntaxTree(); var sourceBuffer = new char[syntaxTree.Source.Length]; syntaxTree.Source.CopyTo(0, sourceBuffer, 0, syntaxTree.Source.Length);