C#: Make Assignment extend BinaryOperation.#21417
Open
aschackmull wants to merge 2 commits intogithub:mainfrom
Open
C#: Make Assignment extend BinaryOperation.#21417aschackmull wants to merge 2 commits intogithub:mainfrom
aschackmull wants to merge 2 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the C# CodeQL AST model so that Assignment is treated as a kind of BinaryOperation, aligning the public library API with planned CFG signature changes and ensuring the dbscheme reflects the new union membership.
Changes:
- Make
AssignmentextendBinaryOperationand provide operand accessor overrides. - Update the C# dbscheme so
@assign_expris included in@bin_op(instead of being included via@op_expr). - Adjust a LINQ library test to avoid pulling in assignments when ranging over
BinaryOperation.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| csharp/ql/test/library-tests/linq/Linq2.ql | Excludes Assignment from a BinaryOperation-based test query to keep expected results stable. |
| csharp/ql/lib/upgrades/178a7e6cf335486d33d4e49543148e3f57f04a9a/upgrade.properties | Declares the dbscheme upgrade for expanding @bin_op to include @assign_expr. |
| csharp/ql/lib/upgrades/178a7e6cf335486d33d4e49543148e3f57f04a9a/semmlecode.csharp.dbscheme | “New” dbscheme snapshot reflecting the updated @bin_op/@op_expr relationship. |
| csharp/ql/lib/upgrades/178a7e6cf335486d33d4e49543148e3f57f04a9a/old.dbscheme | “Old” dbscheme snapshot representing the pre-change state for the upgrade. |
| csharp/ql/lib/semmlecode.csharp.dbscheme | Applies the core dbscheme union change in the main library dbscheme. |
| csharp/ql/lib/semmle/code/csharp/exprs/Expr.qll | Updates BinaryOperation documentation to include Assignment. |
| csharp/ql/lib/semmle/code/csharp/exprs/Assignment.qll | Changes Assignment to extend BinaryOperation and adds operand overrides. |
| csharp/downgrades/e73ca2c93df8aae162f1704edc4817a5cb330529/upgrade.properties | Declares the corresponding downgrade reverting @assign_expr inclusion in @bin_op. |
| csharp/downgrades/e73ca2c93df8aae162f1704edc4817a5cb330529/semmlecode.csharp.dbscheme | Downgrade target dbscheme snapshot representing the pre-change state. |
| csharp/downgrades/e73ca2c93df8aae162f1704edc4817a5cb330529/old.dbscheme | Downgrade “old” snapshot representing the post-change state to downgrade from. |
You can also share your feedback on Copilot code review. Take the survey.
michaelnebel
reviewed
Mar 5, 2026
Comment on lines
28
to
31
| Expr getLValue() { result = this.getChild(1) } | ||
|
|
||
| /** Gets the right operand of this assignment. */ | ||
| Expr getRValue() { result = this.getChild(0) } |
Contributor
There was a problem hiding this comment.
Maybe consider deprecating these and replace their uses with get[Left|Right]Operand()?
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.
This is in order to align with future additions to the AST signature in the CFG library.