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

C# -> VB: Conversion of imported functions doesn't add 'End Function' clause #352

Closed
alt402 opened this issue Aug 9, 2019 · 2 comments
Closed
Labels
C# -> VB Specific to C# -> VB conversion

Comments

@alt402
Copy link

alt402 commented Aug 9, 2019

Input code

[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr OpenProcess(AccessMask dwDesiredAccess, bool bInheritHandle, uint dwProcessId);

Erroneous output

<DllImport("kernel32.dll", SetLastError:=True)>
Private Shared Function OpenProcess(ByVal dwDesiredAccess As AccessMask, ByVal bInheritHandle As Boolean, ByVal dwProcessId As UInteger) As IntPtr

Expected output

<DllImport("kernel32.dll", SetLastError:=True)>
Private Shared Function OpenProcess(ByVal dwDesiredAccess As AccessMask, ByVal bInheritHandle As Boolean, ByVal dwProcessId As UInteger) As IntPtr
End Function

Details

Product in use: VS extension

Version in use: 7.0.0.0

@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Aug 9, 2019

Thanks for the report. Looks like the converter is being too literal. I think another option would be along the lines of Private Declare Function OpenProcess Lib

Happy to accept a PR, if not I'll wait until after #350, and if that's successful use as a test case

@GrahamTheCoder GrahamTheCoder added the C# -> VB Specific to C# -> VB conversion label Aug 9, 2019
@GrahamTheCoder
Copy link
Member

This was mentioned again in #377 - I've moved the example out of the description into here:
Input:

[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
        public static extern int SetWindowsHookEx(HookType idHook, HookProc lpfn, IntPtr hInstance, int threadId);

Erroneous:

<DllImport("user32.dll", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall)>
        Function SetWindowsHookEx(ByVal idHook As HookType, ByVal lpfn As HookProc, ByVal hInstance As IntPtr, ByVal threadId As Integer) As Integer

Expected:

<DllImport("user32.dll", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall)>
        Function SetWindowsHookEx(ByVal idHook As HookType, ByVal lpfn As HookProc, ByVal hInstance As IntPtr, ByVal threadId As Integer) As Integer
        End Function

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

No branches or pull requests

2 participants