Mark empty outer tags as errors when context switching from C# to markup (RZ1022)#12811
Mark empty outer tags as errors when context switching from C# to markup (RZ1022)#12811
Conversation
…kup (RZ1022) Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
|
@copilot please investigate the test failures. |
| { | ||
| // The outer tag of a markup block is missing a name. | ||
| Context.ErrorSink.OnError( | ||
| RazorDiagnosticFactory.CreateParsing_OuterTagMissingName( |
There was a problem hiding this comment.
I checked and this method has no callers, before this PR. The diagnostic is never used 🤷♂️
Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
The failure was in the legacy test project ( Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
| @@ -0,0 +1 @@ | |||
| (1,3): Error RZ1022: Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. | |||
There was a problem hiding this comment.
This is introducing a new diagnostic into an existing test, that looks like this:
That doesn't seem like an issue to me, but feel free to disagree.
chsienki
left a comment
There was a problem hiding this comment.
While I agree that this is the right fix, it's a breaking change. Sure, the code might have errored at runtime, but it did compile and if that code path was never executed it wouldn't have been an issue.
I don't think we can take this until we have warning waves (sigh)
You're right :( |
Summary of the changes
@<>...</>used as a markup template transition compiles silently but throws a runtimeInvalidCharacterErrorbecause<>is not a valid HTML element name. The parser already hadRZ1022("Outer tag is missing a name") defined but never emitted it.HtmlMarkupParser.ParseStartTag: EmitRZ1022when the outermost tag of aMarkupInCodeBlockcontext has an empty name and is immediately closed (<>). TheAt(SyntaxKind.CloseAngle)guard ensures this only fires for<>and not for<at EOF,<with trailing whitespace, or< expr>patterns.HtmlErrorTest: Two new tests covering@{<>foo</>}and@Html.Repeat(10, @<>Foo #@item</>)..diag.txtbaselines for the new tests in bothtest/TestFiles/andlegacyTest/TestFiles/; existingHtmlTagsTest.EmptyTag(@{<></> Bar}) in both test projects now correctly capturesRZ1022.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.