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

Handle razor @: transitions as comments #72745

Merged
merged 4 commits into from
Mar 29, 2024

Conversation

333fred
Copy link
Member

@333fred 333fred commented Mar 26, 2024

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.

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.
@333fred 333fred requested a review from a team as a code owner March 26, 2024 21:44
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 26, 2024
@333fred
Copy link
Member Author

333fred commented Mar 26, 2024

@dotnet/roslyn-compiler @CyrusNajmabadi for review.

@333fred
Copy link
Member Author

333fred commented Mar 27, 2024

@dotnet/roslyn-compiler for a second review.

public void CS1035AtColonParsedAsComment_02()
{
var test = """
@:<div>test</div>
Copy link
Contributor

@jjonescz jjonescz Mar 28, 2024

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).)

Copy link
Member Author

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.

@333fred 333fred merged commit 696b3e0 into dotnet:main Mar 29, 2024
24 checks passed
@333fred 333fred deleted the razor-comments-part-2 branch March 29, 2024 16:58
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Mar 29, 2024
@dibarbet dibarbet modified the milestones: Next, 17.11 P1 Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants