Repository navigation
Print shifts and repeated block expressions correctly in ExpressionPrinter - #39320
Merged
AndriySvyryd merged 1 commit intoOct 21, 2026
Merged
Conversation
…inter ExpressionPrinter had LeftShift/RightShift in its operator map but not in the Visit switch, so they fell back to Expression.ToString(). VisitBlock also used Except() to drop the result expression, which has set semantics: a block that reuses the same expression instance more than once, or whose result instance also appears earlier in the block, lost statements in the printed output.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation changes include regression coverage and have no unresolved review issues.
No open issues 🎉
What changed in this PR
This pull request fixes ExpressionPrinter output for shift operators and block expressions containing repeated expression instances.
Changes:
- Routes
LeftShiftandRightShiftthrough binary-expression printing. - Replaces set-based block filtering with positional filtering.
- Adds regression tests for both scenarios.
| File | Description |
|---|---|
test/EFCore.Tests/Query/ExpressionPrinterTest.cs |
Adds regression coverage for shift operators and repeated block expressions. |
src/EFCore/Query/ExpressionPrinter.cs |
Corrects shift dispatch and preserves repeated block expressions by position. |
Review effort: Lite
AndriySvyryd
approved these changes
Oct 21, 2026
Member
|
Thanks for your contribution! |
This file contains hidden or 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
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.
ExpressionPrinter had LeftShift/RightShift in its operator map but not in the Visit switch, so they fell back to Expression.ToString(). VisitBlock also used Except() to drop the result expression, which has set semantics: a block that reuses the same expression instance more than once, or whose result instance also appears earlier in the block, lost statements in the printed output.