-
Notifications
You must be signed in to change notification settings - Fork 196
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
Unify handling of the @
character in razor code blocks
#10232
Merged
Merged
Conversation
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
…tics reported by the C# compiler. At some point, we should consider doing the same for Razor diagnostics, but that can be done as a future step.
…ffect parsing recovery.
We were not consistently handling recovery after seeing `@` signs in code blocks, which meant that there were all sorts of interesting scenarios where an escaped C# identifier would cause odd error recovery. There are a few edge cases that are now compile errors, but this is a more consistent overall experience. Fixes dotnet#10186 as well.
@dotnet/razor-compiler modulo some possible test failures that I haven't seen outside the compiler layer yet, I believe this should be ready for review. Please give it a look. |
333fred
commented
Apr 6, 2024
src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Semantic/SemanticTokensTest.cs
Outdated
Show resolved
Hide resolved
chsienki
approved these changes
Apr 6, 2024
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.
Love it. LGTM.
...Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
Outdated
Show resolved
Hide resolved
chsienki
reviewed
Apr 6, 2024
...Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
Outdated
Show resolved
Hide resolved
jjonescz
reviewed
Apr 8, 2024
...Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
Outdated
Show resolved
Hide resolved
src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/CSharpCodeParser.cs
Outdated
Show resolved
Hide resolved
...iles/ParserTests/CSharpBlockTest/TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement.diag.txt
Show resolved
Hide resolved
...rationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.codegen.cs
Show resolved
Hide resolved
src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs
Show resolved
Hide resolved
...re.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/EscapedIdentifiers_05.stree.txt
Show resolved
Hide resolved
src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs
Show resolved
Hide resolved
333fred
commented
Apr 11, 2024
src/Shared/Microsoft.AspNetCore.Razor.Test.Common/GenerateBaselines.cs
Outdated
Show resolved
Hide resolved
jjonescz
approved these changes
Apr 11, 2024
chsienki
approved these changes
Apr 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We were extremely inconsistent with how
@
was handled in razor code blocks. When@
was not followed immediately by a:
or<
, we would enter a recovery loop that would eat all characters until the next{
,}
, or<
; this is not correct, and resulted in a number of inconsistent behaviors as well as bad code. In order to make the existing behavior and new behavior difference understandable, I've done a few different test refactorings, so I would highly recommend reviewing this commit-by-commit. Commit summaries:Conditional
methods), but we can address that later.@
change where it wasn't clear that they weren't actually intended to compile. Now, all integration tests will verify that their C# diagnostics. We should at some point do the same for Razor diagnostics, but we may need to make a similar verification framework for razor diagnostics like we have for C# diagnostics.@
scenarios to show how it currently behaves.@
, and update the test baselines to show the new behavior.Here are the expected rules for
@
:@
indicates a transition into an embedded render expression.@:
or@<
indicate a transition into a render template@
, as C# wouldFixes #10186.