Skip to content

C#: Unary expression cleanup in the extractor.#21845

Open
michaelnebel wants to merge 3 commits into
github:mainfrom
michaelnebel:csharp/unaryoperatorcleanup
Open

C#: Unary expression cleanup in the extractor.#21845
michaelnebel wants to merge 3 commits into
github:mainfrom
michaelnebel:csharp/unaryoperatorcleanup

Conversation

@michaelnebel
Copy link
Copy Markdown
Contributor

@michaelnebel michaelnebel commented May 13, 2026

In this PR we

  • Only extract operator calls in prefix unary expressions when they are needed.
  • Re-factor and simplify the implementation of Pre-and Postfix unary expressions in the extractor.

DCA

@michaelnebel michaelnebel force-pushed the csharp/unaryoperatorcleanup branch from ae8245b to 30a5769 Compare May 19, 2026 12:22
@michaelnebel michaelnebel added the no-change-note-required This PR does not need a change note label May 20, 2026
@michaelnebel michaelnebel requested a review from hvitved May 20, 2026 13:30
@michaelnebel michaelnebel marked this pull request as ready for review May 20, 2026 13:30
@michaelnebel michaelnebel requested a review from a team as a code owner May 20, 2026 13:30
Copilot AI review requested due to automatic review settings May 20, 2026 13:30
Copy link
Copy Markdown
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 refactors unary expression extraction in the C# extractor by splitting prefix and postfix unary handling and avoiding extracting operator-call metadata unless the expression is actually an OPERATOR_INVOCATION.

Changes:

  • Replace the generic Unary extractor entity with a dedicated PrefixUnary entity.
  • Simplify PostfixUnary by using PostfixUnaryExpressionSyntax directly and extracting the operand from Syntax.Operand.
  • Only emit expr_call/dynamic_member_name operator-call data when Kind == ExprKind.OPERATOR_INVOCATION.
Show a summary per file
File Description
csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Unary.cs Removed legacy prefix-unary extractor implementation (superseded by PrefixUnary).
csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/PrefixUnary.cs New dedicated prefix unary entity; gates operator-call extraction on OPERATOR_INVOCATION.
csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/PostfixUnary.cs Uses PostfixUnaryExpressionSyntax and gates operator-call extraction similarly.
csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Factory.cs Routes prefix unary syntax kinds to PrefixUnary and updates postfix unary construction calls.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0

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.

2 participants