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: Add addresssof when passing method group #1039

Open
gmcfarlane opened this issue Oct 30, 2023 · 3 comments
Open

C# -> VB: Add addresssof when passing method group #1039

gmcfarlane opened this issue Oct 30, 2023 · 3 comments
Labels
C# -> VB Specific to C# -> VB conversion enhancement

Comments

@gmcfarlane
Copy link

Input code

public sub foo(){

  v_.MasterRowGetLevelDefaultView += new DevExpress.XtraGrid.Views.Grid.MasterRowGetLevelDefaultViewEventHandler(this.MasterRowGetLevelDefaultView);
}    

Erroneous output

Public Function foo() As [sub]
    v_.MasterRowGetLevelDefaultView += New DevExpress.XtraGrid.Views.Grid.MasterRowGetLevelDefaultViewEventHandler(Me.MasterRowGetLevelDefaultView)
End Function

Expected output

Public Function foo() As [sub]
    v_.MasterRowGetLevelDefaultView += New DevExpress.XtraGrid.Views.Grid.MasterRowGetLevelDefaultViewEventHandler( addressof Me.MasterRowGetLevelDefaultView)
End Function

simply needs addressof as a parameter to the addHandler method.
love the tool.

Details

  • Product in use: e.g. icsharpcode.github.io/CodeConverter / VS extension / both
  • Version in use: e.g. 5.6.3 or a commit hash (if it's a 3rd party tool using this library, try one of the above)
  • Did you see it working in a previous version, which?
  • Any other relevant information to the issue, or your interest in contributing a fix.
@gmcfarlane gmcfarlane added the C# -> VB Specific to C# -> VB conversion label Oct 30, 2023
@GrahamTheCoder GrahamTheCoder changed the title C# -> VB: _Add a short description_ C# -> VB: Add addresssof when passing method group Nov 1, 2023
@Sympatron
Copy link

I agree that AddressOf is missing in this case. But it still won't compile, because += does not work for VB.NET.

@gmcfarlane
Copy link
Author

gmcfarlane commented Nov 6, 2023 via email

@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Nov 7, 2023

Thanks both. From the slightly broken input (sub) I assumed the Web converter was used here to convert a quick snippet. It only references a few core dot net libraries, so will never be able to distinguish the thing being assigned here is an event and just makes a best effort.

If you use the extension in visual studio on compiling code, you'll generally get a far better conversion. I'd expect AddHandler to be added
It may also be that addresof is added, or that neither are. Would have to try it.

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 enhancement
Projects
None yet
Development

No branches or pull requests

3 participants