Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C#: params modifier on collection types. #18329

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Dec 19, 2024

In this PR we make the relevant updates to the CodeQL library to support collection like types for params parameters. The extractor worked out of the box for extracting these types.
The feature is described here: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-13#params-collections

@michaelnebel michaelnebel marked this pull request as ready for review December 20, 2024 13:26
@Copilot Copilot bot review requested due to automatic review settings December 20, 2024 13:26
@michaelnebel michaelnebel requested a review from a team as a code owner December 20, 2024 13:26
Copy link
Contributor

@Copilot 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.

Copilot reviewed 13 out of 30 changed files in this pull request and generated 2 comments.

Files not reviewed (17)
  • csharp/ql/lib/semmle/code/csharp/Callable.qll: Language not supported
  • csharp/ql/lib/semmle/code/csharp/Variable.qll: Language not supported
  • csharp/ql/lib/semmle/code/csharp/commons/Collections.qll: Language not supported
  • csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll: Language not supported
  • csharp/ql/lib/semmle/code/csharp/dispatch/Dispatch.qll: Language not supported
  • csharp/ql/lib/semmle/code/csharp/frameworks/Format.qll: Language not supported
  • csharp/ql/lib/semmle/code/csharp/frameworks/System.qll: Language not supported
  • csharp/ql/lib/semmle/code/csharp/frameworks/system/collections/Generic.qll: Language not supported
  • csharp/ql/test/library-tests/arguments/argumentByName.expected: Language not supported
  • csharp/ql/test/library-tests/arguments/argumentByParameter.expected: Language not supported
  • csharp/ql/test/library-tests/arguments/argumentByParameter.ql: Language not supported
  • csharp/ql/test/library-tests/arguments/argumentName.expected: Language not supported
  • csharp/ql/test/library-tests/arguments/argumentType.expected: Language not supported
  • csharp/ql/test/library-tests/arguments/parameterGetArguments.expected: Language not supported
  • csharp/ql/test/library-tests/arguments/parameterGetArguments.ql: Language not supported
  • csharp/ql/test/library-tests/dispatch/CallContext.expected: Language not supported
  • csharp/ql/test/library-tests/dispatch/GetADynamicTarget.expected: Language not supported

Tip: Leave feedback on Copilot's review comments with the 👎 and 👍 buttons to help improve review quality. Learn more

{
f10(0, 1, 2);
f10(0, [1, 2]);
f10(args: 1, o: 0);
Copy link
Preview

Copilot AI Dec 20, 2024

Choose a reason for hiding this comment

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

The params modifier expects a List, but 1 is an int. It should be f10(args: new List { 1 }, o: 0);

Suggested change
f10(args: 1, o: 0);
f10(args: new List<int> { 1 }, o: 0);

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
SinkCollectionParams(new A()); // flow
SinkCollectionParams(null, new A()); // flow
SinkCollectionParams(null, new A(), null); // flow
SinkCollectionParams([new A()]); // flow
Copy link
Preview

Copilot AI Dec 20, 2024

Choose a reason for hiding this comment

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

The use of square brackets '[]' for collection initialization is incorrect in C#. It should be replaced with curly braces '{}'.

Suggested change
SinkCollectionParams([new A()]); // flow
SinkCollectionParams(new A[] { new A() }); // flow

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant