Skip to content

Commit

Permalink
Added Indexer(CS) and Properties(VB) FN
Browse files Browse the repository at this point in the history
  • Loading branch information
CristianAmbrosini committed Jan 27, 2023
1 parent ee448f6 commit f7b83b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public void Base(string[] myArray)
var s1 = new MyClass(1, 2, 3); // Compliant
s1 = new MyClass(args: new int[] { 2, 3 }, a: 1); // Compliant (if you specifically require the arguments to be passed in this order there is no way of making this compliant, thus we shouldn't raise)
var s2 = new MyOtherClass(args: new int[12], a: new int[] { 2, 3 }); // Compliant

var s3 = new IndexerClass();
var indexer1 = s3[new int[] { 1, 2 }]; // FN
var indexer2 = s3[1, 2]; // Compliant
}

public void Method(params string[] args) { }
Expand All @@ -58,3 +62,8 @@ public class MyOtherClass
{
public MyOtherClass(int[] a, params int[] args) { }
}

public class IndexerClass
{
public int this[params int[] i] => 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Public Class Program
Dim s1 = New [MyClass](1, 2, 3) ' Compliant
s1 = New [MyClass](args:=New Integer() {2, 3}, a:=1) ' Error [BC30587] Named argument cannot match a ParamArray parameter
Dim s2 = New MyOtherClass(args:=New Integer(11) {}, a:=New Integer() {2, 3}) ' Error [BC30587] Named argument cannot match a ParamArray parameter

Dim s3 = Prop(New String() {"s1", "s2"}) ' FN
Dim s4 = Prop("s1", "s2") ' Compliant
End Sub

Public Sub Method(ParamArray args As String())
Expand All @@ -44,6 +47,12 @@ Public Class Program

Public Sub Method4(ParamArray a As String(), ParamArray args As String()) 'Error [CS0231]
End Sub

Public ReadOnly Property Prop(ParamArray param() As String) As Integer
Get
End Get
End Property

End Class

Public Class [MyClass]
Expand Down

0 comments on commit f7b83b1

Please sign in to comment.