diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs index 3c0f16551ffe..5ac8f6c01c1e 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs @@ -1313,6 +1313,7 @@ private void ParseExtensibleDirective(in SyntaxListBuilder buil { if (!At(SyntaxKind.Whitespace) && !At(SyntaxKind.NewLine) && + !At(SyntaxKind.Semicolon) && !EndOfFile) { // This case should never happen in a real scenario. We're just being defensive. @@ -1487,6 +1488,13 @@ private void ParseExtensibleDirective(in SyntaxListBuilder buil { while (!At(SyntaxKind.NewLine)) { + if (At(SyntaxKind.Semicolon)) + { + // Consume the ending ';' + EatCurrentToken(); + break; + } + AcceptAndMoveNext(); if (EndOfFile) { @@ -1496,6 +1504,11 @@ private void ParseExtensibleDirective(in SyntaxListBuilder buil } } } + else if (At(SyntaxKind.Semicolon)) + { + // Consume the ending ';' + EatCurrentToken(); + } else { Context.ErrorSink.OnError( 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 84d06cd5a226..c65bb41bb464 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -3,7 +3,6 @@ using System.Linq; using Microsoft.AspNetCore.Razor.Language.Components; -using Microsoft.AspNetCore.Testing; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests @@ -212,6 +211,36 @@ public void ComponentWithTypeParameters() @typeparam TItem1 @typeparam TItem2 +

Item1

+@foreach (var item2 in Items2) +{ +

+ @ChildContent(item2); +

+} +@code { + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ComponentWithTypeParameters_WithSemicolon() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components; +@typeparam TItem1; +@typeparam TItem2; +

Item1

@foreach (var item2 in Items2) { @@ -356,6 +385,83 @@ @using Test

@context

+@code { + Image item1 = new Image() { id = 1, url=""https://example.com""}; + static Tag tag1 = new Tag() { description = ""A description.""}; + static Tag tag2 = new Tag() { description = ""Another description.""}; + List items = new List() { tag1, tag2 }; +}"); + AssertDocumentNodeMatchesBaseline(useGenerated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(useGenerated.CodeDocument); + CompileToAssembly(useGenerated); + } + + [Fact] + public void ComponentWithConstrainedTypeParameters_WithSemicolon() + { + // Arrange + var classes = @" +public class Image +{ + public string url { get; set; } + public int id { get; set; } + + public Image() + { + url = ""https://example.com/default.png""; + id = 1; + } +} + +public interface ITag +{ + string description { get; set; } +} + +public class Tag : ITag +{ + public string description { get; set; } +} +"; + + AdditionalSyntaxTrees.Add(Parse(classes)); + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components; +@typeparam TItem1 where TItem1 : Image; +@typeparam TItem2 where TItem2 : ITag; +@typeparam TItem3 where TItem3 : Image, new(); + +

Item1

+@foreach (var item2 in Items2) +{ +

+ @ChildContent(item2); +

+} + +

Item3

+ +@code { + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public TItem3 Item3 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + + AdditionalSyntaxTrees.Add(Parse(generated.CodeDocument.GetCSharpDocument().GeneratedCode)); + var useGenerated = CompileToCSharp("UseTestComponent.cshtml", @" +@using Test + +

@context

+
+ @code { Image item1 = new Image() { id = 1, url=""https://example.com""}; static Tag tag1 = new Tag() { description = ""A description.""}; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiscoveryIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiscoveryIntegrationTest.cs index 10d3ceb8011a..f2f73b80166b 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiscoveryIntegrationTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiscoveryIntegrationTest.cs @@ -100,6 +100,23 @@ @typeparam TItem Assert.Contains(bindings.TagHelpers, t => t.Name == "Test.UniqueName"); } + [Fact] + public void ComponentDiscovery_CanFindComponent_WithTypeParameterAndSemicolon() + { + // Arrange + + // Act + var result = CompileToCSharp("UniqueName.cshtml", @" +@typeparam TItem; +@functions { + [Parameter] public TItem Item { get; set; } +}"); + + // Assert + var bindings = result.CodeDocument.GetTagHelperContext(); + Assert.Contains(bindings.TagHelpers, t => t.Name == "Test.UniqueName"); + } + [Fact] public void ComponentDiscovery_CanFindComponent_WithMultipleTypeParameters() { @@ -110,6 +127,25 @@ public void ComponentDiscovery_CanFindComponent_WithMultipleTypeParameters() @typeparam TItem1 @typeparam TItem2 @typeparam TItem3 +@functions { + [Parameter] public TItem1 Item { get; set; } +}"); + + // Assert + var bindings = result.CodeDocument.GetTagHelperContext(); + Assert.Contains(bindings.TagHelpers, t => t.Name == "Test.UniqueName"); + } + + [Fact] + public void ComponentDiscovery_CanFindComponent_WithMultipleTypeParametersAndMixedSemicolons() + { + // Arrange + + // Act + var result = CompileToCSharp("UniqueName.cshtml", @" +@typeparam TItem1 +@typeparam TItem2; +@typeparam TItem3 @functions { [Parameter] public TItem1 Item { get; set; } }"); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.codegen.cs new file mode 100644 index 000000000000..c88f3f905c46 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.codegen.cs @@ -0,0 +1,149 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +using Microsoft.AspNetCore.Components; + +#line default +#line hidden +#nullable disable + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + where TItem1 : Image + where TItem2 : ITag + where TItem3 : Image, new() + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object TItem1 = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#pragma warning disable CS0693 +#pragma warning disable CS8321 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +void __TypeConstraints_TItem1() where TItem1 : Image +{ +} +#pragma warning restore CS0693 +#pragma warning restore CS8321 + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object TItem2 = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#pragma warning disable CS0693 +#pragma warning disable CS8321 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" +void __TypeConstraints_TItem2() where TItem2 : ITag +{ +} +#pragma warning restore CS0693 +#pragma warning restore CS8321 + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object TItem3 = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#pragma warning disable CS0693 +#pragma warning disable CS8321 +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" +void __TypeConstraints_TItem3() where TItem3 : Image, new() +{ +} +#pragma warning restore CS0693 +#pragma warning restore CS8321 + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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) + { +#nullable restore +#line 6 "x:\dir\subdir\Test\TestComponent.cshtml" + foreach (var item2 in Items2) +{ + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = ChildContent(item2); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 11 "x:\dir\subdir\Test\TestComponent.cshtml" + +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 16 "x:\dir\subdir\Test\TestComponent.cshtml" + + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public TItem3 Item3 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.ir.txt new file mode 100644 index 000000000000..4a05bd5e4717 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.ir.txt @@ -0,0 +1,51 @@ +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 - (1:0,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - - TItem1, TItem2, TItem3 + DesignTimeDirective - + DirectiveToken - (52:1,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem1 + DirectiveToken - (59:1,18 [20] x:\dir\subdir\Test\TestComponent.cshtml) - where TItem1 : Image + DirectiveToken - (92:2,10 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem2 + DirectiveToken - (99:2,17 [19] x:\dir\subdir\Test\TestComponent.cshtml) - where TItem2 : ITag + DirectiveToken - (131:3,9 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem3 + DirectiveToken - (138:3,16 [27] x:\dir\subdir\Test\TestComponent.cshtml) - where TItem3 : Image, new() + 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 - (39:0,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (39:0,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (167:3,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (167:3,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (169:3,47 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (173:5,1 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (173:5,1 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Item1 + HtmlContent - (183:5,11 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (183:5,11 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (186:5,14 [38] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (186:5,14 [38] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - foreach (var item2 in Items2)\n{\n + MarkupElement - (224:8,1 [40] x:\dir\subdir\Test\TestComponent.cshtml) - p + HtmlContent - (227:8,4 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (227:8,4 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (234:9,2 [19] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (234:9,2 [19] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ChildContent(item2) + HtmlContent - (253:9,21 [7] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (253:9,21 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n + CSharpCode - (264:10,5 [3] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (264:10,5 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n} + HtmlContent - (267:10,8 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (267:10,8 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + MarkupElement - (271:11,2 [12] x:\dir\subdir\Test\TestComponent.cshtml) - p + HtmlContent - (274:13,0 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (274:13,0 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Item3 + HtmlContent - (283:13,9 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (283:13,9 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + CSharpCode - (294:15,4 [236] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (294:15,4 [236] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n [Parameter] public TItem1 Item1 { get; set; }\n [Parameter] public List Items2 { get; set; }\n [Parameter] public TItem3 Item3 { get; set; }\n [Parameter] public RenderFragment ChildContent { get; set; }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.mappings.txt new file mode 100644 index 000000000000..396c95bf1095 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.mappings.txt @@ -0,0 +1,70 @@ +Source Location: (1:0,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) +|using Microsoft.AspNetCore.Components;| +Generated Location: (276:11,0 [38] ) +|using Microsoft.AspNetCore.Components;| + +Source Location: (52:1,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|TItem1| +Generated Location: (789:26,22 [6] ) +|TItem1| + +Source Location: (59:1,18 [20] x:\dir\subdir\Test\TestComponent.cshtml) +|where TItem1 : Image| +Generated Location: (1090:38,40 [20] ) +|where TItem1 : Image| + +Source Location: (92:2,10 [6] x:\dir\subdir\Test\TestComponent.cshtml) +| TItem| +Generated Location: (1384:52,22 [6] ) +|TItem2| + +Source Location: (99:2,17 [19] x:\dir\subdir\Test\TestComponent.cshtml) +| where TItem2 : ITa| +Generated Location: (1685:64,40 [19] ) +|where TItem2 : ITag| + +Source Location: (131:3,9 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|m TIte| +Generated Location: (1978:78,22 [6] ) +|TItem3| + +Source Location: (138:3,16 [27] x:\dir\subdir\Test\TestComponent.cshtml) +|3 where TItem3 : Image, new| +Generated Location: (2279:90,40 [27] ) +|where TItem3 : Image, new()| + +Source Location: (186:5,14 [38] x:\dir\subdir\Test\TestComponent.cshtml) +| +@foreach (var item2 in Items2) +{ + | +Generated Location: (2881:111,14 [38] ) +|foreach (var item2 in Items2) +{ + | + +Source Location: (234:9,2 [19] x:\dir\subdir\Test\TestComponent.cshtml) +| @ChildContent(ite| +Generated Location: (3048:120,6 [19] ) +|ChildContent(item2)| + +Source Location: (264:10,5 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|/p>| +Generated Location: (3196:127,5 [3] ) +| +}| + +Source Location: (294:15,4 [236] x:\dir\subdir\Test\TestComponent.cshtml) +|e { + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public TItem3 Item3 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; | +Generated Location: (3375:137,4 [236] ) +| + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public TItem3 Item3 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs new file mode 100644 index 000000000000..27168993b6ae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs @@ -0,0 +1,105 @@ +// +#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\UseTestComponent.cshtml" +using Test; + +#line default +#line hidden +#nullable disable + public partial class UseTestComponent : 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.UseTestComponent.TypeInference.CreateTestComponent_0(__builder, -1, -1, +#nullable restore +#line 2 "x:\dir\subdir\Test\UseTestComponent.cshtml" + item1 + +#line default +#line hidden +#nullable disable + , -1, +#nullable restore +#line 2 "x:\dir\subdir\Test\UseTestComponent.cshtml" + items + +#line default +#line hidden +#nullable disable + , -1, +#nullable restore +#line 2 "x:\dir\subdir\Test\UseTestComponent.cshtml" + item1 + +#line default +#line hidden +#nullable disable + , -1, (context) => (__builder2) => { +#nullable restore +#line 3 "x:\dir\subdir\Test\UseTestComponent.cshtml" + __o = context; + +#line default +#line hidden +#nullable disable + } + ); +#nullable restore +#line 2 "x:\dir\subdir\Test\UseTestComponent.cshtml" +__o = typeof(TestComponent<,,>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 6 "x:\dir\subdir\Test\UseTestComponent.cshtml" + + Image item1 = new Image() { id = 1, url="https://example.com"}; + static Tag tag1 = new Tag() { description = "A description."}; + static Tag tag2 = new Tag() { description = "Another description."}; + List items = new List() { tag1, tag2 }; + +#line default +#line hidden +#nullable disable + } +} +namespace __Blazor.Test.UseTestComponent +{ + #line hidden + 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() + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Item1", __arg0); + __builder.AddAttribute(__seq1, "Items2", __arg1); + __builder.AddAttribute(__seq2, "Item3", __arg2); + __builder.AddAttribute(__seq3, "ChildContent", __arg3); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.ir.txt new file mode 100644 index 000000000000..af6324ae5177 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.ir.txt @@ -0,0 +1,44 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + UsingDirective - (1:0,1 [10] x:\dir\subdir\Test\UseTestComponent.cshtml) - Test + ClassDeclaration - - public partial - UseTestComponent - 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\UseTestComponent.cshtml) + LazyIntermediateToken - (11:0,11 [2] x:\dir\subdir\Test\UseTestComponent.cshtml) - Html - \n + Component - (13:1,0 [94] x:\dir\subdir\Test\UseTestComponent.cshtml) - TestComponent + ComponentChildContent - - ChildContent - context + HtmlContent - (68:1,55 [6] x:\dir\subdir\Test\UseTestComponent.cshtml) + LazyIntermediateToken - (68:1,55 [6] x:\dir\subdir\Test\UseTestComponent.cshtml) - Html - \n + MarkupElement - (74:2,4 [15] x:\dir\subdir\Test\UseTestComponent.cshtml) - p + CSharpExpression - (78:2,8 [7] x:\dir\subdir\Test\UseTestComponent.cshtml) + LazyIntermediateToken - (78:2,8 [7] x:\dir\subdir\Test\UseTestComponent.cshtml) - CSharp - context + HtmlContent - (89:2,19 [2] x:\dir\subdir\Test\UseTestComponent.cshtml) + LazyIntermediateToken - (89:2,19 [2] x:\dir\subdir\Test\UseTestComponent.cshtml) - Html - \n + ComponentAttribute - (34:1,21 [6] x:\dir\subdir\Test\UseTestComponent.cshtml) - Item1 - Item1 - AttributeStructure.DoubleQuotes + CSharpExpression - (35:1,22 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) + LazyIntermediateToken - (35:1,22 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) - CSharp - item1 + ComponentAttribute - (48:1,35 [6] x:\dir\subdir\Test\UseTestComponent.cshtml) - Items2 - Items2 - AttributeStructure.DoubleQuotes + CSharpExpression - (49:1,36 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) + LazyIntermediateToken - (49:1,36 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) - CSharp - items + ComponentAttribute - (61:1,48 [6] x:\dir\subdir\Test\UseTestComponent.cshtml) - Item3 - Item3 - AttributeStructure.DoubleQuotes + CSharpExpression - (62:1,49 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) + LazyIntermediateToken - (62:1,49 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) - CSharp - item1 + HtmlContent - (107:3,16 [4] x:\dir\subdir\Test\UseTestComponent.cshtml) + LazyIntermediateToken - (107:3,16 [4] x:\dir\subdir\Test\UseTestComponent.cshtml) - Html - \n\n + CSharpCode - (118:5,7 [268] x:\dir\subdir\Test\UseTestComponent.cshtml) + LazyIntermediateToken - (118:5,7 [268] x:\dir\subdir\Test\UseTestComponent.cshtml) - CSharp - \n Image item1 = new Image() { id = 1, url="https://example.com"};\n static Tag tag1 = new Tag() { description = "A description."};\n static Tag tag2 = new Tag() { description = "Another description."};\n List items = new List() { tag1, tag2 };\n + NamespaceDeclaration - - __Blazor.Test.UseTestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.UseTestComponent.TypeInference - CreateTestComponent_0 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.mappings.txt new file mode 100644 index 000000000000..20606d66d09c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.mappings.txt @@ -0,0 +1,40 @@ +Source Location: (1:0,1 [10] x:\dir\subdir\Test\UseTestComponent.cshtml) +|using Test| +Generated Location: (323:12,0 [10] ) +|using Test| + +Source Location: (35:1,22 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) +|item1| +Generated Location: (1116:32,22 [5] ) +|item1| + +Source Location: (49:1,36 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) +|items| +Generated Location: (1302:40,36 [5] ) +|items| + +Source Location: (62:1,49 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) +|item1| +Generated Location: (1501:48,49 [5] ) +|item1| + +Source Location: (78:2,8 [7] x:\dir\subdir\Test\UseTestComponent.cshtml) +|context| +Generated Location: (1689:56,8 [7] ) +|context| + +Source Location: (118:5,7 [268] x:\dir\subdir\Test\UseTestComponent.cshtml) +| + Image item1 = new Image() { id = 1, url="https://example.com"}; + static Tag tag1 = new Tag() { description = "A description."}; + static Tag tag2 = new Tag() { description = "Another description."}; + List items = new List() { tag1, tag2 }; +| +Generated Location: (2066:74,7 [268] ) +| + Image item1 = new Image() { id = 1, url="https://example.com"}; + static Tag tag1 = new Tag() { description = "A description."}; + static Tag tag2 = new Tag() { description = "Another description."}; + List items = new List() { tag1, tag2 }; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.codegen.cs new file mode 100644 index 000000000000..9c30eb232cc8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/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; +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +using Microsoft.AspNetCore.Components; + +#line default +#line hidden +#nullable disable + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object TItem1 = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object TItem2 = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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) + { +#nullable restore +#line 5 "x:\dir\subdir\Test\TestComponent.cshtml" +foreach (var item2 in Items2) +{ + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = ChildContent(item2); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "x:\dir\subdir\Test\TestComponent.cshtml" + +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 12 "x:\dir\subdir\Test\TestComponent.cshtml" + + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.ir.txt new file mode 100644 index 000000000000..fd3f0df97949 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.ir.txt @@ -0,0 +1,42 @@ +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 - (1:0,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - - TItem1, TItem2 + DesignTimeDirective - + DirectiveToken - (52:1,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem1 + DirectiveToken - (71:2,10 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem2 + 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 - (39:0,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (39:0,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (79:2,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (79:2,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (81:3,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (85:4,2 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (85:4,2 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Item1 + HtmlContent - (95:4,12 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (95:4,12 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (98:4,15 [38] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (98:4,15 [38] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - foreach (var item2 in Items2)\n{\n + MarkupElement - (136:7,2 [40] x:\dir\subdir\Test\TestComponent.cshtml) - p + HtmlContent - (139:7,5 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (139:7,5 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (146:8,3 [19] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (146:8,3 [19] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ChildContent(item2) + HtmlContent - (165:8,22 [7] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (165:8,22 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n + CSharpCode - (176:9,6 [3] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (176:9,6 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n} + HtmlContent - (179:9,9 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (179:9,9 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (188:11,5 [185] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (188:11,5 [185] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n [Parameter] public TItem1 Item1 { get; set; }\n [Parameter] public List Items2 { get; set; }\n [Parameter] public RenderFragment ChildContent { get; set; }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.mappings.txt new file mode 100644 index 000000000000..cd4e95edbafb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.mappings.txt @@ -0,0 +1,48 @@ +Source Location: (1:0,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) +|using Microsoft.AspNetCore.Components;| +Generated Location: (276:11,0 [38] ) +|using Microsoft.AspNetCore.Components;| + +Source Location: (52:1,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|TItem1| +Generated Location: (697:23,22 [6] ) +|TItem1| + +Source Location: (71:2,10 [6] x:\dir\subdir\Test\TestComponent.cshtml) +| TItem| +Generated Location: (916:33,22 [6] ) +|TItem2| + +Source Location: (98:4,15 [38] x:\dir\subdir\Test\TestComponent.cshtml) +| +@foreach (var item2 in Items2) +{ + | +Generated Location: (1422:50,0 [38] ) +|foreach (var item2 in Items2) +{ + | + +Source Location: (146:8,3 [19] x:\dir\subdir\Test\TestComponent.cshtml) +| @ChildContent(item| +Generated Location: (1588:59,6 [19] ) +|ChildContent(item2)| + +Source Location: (176:9,6 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|p> | +Generated Location: (1737:66,6 [3] ) +| +}| + +Source Location: (188:11,5 [185] x:\dir\subdir\Test\TestComponent.cshtml) +| { + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; }| +Generated Location: (1917:76,5 [185] ) +| + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.codegen.cs new file mode 100644 index 000000000000..3a5d8e534f50 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.codegen.cs @@ -0,0 +1,67 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +using Microsoft.AspNetCore.Components; + +#line default +#line hidden +#nullable disable + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + where TItem1 : Image + where TItem2 : ITag + where TItem3 : Image, new() + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.AddMarkupContent(0, "

Item1

"); +#nullable restore +#line 6 "x:\dir\subdir\Test\TestComponent.cshtml" + foreach (var item2 in Items2) +{ + +#line default +#line hidden +#nullable disable + __builder.OpenElement(1, "p"); +#nullable restore +#line (10,3)-(10,22) 24 "x:\dir\subdir\Test\TestComponent.cshtml" +__builder.AddContent(2, ChildContent(item2)); + +#line default +#line hidden +#nullable disable + __builder.AddMarkupContent(3, ";\r\n "); + __builder.CloseElement(); +#nullable restore +#line 11 "x:\dir\subdir\Test\TestComponent.cshtml" + } + +#line default +#line hidden +#nullable disable + __builder.AddMarkupContent(4, "

Item3

"); + } + #pragma warning restore 1998 +#nullable restore +#line 16 "x:\dir\subdir\Test\TestComponent.cshtml" + + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public TItem3 Item3 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.ir.txt new file mode 100644 index 000000000000..12ef44b89439 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (1:0,1 [40] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - - TItem1, TItem2, TItem3 + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupBlock - -

Item1

+ CSharpCode - (186:5,14 [34] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (186:5,14 [34] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - foreach (var item2 in Items2)\n{\n + MarkupElement - (224:8,1 [40] x:\dir\subdir\Test\TestComponent.cshtml) - p + CSharpExpression - (234:9,2 [19] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (234:9,2 [19] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ChildContent(item2) + HtmlContent - (253:9,21 [7] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (253:9,21 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n + CSharpCode - (266:10,7 [3] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (266:10,7 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - }\n + MarkupBlock - -

Item3

+ CSharpCode - (294:15,4 [236] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (294:15,4 [236] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n [Parameter] public TItem1 Item1 { get; set; }\n [Parameter] public List Items2 { get; set; }\n [Parameter] public TItem3 Item3 { get; set; }\n [Parameter] public RenderFragment ChildContent { get; set; }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.mappings.txt new file mode 100644 index 000000000000..d94a7a379412 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/TestComponent.mappings.txt @@ -0,0 +1,30 @@ +Source Location: (186:5,14 [34] x:\dir\subdir\Test\TestComponent.cshtml) +| +@foreach (var item2 in Items2) +| +Generated Location: (884:27,14 [34] ) +|foreach (var item2 in Items2) +{ +| + +Source Location: (266:10,7 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|> +| +Generated Location: (1369:47,7 [3] ) +|} +| + +Source Location: (294:15,4 [236] x:\dir\subdir\Test\TestComponent.cshtml) +|e { + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public TItem3 Item3 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; | +Generated Location: (1606:57,4 [236] ) +| + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public TItem3 Item3 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs new file mode 100644 index 000000000000..259762e28014 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.codegen.cs @@ -0,0 +1,93 @@ +// +#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\UseTestComponent.cshtml" +using Test; + +#line default +#line hidden +#nullable disable + public partial class UseTestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __Blazor.Test.UseTestComponent.TypeInference.CreateTestComponent_0(__builder, 0, 1, +#nullable restore +#line 2 "x:\dir\subdir\Test\UseTestComponent.cshtml" + item1 + +#line default +#line hidden +#nullable disable + , 2, +#nullable restore +#line 2 "x:\dir\subdir\Test\UseTestComponent.cshtml" + items + +#line default +#line hidden +#nullable disable + , 3, +#nullable restore +#line 2 "x:\dir\subdir\Test\UseTestComponent.cshtml" + item1 + +#line default +#line hidden +#nullable disable + , 4, (context) => (__builder2) => { + __builder2.OpenElement(5, "p"); +#nullable restore +#line (3,9)-(3,16) 25 "x:\dir\subdir\Test\UseTestComponent.cshtml" +__builder2.AddContent(6, context); + +#line default +#line hidden +#nullable disable + __builder2.CloseElement(); + } + ); + } + #pragma warning restore 1998 +#nullable restore +#line 6 "x:\dir\subdir\Test\UseTestComponent.cshtml" + + Image item1 = new Image() { id = 1, url="https://example.com"}; + static Tag tag1 = new Tag() { description = "A description."}; + static Tag tag2 = new Tag() { description = "Another description."}; + List items = new List() { tag1, tag2 }; + +#line default +#line hidden +#nullable disable + } +} +namespace __Blazor.Test.UseTestComponent +{ + #line hidden + 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() + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Item1", __arg0); + __builder.AddAttribute(__seq1, "Items2", __arg1); + __builder.AddAttribute(__seq2, "Item3", __arg2); + __builder.AddAttribute(__seq3, "ChildContent", __arg3); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.ir.txt new file mode 100644 index 000000000000..dd6dfbb8cb58 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.ir.txt @@ -0,0 +1,29 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + UsingDirective - (1:0,1 [12] x:\dir\subdir\Test\UseTestComponent.cshtml) - Test + ClassDeclaration - - public partial - UseTestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (13:1,0 [94] x:\dir\subdir\Test\UseTestComponent.cshtml) - TestComponent + ComponentChildContent - - ChildContent - context + MarkupElement - (74:2,4 [15] x:\dir\subdir\Test\UseTestComponent.cshtml) - p + CSharpExpression - (78:2,8 [7] x:\dir\subdir\Test\UseTestComponent.cshtml) + LazyIntermediateToken - (78:2,8 [7] x:\dir\subdir\Test\UseTestComponent.cshtml) - CSharp - context + ComponentAttribute - (34:1,21 [6] x:\dir\subdir\Test\UseTestComponent.cshtml) - Item1 - Item1 - AttributeStructure.DoubleQuotes + CSharpExpression - (35:1,22 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) + LazyIntermediateToken - (35:1,22 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) - CSharp - item1 + ComponentAttribute - (48:1,35 [6] x:\dir\subdir\Test\UseTestComponent.cshtml) - Items2 - Items2 - AttributeStructure.DoubleQuotes + CSharpExpression - (49:1,36 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) + LazyIntermediateToken - (49:1,36 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) - CSharp - items + ComponentAttribute - (61:1,48 [6] x:\dir\subdir\Test\UseTestComponent.cshtml) - Item3 - Item3 - AttributeStructure.DoubleQuotes + CSharpExpression - (62:1,49 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) + LazyIntermediateToken - (62:1,49 [5] x:\dir\subdir\Test\UseTestComponent.cshtml) - CSharp - item1 + CSharpCode - (118:5,7 [268] x:\dir\subdir\Test\UseTestComponent.cshtml) + LazyIntermediateToken - (118:5,7 [268] x:\dir\subdir\Test\UseTestComponent.cshtml) - CSharp - \n Image item1 = new Image() { id = 1, url="https://example.com"};\n static Tag tag1 = new Tag() { description = "A description."};\n static Tag tag2 = new Tag() { description = "Another description."};\n List items = new List() { tag1, tag2 };\n + NamespaceDeclaration - - __Blazor.Test.UseTestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.UseTestComponent.TypeInference - CreateTestComponent_0 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.mappings.txt new file mode 100644 index 000000000000..a9182f5dc7fd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters_WithSemicolon/UseTestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (118:5,7 [268] x:\dir\subdir\Test\UseTestComponent.cshtml) +| + Image item1 = new Image() { id = 1, url="https://example.com"}; + static Tag tag1 = new Tag() { description = "A description."}; + static Tag tag2 = new Tag() { description = "Another description."}; + List items = new List() { tag1, tag2 }; +| +Generated Location: (1761:62,7 [268] ) +| + Image item1 = new Image() { id = 1, url="https://example.com"}; + static Tag tag1 = new Tag() { description = "A description."}; + static Tag tag2 = new Tag() { description = "Another description."}; + List items = new List() { tag1, tag2 }; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.codegen.cs new file mode 100644 index 000000000000..40f98f59c55b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.codegen.cs @@ -0,0 +1,62 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +using Microsoft.AspNetCore.Components; + +#line default +#line hidden +#nullable disable + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.AddMarkupContent(0, "

Item1

"); +#nullable restore +#line 5 "x:\dir\subdir\Test\TestComponent.cshtml" +foreach (var item2 in Items2) +{ + +#line default +#line hidden +#nullable disable + __builder.OpenElement(1, "p"); +#nullable restore +#line (9,4)-(9,23) 24 "x:\dir\subdir\Test\TestComponent.cshtml" +__builder.AddContent(2, ChildContent(item2)); + +#line default +#line hidden +#nullable disable + __builder.AddMarkupContent(3, ";\r\n "); + __builder.CloseElement(); +#nullable restore +#line 10 "x:\dir\subdir\Test\TestComponent.cshtml" + } + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 12 "x:\dir\subdir\Test\TestComponent.cshtml" + + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.ir.txt new file mode 100644 index 000000000000..29fd29967cdb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.ir.txt @@ -0,0 +1,21 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (1:0,1 [40] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - - TItem1, TItem2 + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupBlock - -

Item1

+ CSharpCode - (98:4,15 [34] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (98:4,15 [34] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - foreach (var item2 in Items2)\n{\n + MarkupElement - (136:7,2 [40] x:\dir\subdir\Test\TestComponent.cshtml) - p + CSharpExpression - (146:8,3 [19] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (146:8,3 [19] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ChildContent(item2) + HtmlContent - (165:8,22 [7] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (165:8,22 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n + CSharpCode - (178:9,8 [3] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (178:9,8 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - }\n + CSharpCode - (188:11,5 [185] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (188:11,5 [185] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n [Parameter] public TItem1 Item1 { get; set; }\n [Parameter] public List Items2 { get; set; }\n [Parameter] public RenderFragment ChildContent { get; set; }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.mappings.txt new file mode 100644 index 000000000000..a6046b1f4339 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters_WithSemicolon/TestComponent.mappings.txt @@ -0,0 +1,28 @@ +Source Location: (98:4,15 [34] x:\dir\subdir\Test\TestComponent.cshtml) +| +@foreach (var item2 in Items2) +{| +Generated Location: (778:24,0 [34] ) +|foreach (var item2 in Items2) +{ +| + +Source Location: (178:9,8 [3] x:\dir\subdir\Test\TestComponent.cshtml) +| +}| +Generated Location: (1262:44,8 [3] ) +|} +| + +Source Location: (188:11,5 [185] x:\dir\subdir\Test\TestComponent.cshtml) +| { + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; }| +Generated Location: (1440:53,5 [185] ) +| + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } +| +