-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fuse incorrect page directives #10907
Merged
chsienki
merged 5 commits into
dotnet:main
from
chsienki:fuse_incorrect_page_directives
Sep 23, 2024
+483
−5
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5550,6 +5550,37 @@ @inherits BaseComponent<string?> | |
]); | ||
} | ||
|
||
[IntegrationTestFact] | ||
public void PageDirective_NoForwardSlash() | ||
{ | ||
// Act | ||
var generated = CompileToCSharp(@" | ||
@page ""MyPage"" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: consider using raw strings to avoid duplicate quotes |
||
"); | ||
|
||
// Assert | ||
AssertDocumentNodeMatchesBaseline(generated.CodeDocument); | ||
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); | ||
CompileToAssembly(generated); | ||
} | ||
|
||
[IntegrationTestFact] | ||
public void PageDirective_MissingRoute() | ||
{ | ||
// Act | ||
var generated = CompileToCSharp(@" | ||
@page | ||
"); | ||
|
||
// Assert | ||
AssertDocumentNodeMatchesBaseline(generated.CodeDocument); | ||
|
||
// Design time writer doesn't correctly emit pragmas for missing tokens, so don't validate them in design time | ||
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument, verifyLinePragmas: !DesignTime); | ||
CompileToAssembly(generated); | ||
} | ||
|
||
|
||
#endregion | ||
|
||
#region EventCallback | ||
|
32 changes: 32 additions & 0 deletions
32
...ComponentDesignTimeCodeGenerationTest/PageDirective_MissingRoute/TestComponent.codegen.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// <auto-generated/> | ||
#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 | ||
#nullable restore | ||
public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase | ||
#nullable disable | ||
{ | ||
#pragma warning disable 219 | ||
private void __RazorDirectiveTokenHelpers__() { | ||
} | ||
#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 |
1 change: 1 addition & 0 deletions
1
...nentDesignTimeCodeGenerationTest/PageDirective_MissingRoute/TestComponent.diagnostics.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
x:\dir\subdir\Test\TestComponent.cshtml(1,6): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. |
21 changes: 21 additions & 0 deletions
21
...sts/ComponentDesignTimeCodeGenerationTest/PageDirective_MissingRoute/TestComponent.ir.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
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 | ||
ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - | ||
DesignTimeDirective - | ||
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 | ||
MalformedDirective - (0:0,0 [5] x:\dir\subdir\Test\TestComponent.cshtml) - page | ||
CSharpCode - (5:0,5 [0] x:\dir\subdir\Test\TestComponent.cshtml) | ||
LazyIntermediateToken - (5:0,5 [0] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - | ||
HtmlContent - (5:0,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) | ||
LazyIntermediateToken - (5:0,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n |
5 changes: 5 additions & 0 deletions
5
...mponentDesignTimeCodeGenerationTest/PageDirective_MissingRoute/TestComponent.mappings.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Source Location: (5:0,5 [0] x:\dir\subdir\Test\TestComponent.cshtml) | ||
|| | ||
Generated Location: (920:26,5 [0] ) | ||
|| | ||
|
42 changes: 42 additions & 0 deletions
42
...mponentDesignTimeCodeGenerationTest/PageDirective_NoForwardSlash/TestComponent.codegen.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// <auto-generated/> | ||
#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 | ||
#nullable restore | ||
public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase | ||
#nullable disable | ||
{ | ||
#pragma warning disable 219 | ||
private void __RazorDirectiveTokenHelpers__() { | ||
((global::System.Action)(() => { | ||
// language=Route,Component | ||
#nullable restore | ||
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" | ||
global::System.Object __typeHelper = "MyPage"; | ||
|
||
#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 |
1 change: 1 addition & 0 deletions
1
...ntDesignTimeCodeGenerationTest/PageDirective_NoForwardSlash/TestComponent.diagnostics.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
x:\dir\subdir\Test\TestComponent.cshtml(1,1): Error RZ9988: The @page directive must specify a route template. The route template must be enclosed in quotes and begin with the '/' character. |
17 changes: 17 additions & 0 deletions
17
...s/ComponentDesignTimeCodeGenerationTest/PageDirective_NoForwardSlash/TestComponent.ir.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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 | ||
ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - | ||
DesignTimeDirective - | ||
DirectiveToken - (6:0,6 [8] x:\dir\subdir\Test\TestComponent.cshtml) - "MyPage" | ||
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 |
5 changes: 5 additions & 0 deletions
5
...onentDesignTimeCodeGenerationTest/PageDirective_NoForwardSlash/TestComponent.mappings.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Source Location: (6:0,6 [8] x:\dir\subdir\Test\TestComponent.cshtml) | ||
|"MyPage"| | ||
Generated Location: (749:22,37 [8] ) | ||
|"MyPage"| | ||
|
24 changes: 24 additions & 0 deletions
24
...ts/ComponentRuntimeCodeGenerationTest/PageDirective_MissingRoute/TestComponent.codegen.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// <auto-generated/> | ||
#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 | ||
#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 |
1 change: 1 addition & 0 deletions
1
...mponentRuntimeCodeGenerationTest/PageDirective_MissingRoute/TestComponent.diagnostics.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
x:\dir\subdir\Test\TestComponent.cshtml(1,6): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. |
12 changes: 12 additions & 0 deletions
12
...nTests/ComponentRuntimeCodeGenerationTest/PageDirective_MissingRoute/TestComponent.ir.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Document - | ||
NamespaceDeclaration - - Test | ||
UsingDirective - (3:1,1 [22] ) - global::System | ||
UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic | ||
UsingDirective - (69:3,1 [27] ) - global::System.Linq | ||
UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks | ||
UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components | ||
ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - | ||
MethodDeclaration - - protected override - void - BuildRenderTree | ||
MalformedDirective - (0:0,0 [5] x:\dir\subdir\Test\TestComponent.cshtml) - page | ||
CSharpCode - (5:0,5 [0] x:\dir\subdir\Test\TestComponent.cshtml) | ||
LazyIntermediateToken - (5:0,5 [0] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - |
24 changes: 24 additions & 0 deletions
24
.../ComponentRuntimeCodeGenerationTest/PageDirective_NoForwardSlash/TestComponent.codegen.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// <auto-generated/> | ||
#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 | ||
#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 |
1 change: 1 addition & 0 deletions
1
...onentRuntimeCodeGenerationTest/PageDirective_NoForwardSlash/TestComponent.diagnostics.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
x:\dir\subdir\Test\TestComponent.cshtml(1,1): Error RZ9988: The @page directive must specify a route template. The route template must be enclosed in quotes and begin with the '/' character. |
9 changes: 9 additions & 0 deletions
9
...ests/ComponentRuntimeCodeGenerationTest/PageDirective_NoForwardSlash/TestComponent.ir.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Document - | ||
NamespaceDeclaration - - Test | ||
UsingDirective - (3:1,1 [22] ) - global::System | ||
UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic | ||
UsingDirective - (69:3,1 [27] ) - global::System.Linq | ||
UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks | ||
UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components | ||
ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - | ||
MethodDeclaration - - protected override - void - BuildRenderTree |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: consider adding WorkItem attribute to the new tests