From 234a73871838bd3c3cbc622805e6e83930390e10 Mon Sep 17 00:00:00 2001 From: Chris Sienkiewicz Date: Thu, 27 Feb 2025 12:19:41 -0800 Subject: [PATCH 1/4] Add layout test --- .../ComponentCodeGenerationTestBase.cs | 14 +++++++ .../LayoutDirective/TestComponent.codegen.cs | 42 +++++++++++++++++++ .../LayoutDirective/TestComponent.ir.txt | 19 +++++++++ .../TestComponent.mappings.txt | 5 +++ .../LayoutDirective/TestComponent.codegen.cs | 25 +++++++++++ .../LayoutDirective/TestComponent.ir.txt | 11 +++++ 6 files changed, 116 insertions(+) create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.codegen.cs create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.mappings.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.codegen.cs create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index 15a06d45518..42e722253d5 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -2360,6 +2360,20 @@ public void ExplicitExpression_Whitespace() CompileToAssembly(generated); } + [IntegrationTestFact] + public void LayoutDirective() + { + // Act + var generated = CompileToCSharp(""" + @layout System.Object + """); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + #endregion #region Bind diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.codegen.cs new file mode 100644 index 00000000000..a50d6e2584f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof(System.Object))] + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((global::System.Action)(() => { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +System.Object __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt new file mode 100644 index 00000000000..97b651a3ae4 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + CSharpCode - + IntermediateToken - - CSharp - [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof(System.Object))] + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (8:0,8 [13] x:\dir\subdir\Test\TestComponent.cshtml) - System.Object + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.mappings.txt new file mode 100644 index 00000000000..bf81c0ccb3b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (8:0,8 [13] x:\dir\subdir\Test\TestComponent.cshtml) +|System.Object| +Generated Location: (769:22,0 [13] ) +|System.Object| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.codegen.cs new file mode 100644 index 00000000000..ffb193d6ba7 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.codegen.cs @@ -0,0 +1,25 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line default + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.AspNetCore.Components; + #line default + #line hidden + [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof(System.Object))] + #nullable restore + public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase + #nullable disable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt new file mode 100644 index 00000000000..449287823e7 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt @@ -0,0 +1,11 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [20] ) - global::System + UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic + UsingDirective - (69:3,1 [25] ) - global::System.Linq + UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks + UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components + CSharpCode - + IntermediateToken - - CSharp - [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof(System.Object))] + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree From 9ae72613027b08afd372d85e894ad65bef615c28 Mon Sep 17 00:00:00 2001 From: Chris Sienkiewicz Date: Thu, 27 Feb 2025 12:24:31 -0800 Subject: [PATCH 2/4] Emit source location for runtime --- .../Components/ComponentLayoutDirectivePass.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentLayoutDirectivePass.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentLayoutDirectivePass.cs index 17fbf5da25e..f7502fdb335 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentLayoutDirectivePass.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentLayoutDirectivePass.cs @@ -33,11 +33,11 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte } var attributeNode = new CSharpCodeIntermediateNode(); - attributeNode.Children.Add(new IntermediateToken() - { - Kind = TokenKind.CSharp, - Content = $"[global::{ComponentsApi.LayoutAttribute.FullTypeName}(typeof({token.Content}))]", - }); + attributeNode.Children.AddRange([ + IntermediateToken.CreateCSharpToken($"[global::{ComponentsApi.LayoutAttribute.FullTypeName}(typeof("), + IntermediateToken.CreateCSharpToken(token.Content, documentNode.Options.DesignTime ? null : token.Source), + IntermediateToken.CreateCSharpToken("))]") + ]); // Insert the new attribute on top of the class for (var i = 0; i < @namespace.Children.Count; i++) From 92c80f6bbdd23a808291b219bd9ce2272d2f8a33 Mon Sep 17 00:00:00 2001 From: Chris Sienkiewicz Date: Thu, 27 Feb 2025 12:27:21 -0800 Subject: [PATCH 3/4] Update tests --- .../ComponentCodeGenerationTestBase.cs | 2 +- .../ComponentImports/_Imports.ir.txt | 4 +++- .../LayoutDirective/TestComponent.ir.txt | 4 +++- .../ComponentImports/_Imports.codegen.cs | 10 +++++++++- .../ComponentImports/_Imports.ir.txt | 4 +++- .../ComponentImports/_Imports.mappings.txt | 7 ++++++- .../LayoutDirective/TestComponent.codegen.cs | 10 +++++++++- .../LayoutDirective/TestComponent.ir.txt | 4 +++- .../LayoutDirective/TestComponent.mappings.txt | 5 +++++ 9 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.mappings.txt diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index 42e722253d5..c7e94957ef1 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -10582,7 +10582,7 @@ @layout MainLayout Diagnostic(ErrorCode.ERR_NameNotInContext, "Foo").WithArguments("Foo").WithLocation(5, 2), // (33,13): error CS0103: The name '__builder' does not exist in the current context // __builder.AddContent(0, - Diagnostic(ErrorCode.ERR_NameNotInContext, "__builder").WithArguments("__builder").WithLocation(33, 13)]); + Diagnostic(ErrorCode.ERR_NameNotInContext, "__builder").WithArguments("__builder").WithLocation(41, 13)]); } [IntegrationTestFact] diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentImports/_Imports.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentImports/_Imports.ir.txt index 9dc9919ee8b..811ace8bdba 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentImports/_Imports.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentImports/_Imports.ir.txt @@ -8,7 +8,9 @@ UsingDirective - (1:0,1 [17] x:\dir\subdir\Test\_Imports.razor) - System.Text UsingDirective - (21:1,1 [23] x:\dir\subdir\Test\_Imports.razor) - System.Reflection CSharpCode - - IntermediateToken - - CSharp - [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof(MainLayout))] + IntermediateToken - - CSharp - [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof( + IntermediateToken - - CSharp - MainLayout + IntermediateToken - - CSharp - ))] ClassDeclaration - - public partial - _Imports - object - DesignTimeDirective - DirectiveToken - (56:3,8 [10] x:\dir\subdir\Test\_Imports.razor) - MainLayout diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt index 97b651a3ae4..04aaa3d5d27 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt @@ -6,7 +6,9 @@ UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components CSharpCode - - IntermediateToken - - CSharp - [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof(System.Object))] + IntermediateToken - - CSharp - [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof( + IntermediateToken - - CSharp - System.Object + IntermediateToken - - CSharp - ))] ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - DesignTimeDirective - DirectiveToken - (8:0,8 [13] x:\dir\subdir\Test\TestComponent.cshtml) - System.Object diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentImports/_Imports.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentImports/_Imports.codegen.cs index f788ff6a26f..d8050e19d2b 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentImports/_Imports.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentImports/_Imports.codegen.cs @@ -22,7 +22,15 @@ namespace Test ; #line default #line hidden - [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof(MainLayout))] + [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof( +#nullable restore +#line (4,9)-(4,19) "x:\dir\subdir\Test\_Imports.razor" +MainLayout + +#line default +#line hidden +#nullable disable + ))] #nullable restore public partial class _Imports : object #nullable disable diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentImports/_Imports.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentImports/_Imports.ir.txt index 55f2c9c549c..406337a220b 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentImports/_Imports.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentImports/_Imports.ir.txt @@ -8,7 +8,9 @@ UsingDirective - (1:0,1 [17] x:\dir\subdir\Test\_Imports.razor) - System.Text UsingDirective - (21:1,1 [23] x:\dir\subdir\Test\_Imports.razor) - System.Reflection CSharpCode - - IntermediateToken - - CSharp - [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof(MainLayout))] + IntermediateToken - - CSharp - [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof( + IntermediateToken - (56:3,8 [10] x:\dir\subdir\Test\_Imports.razor) - CSharp - MainLayout + IntermediateToken - - CSharp - ))] ClassDeclaration - - public partial - _Imports - object - MethodDeclaration - - protected - void - Execute CSharpExpression - (69:4,1 [3] x:\dir\subdir\Test\_Imports.razor) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentImports/_Imports.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentImports/_Imports.mappings.txt index c7a05ab1cdd..fe048b04412 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentImports/_Imports.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentImports/_Imports.mappings.txt @@ -8,8 +8,13 @@ Source Location: (21:1,1 [23] x:\dir\subdir\Test\_Imports.razor) Generated Location: (488:18,0 [23] ) |using System.Reflection| +Source Location: (56:3,8 [10] x:\dir\subdir\Test\_Imports.razor) +|MainLayout| +Generated Location: (723:27,0 [10] ) +|MainLayout| + Source Location: (69:4,1 [3] x:\dir\subdir\Test\_Imports.razor) |Foo| -Generated Location: (953:35,0 [3] ) +Generated Location: (1086:43,0 [3] ) |Foo| diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.codegen.cs index ffb193d6ba7..fdb1ec92cee 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.codegen.cs @@ -10,7 +10,15 @@ namespace Test using global::Microsoft.AspNetCore.Components; #line default #line hidden - [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof(System.Object))] + [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof( +#nullable restore +#line (1,9)-(1,22) "x:\dir\subdir\Test\TestComponent.cshtml" +System.Object + +#line default +#line hidden +#nullable disable + ))] #nullable restore public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase #nullable disable diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt index 449287823e7..825e4c7d264 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.ir.txt @@ -6,6 +6,8 @@ UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components CSharpCode - - IntermediateToken - - CSharp - [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof(System.Object))] + IntermediateToken - - CSharp - [global::Microsoft.AspNetCore.Components.LayoutAttribute(typeof( + IntermediateToken - (8:0,8 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - System.Object + IntermediateToken - - CSharp - ))] ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.mappings.txt new file mode 100644 index 00000000000..14948124177 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LayoutDirective/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (8:0,8 [13] x:\dir\subdir\Test\TestComponent.cshtml) +|System.Object| +Generated Location: (479:15,0 [13] ) +|System.Object| + From aa5a605dc4b8e1e2496f517535724d3537a230d5 Mon Sep 17 00:00:00 2001 From: Chris Sienkiewicz Date: Fri, 28 Feb 2025 10:57:02 -0800 Subject: [PATCH 4/4] Update src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs Co-authored-by: Jan Jones --- .../test/IntegrationTests/ComponentCodeGenerationTestBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index c7e94957ef1..140a2444b1a 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -2360,7 +2360,7 @@ public void ExplicitExpression_Whitespace() CompileToAssembly(generated); } - [IntegrationTestFact] + [IntegrationTestFact, WorkItem("https://github.com/dotnet/razor/issues/11551")] public void LayoutDirective() { // Act