Skip to content

C#: Make Assignment extend BinaryOperation.#21417

Open
aschackmull wants to merge 2 commits intogithub:mainfrom
aschackmull:csharp/binary-assignment
Open

C#: Make Assignment extend BinaryOperation.#21417
aschackmull wants to merge 2 commits intogithub:mainfrom
aschackmull:csharp/binary-assignment

Conversation

@aschackmull
Copy link
Contributor

This is in order to align with future additions to the AST signature in the CFG library.

@aschackmull aschackmull requested a review from a team as a code owner March 5, 2026 13:43
Copilot AI review requested due to automatic review settings March 5, 2026 13:43
@aschackmull aschackmull added the no-change-note-required This PR does not need a change note label Mar 5, 2026
@github-actions github-actions bot added the C# label Mar 5, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Assignment extend BinaryOperation and provide operand accessor overrides.
  • Update the C# dbscheme so @assign_expr is 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.

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) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe consider deprecating these and replace their uses with get[Left|Right]Operand()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C# no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants