Skip to content
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
merged 5 commits into from
Sep 23, 2024

Conversation

chsienki
Copy link
Contributor

Fixes #10863

Previously we didn't emit the page directive if it had an error. Now we do, so the user still gets syntax highlighting etc.

@@ -5550,6 +5550,37 @@ @inherits BaseComponent<string?>
]);
}

[IntegrationTestFact]
Copy link
Member

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

{
// Act
var generated = CompileToCSharp(@"
@page ""MyPage""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: consider using raw strings to avoid duplicate quotes

@@ -59,15 +59,16 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte
var pageDirective = (DirectiveIntermediateNode)directives[i].Node;

// The parser also adds errors for invalid syntax, we just need to not crash.
var routeToken = pageDirective.Tokens.FirstOrDefault();
var routeToken = pageDirective.Tokens.First();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change FirstOrDefault -> First? Is it guaranteed pageDirective.Tokens won't be empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we won't ever actually encounter a page directive without tokens, because the way it parses goes down a different path. I added the PageDirective_MissingRoute test to show that behavior.

@chsienki chsienki force-pushed the fuse_incorrect_page_directives branch from 1309db8 to 38e7f8b Compare September 20, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FUSE] Invalid @page directives don't get any code-gen
5 participants