-
Notifications
You must be signed in to change notification settings - Fork 10
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
Custom events conversion issues #76
Comments
@VBAndCs what is an EventHandlerList? I have reimplemented the conversion in version 5.0.1.21. Please provide feedback. |
EventHandlerList is used internally to store event handlers for normal events (you can get it via reflection if you need), and you should use it manually with custom events. It is defined in System.ComponentModel. |
@VBAndCs I will look at this more everything looks good except raising event and that is a big issue with current implementation. |
@VBAndCs I fixed a lot of it but there are still a few issues with raising events |
The converter has serious issues with custom events. For example, this code:
is converted to:
Which has many errors:
Controls._buttonClicked = Nothing
_buttonClicked += value
_buttonClicked -= value
RaiseEvent(sender As Object, e As EventArgs)
and there is a related error when using this code to raise the event in another place:
5. Controls._buttonClicked?.Invoke()
The correct code should be:
and to raise the event:
'RaiseEvent ButtonClicked()'
Note: we use ButtonClicked not _buttonClicked, becuae I changed it from event to EventHandlerList. C# can set the event to null, but VB can't, and we must do it through the EventHandlerList.
Note: you can use one EventHandlerList to deal with all events in the class, as long as each event has a unique key. Say:
Private Shared Events As EventHandlerList
This is an example:
Note that that this part in the AddHandler:
is not necessary unless C# sets the event to null. In my code, each event will have only one handler, but this is not the generic case, so, it there is no
_event = bull
in C#, omit this part.The text was updated successfully, but these errors were encountered: