-
Notifications
You must be signed in to change notification settings - Fork 66
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
Unable to call C# 7.3 method with unmanaged
type parameter
#300
Comments
You are correct. We don't support unmanaged types in Visual Basic, even if the type is used in C#. I'll be honest here... unmanaged types is not a strong point (as I've spent a lot of my career in VB). I don't think I understand your scenario. You have an unmanaged type in VB that you want to pass to C# to get the size? |
I have a blittable |
The function I gave is only an example. Actually, I tried to write a |
There are no plans for Visual Basic to support variations of unsafe code. |
Solved in project Mercury |
An As a result: even though consumer code is not unsafe or low-level, it's not possible to use generic ImageSharp API-s from VB now. @KathleenDollard have you considered scenarios like this? Any chance it may change your decision? |
Before this issue being solved, I suggest switching to C# now, though it is hard to accept that VB.NET is abandoned by M$. I wish I'm wrong... |
I second the need to be able to consume C# APIs that have |
Hey @fitdev , I'm happy to see that there's still someone would like this feature after 3 years. But sadly I have to admit that VB has been abandoned by MS. I have ported some of my projects from VB to C#, and never use VB in new projects any more. It is a painful way, but better than sticking to a language abandoned by its inventor. I will leave this issue open to mark how MS abandoned their wonderful inventions again and again. |
@Berrysoft Good for you that you were able to port your apps to CS. I completely agree that this is the approach going forward. The problem is it takes time, and in the meantime a small feature like this is really a must. I opened another issue where I suggested that at the least |
@Berrysoft if you want to use Don't be afraid of the |
In order to add some "gravitas" to this issue I recently ran into this when using VB + ImageSharp and was stopped right in my tracks. IMHO the problem is not only that it doesn't work but also that the VB compiler produces error messages that is just confusing
Type '?' and ''? Perhaps supporting unmanaged types is beyond the scope of VB but could I wish for an improved error message at least that guides me to a solution? |
@teo-tsirpanis #300 (comment) is not a solution for the problem if the |
Not to mention libraries like imagesharp where that constraint leaks into their public API despite the public API not needing it. But then again, can't they have an internal interface that is hidden from everyone else use it though (and then manually write their own reference assembly code that does not contain said interface) where the ref assembly is then used to compile VB.NET Code? I think that could be an option and then they would have to instruct the compiler to drop in the real imagesharp implementation. |
I wrote a C# function like this:
But when I tried to call this function in a VB project, the compiler threw a BC30649 exception said:
""is an unsupported type
What should I do to call this function?
The text was updated successfully, but these errors were encountered: