dotnet / dotnet/vblang

Knock out BC31902

Open
#602 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

````
Imports System.Runtime.CompilerServices

Public Module Program

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


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` 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.