diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.codegen.cs index 11f7ea0e42a..56ff2b982d8 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.codegen.cs @@ -28,7 +28,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line default #line hidden #nullable disable - , -1, global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + , -1, global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => Selected = __value, Selected)), -1, () => Selected); #pragma warning disable BL0005 __typeInference_CreateMyComponent_0. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.mappings.txt index 5c7283fcb89..830a29a9326 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.mappings.txt @@ -5,14 +5,14 @@ Generated Location: (1072:25,26 [8] ) Source Location: (19:0,19 [5] x:\dir\subdir\Test\TestComponent.cshtml) |Value| -Generated Location: (1610:36,19 [5] ) +Generated Location: (1593:36,19 [5] ) |Value| Source Location: (49:2,7 [64] x:\dir\subdir\Test\TestComponent.cshtml) | string[] Selected { get; set; } = Array.Empty(); | -Generated Location: (2025:54,7 [64] ) +Generated Location: (2008:54,7 [64] ) | string[] Selected { get; set; } = Array.Empty(); | diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.codegen.cs index 22f0afaf175..992cb6f46cb 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.codegen.cs @@ -21,7 +21,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line default #line hidden #nullable disable - , 2, global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => Selected = __value, Selected)), 3, () => Selected); + , 2, global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => Selected = __value, Selected)), 3, () => Selected); } #pragma warning restore 1998 #nullable restore diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.mappings.txt index ffce2a45913..7945fa15918 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventCallbackOfT_Array/TestComponent.mappings.txt @@ -2,7 +2,7 @@ | string[] Selected { get; set; } = Array.Empty(); | -Generated Location: (1232:28,7 [64] ) +Generated Location: (1215:28,7 [64] ) | string[] Selected { get; set; } = Array.Empty(); | diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor/src/DefaultTypeNameFeature.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor/src/DefaultTypeNameFeature.cs index b96cb15aa68..5e8bad1f561 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor/src/DefaultTypeNameFeature.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor/src/DefaultTypeNameFeature.cs @@ -22,24 +22,45 @@ public override IReadOnlyList ParseTypeParameters(string typeName) } var parsed = SyntaxFactory.ParseTypeName(typeName); + if (parsed is IdentifierNameSyntax identifier) { return Array.Empty(); } - else if (parsed is ArrayTypeSyntax array) + + if (TryParseCore(parsed) is { } list) { - return new[] { array.ElementType.ToString() }; + return list; } - else if (parsed is TupleTypeSyntax tuple) + + return parsed.DescendantNodesAndSelf() + .OfType() + .SelectMany(arg => arg.Arguments) + .SelectMany(ParseCore).ToArray(); + + static IReadOnlyList TryParseCore(TypeSyntax parsed) { - return tuple.Elements.Select(a => a.ToString()).ToList(); + if (parsed is ArrayTypeSyntax array) + { + return new[] { array.ElementType.ToString() }; + } + + if (parsed is TupleTypeSyntax tuple) + { + return tuple.Elements.Select(a => a.ToString()).ToList(); + } + + return null; } - else + + static IReadOnlyList ParseCore(TypeSyntax parsed) { - return parsed.DescendantNodesAndSelf() - .OfType() - .SelectMany(arg => arg.Arguments) - .Select(a => a.ToString()).ToList(); + if (TryParseCore(parsed) is { } list) + { + return list; + } + + return new[] { parsed.ToString() }; } }