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 to support consuming API that has required members. #619

Closed
mrange opened this issue Dec 18, 2022 · 3 comments
Closed

VB to support consuming API that has required members. #619

mrange opened this issue Dec 18, 2022 · 3 comments

Comments

@mrange
Copy link

mrange commented Dec 18, 2022

Hi.

Perhaps this is already fixed but I wasn't able to google a solution and didn't find any issue matching my query. If this is a duplicate just close ASAP.

Anyway I have C# API that utilizes required members (from .NET7 IIRC). I can't get VB (running on .NET7) to consume the C# API successfully.

I am not concerned about being able to create APIs in VB that uses required members but rather consuming future C# APIs as this feature gets more and more used.

This is my example program. First the C# api

namespace CsLib
{
  public class XX
  {
    public required int X { get; init; }
    public string? Y { get; set; }
  }
}

Then I try to consume this API in VB

Imports CsLib

Module Program
    Sub Main(args As String())
        ' Refuses to compile with: 
        '  error BC37319: 'Public Overloads Sub New()' requires compiler feature 'RequiredMembers', which is not supported by this version of the Visual Basic compiler.
        Dim x As New XX() With {.X = 1, .Y = "123"}
        Console.WriteLine("Hello World!")
    End Sub
End Module

The error message implies that there might be a newer version of the compiler that I could use but I wasn't able to find that the switch. If there is but I missed my apologies for opening a duplicate ticket.

@mrange
Copy link
Author

mrange commented Dec 18, 2022

There is a discussion here but very little details: dotnet/roslyn#61435

@jrmoreno1
Copy link

jrmoreno1 commented Feb 11, 2023

Looks like this should be resolved by dotnet/roslyn#66084

@333fred
Copy link
Member

333fred commented May 10, 2023

This has been implemented and will be in VS 17.7.

@333fred 333fred closed this as completed May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants