Skip to content

Conversation

@michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Mar 25, 2025

This is addressing the issue https://github.com/github/codeql-csharp-team/issues/474 reported by @MathiasVP.

There are two note-worthy consequences of this

  • Models that targeted an out or ref parameter will now correctly target Argument[...] instead of ReturnValue.
  • Prior to this change, a method with a ref parameter and a use of the ref parameter in the callable declaration would lead to an incorrect summary, as there would be flow from the parameter node to the SSA definition corresponding to the parameter. This is fixed with this change.

@github-actions github-actions bot added the C# label Mar 25, 2025
@michaelnebel michaelnebel force-pushed the csharp/modelgenparammodifiers branch from 215ceb8 to cdb7127 Compare March 26, 2025 13:26
@michaelnebel michaelnebel force-pushed the csharp/modelgenparammodifiers branch from cdb7127 to 8bda7ce Compare March 26, 2025 14:08
@michaelnebel michaelnebel marked this pull request as ready for review March 26, 2025 15:04
Copilot AI review requested due to automatic review settings March 26, 2025 15:04
@michaelnebel michaelnebel requested a review from a team as a code owner March 26, 2025 15:04
@michaelnebel michaelnebel added the no-change-note-required This PR does not need a change note label Mar 26, 2025
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 fixes the model generation to correctly print return flows via out/ref parameters and addresses an issue with ref parameter usage in method declarations. The changes include:

  • Updating model summaries for methods that handle out and ref parameters.
  • Fixing the incorrect summary flow for methods using ref parameters.
  • Introducing a new ParameterModifiers class with methods to test the updated behavior.
Files not reviewed (2)
  • csharp/ql/src/utils/modelgenerator/internal/CaptureModels.qll: Language not supported
  • shared/mad/codeql/mad/modelgenerator/internal/ModelGeneratorImpl.qll: Language not supported

Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more

// neutral=Models;ParameterModifiers;RefParamUse;(System.Object);summary;df-generated
public void RefParamUse(ref object value)
{
var b = value is null;
Copy link

Copilot AI Mar 26, 2025

Choose a reason for hiding this comment

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

The variable 'b' is assigned but never used; consider removing it or using it meaningfully to avoid confusion.

Suggested change
var b = value is null;
// The variable 'b' was removed as it was unused.

Copilot uses AI. Check for mistakes.
@michaelnebel michaelnebel merged commit 0a0ec18 into github:main Mar 27, 2025
44 of 45 checks passed
@michaelnebel michaelnebel deleted the csharp/modelgenparammodifiers branch March 27, 2025 09:03
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