You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Imports System.Runtime.CompilerServices
Public Module Program
<Extension>
Public Sub AddRange(Of T)([Me] As IList(Of T), <[ParamArray]> elements As IEnumerable(Of T))
For Each e In elements
[Me].Add(e)
Next
End Sub
<Extension>
Public Sub AddRange(Of T)([Me] As List(Of T), <[ParamArray]> elements As T())
For Each e In elements
[Me].Add(e)
Next
End Sub
Public Sub Main(args As String())
Dim l As IList(Of Integer) = New List(Of Integer)
l.AddRange(New Integer(){1,2,3})
End Sub
End Module
Raises BC31902
What's going on here is this library is written in VB specifically to spoof-out the C# compiler to allow params IEnumerable<T> to work (and a few other things C# should be able to do but can't but that's for another day). But in further development I found it necessary to call the methods within the implementation and it got kicked out.
The simplest solution is not to treat it as a params argument if it's not an array type, and given the existing error this breaks no code.
The text was updated successfully, but these errors were encountered:
Raises BC31902
What's going on here is this library is written in VB specifically to spoof-out the C# compiler to allow
params IEnumerable<T>
to work (and a few other things C# should be able to do but can't but that's for another day). But in further development I found it necessary to call the methods within the implementation and it got kicked out.The simplest solution is not to treat it as a params argument if it's not an array type, and given the existing error this breaks no code.
The text was updated successfully, but these errors were encountered: