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

VB -> C#: missing type declaration in c# for vb implicitly-typed array #632

Closed
KunzeAndreas opened this issue Sep 23, 2020 · 2 comments
Closed
Labels
VB -> C# Specific to VB -> C# conversion

Comments

@KunzeAndreas
Copy link

KunzeAndreas commented Sep 23, 2020

Input code

WithList({Sub() Debug.Print("a"), Sub() Debug.Print("b")})
Private Shared Sub WithList(actions As List(Of Action))
        Debug.Print(actions.Count.ToString)
End Sub

Erroneous output

WithList(new[] { () => Debug.Print("a"), () => Debug.Print("b") }); 
--> No best type found for implicitly-typed array

Expected output

WithList(new List<Action>() { () => Debug.Print("a"), () => Debug.Print("b") });

Details

  • Product in use: VS extension
  • Version in use: 8.1.8.0
  • Did you see it working in a previous version, which? no
@KunzeAndreas KunzeAndreas added the VB -> C# Specific to VB -> C# conversion label Sep 23, 2020
@GrahamTheCoder
Copy link
Member

Thanks for this. There's already some code for inferring delegate types on the converter. Hopefully it'll be a good start for solving this. We'll need to check the VB behaviour though, often it just infers object for cases like these.

@GrahamTheCoder
Copy link
Member

I've confirmed with an example here that "Action" can be inferred in this case

Note: It chooses whatever the target type is, so no clever lambda analysis is needed here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

2 participants