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

Implementing interfaces with static members #625

Open
josephmoresena opened this issue Aug 27, 2024 · 7 comments
Open

Implementing interfaces with static members #625

josephmoresena opened this issue Aug 27, 2024 · 7 comments

Comments

@josephmoresena
Copy link

I am trying to implement an interface created in a C# assembly in .NET 8, which has both static virtual and abstract members. However, it's not possible to implement this interface in a Visual Basic class because all interface implementation methods have to be instance methods, and when I try to compile, it indicates that the method does not match the interface.

@Nukepayload2
Copy link

The ability of consuming C# code in VB is already broken since C# 7.2. Here's a list of interoperability issues of calling C# library with VB (found in my projects):

  • Use ref struct (Span(Of T), Utf8JsonReader)
  • Use ref readonly returns (ReadOnlySpan(Of T).Item)
  • Override methods that have in parameters
  • Override ref readonly parameters
  • Override methods that have covariance returns
  • Use fixed buffers
  • Consume members that have unmanaged constraint (ImageSharp, OpenCVSharp)
  • Use unmanaged delegates
  • Inherit record types
  • Use or implement default interface members
  • Implement IAsyncEnumerable
  • Dispose IAsyncDisposable objects with Try ... Finally
  • Implement async functions that has a return type requires a custom AsyncStateMachine (Parallel.ForEachAsync)
  • Use a custom logger that requires custom string interpolation handlers
  • Override methods with allows ref struct constraint
  • Override init properties
  • Use libraries that only have C# source generators (Mvvm community toolkit, LibraryImportAttribute, AOT Json serializer, AOT regex)

@paul1956
Copy link

paul1956 commented Sep 3, 2024

@Nukepayload2 are these is the Roslyn Repo? Does on the team actually look here anymore? Give the goal of keeping VB compatible with C# libraries all of these should be bugs.

@aarondglover
Copy link

@Nukepayload2 are these is the Roslyn Repo? Does on the team actually look here anymore? Give the goal of keeping VB compatible with C# libraries all of these should be bugs.

Its just not going to happen @paul1956 :(

@paul1956
Copy link

paul1956 commented Nov 3, 2024

@Nukepayload2 They are in the process of fixing the "constraint" issue, a major compatibility issue with VB consuming C# Libraries. and it's a very big change.

If people report compatibility issues using VS Feedback NOT HERE and up-vote them in VS Feedback they seem to be getting attention.

On another positive note I with the help of the testing team have been updating and reimplementing WinForms VB Runtime using more modern VB and Async and improving tests coverage to as close to 100% as possible without using "mock" which I don't understand.

I have lost track of the total number of PR's merged but its significant, in the process bugs have been uncovered and fixes especially around Clipboard. And .Net 9 includes a significant start are Dark Mode with fill VB support.

There are 180 new tests written in VB and at least double that number written in C# to test VB Runtime.

@Nukepayload2
Copy link

@paul1956

They are in the process of fixing the "constraint" issue

This is a good news. We can finally use OpenCVSharp and ImageSharp.

If people report compatibility issues using VS Feedback NOT HERE and up-vote them in VS Feedback they seem to be getting attention.

I've created or upvoted some feedbacks before. But they were marked as Closed - Lower Priority. I'll try to create more VB/C# interop feedbacks that don't require new syntaxes to resolve.

@paul1956
Copy link

paul1956 commented Nov 6, 2024

Need to be a campaign to upvote.

@AnthonyDGreen
Copy link
Contributor

The unmanaged constraint fix for those interested.

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

5 participants