-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
3ccd115
commit 2fb41a4
Showing
2 changed files
with
21 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
20 changes: 20 additions & 0 deletions
20
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ArrayPassedAsParams.CSharp12.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
|
||
const int a = 1; | ||
int[] array = [2, 3]; | ||
|
||
_ = new MyClass(1, [1, 2, 3]); // Noncompliant | ||
_ = new MyClass(1, []); // Noncompliant | ||
|
||
// repro for https://github.com/SonarSource/sonar-dotnet/issues/8510 | ||
_ = new MyClass(1, [a, .. array]); // Noncompliant FP | ||
|
||
_ = new MyClass2([1], [1, 2, 3]); // Noncompliant | ||
_ = new MyClass2([1, 2, 3], 1); | ||
_ = new MyClass3([1, 2, 3], [4, 5, 6]); // Noncompliant FP | ||
_ = new MyClass3([[1, 2, 3], [4, 5, 6]]); // Noncompliant | ||
_ = new MyClass3([[1, 2, 3], [4, 5, 6]]); // Noncompliant | ||
|
||
class MyClass(int a, params int[] args); | ||
class MyClass2(int[] a, params int[] args); | ||
class MyClass3(params int[][] args); |