-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Handle razor @:
transitions as comments
#72745
Conversation
In Razor, `@:` represents an unconditional transition to HTML for the rest of a given line. In order to handle this gracefully when using the C# lexer in Razor, we'll take the same approach we did for `@* *@` comments, except this time treating it as if it was a `//` comment.
@dotnet/roslyn-compiler @CyrusNajmabadi for review. |
src/Compilers/CSharp/Test/Syntax/LexicalAndXml/LexicalErrorTests.cs
Outdated
Show resolved
Hide resolved
@dotnet/roslyn-compiler for a second review. |
public void CS1035AtColonParsedAsComment_02() | ||
{ | ||
var test = """ | ||
@:<div>test</div> |
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.
Today in Razor you can "spill" this markup transition over multiple lines via something like this:
@:@{<strong>
I'm evil
</strong>}
Will that still work with the single-line comment lexing?
(I think we don't have to support that as it's not useful except for some hacks like dotnet/razor#7681 (comment).)
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.
It will "work" in that the first line will entirely be processed as a comment, and the next line will be treated as an identifier. We'll have to have tests for this and handle it carefully on the razor side.
In Razor,
@:
represents an unconditional transition to HTML for the rest of a given line. In order to handle this gracefully when using the C# lexer in Razor, we'll take the same approach we did for@* *@
comments, except this time treating it as if it was a//
comment.