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

Issue/774 #802

Merged
merged 28 commits into from
Dec 23, 2021
Merged

Issue/774 #802

merged 28 commits into from
Dec 23, 2021

Conversation

GrahamTheCoder
Copy link
Member

@GrahamTheCoder GrahamTheCoder commented Dec 21, 2021

Fixes #774

Problem

Methods handling events on a WithEvents property from a base class are not wired up after conversion

Solution

  • Look for methods which handle events on properties not defined within the type.
  • Override that property to add the appropriate handlers
  • In the base constructor, assign the property so that it runs the overridden code upon construction without further effort

Trade-offs

  • For the sake of a simple output, assume there's no type outside the compilation which inherits from a type and overrides a WithEvents property within it (e.g. by using a Handles clause on it). This will be a breaking change for a consumer of a converted VB library. If people complain about this scenario, we could add an option to toggle this trade-off since it seems like it will benefit a large proportion of users.

Manual test case tried

Real world app with Form2 inheriting Form1 and adding a method to handle a button click:

  • Check events fire and, and that the designer renders
  • After conversion, make a change in the designer and save
  • Check it's still the case that events fire and the designer renders.

@GrahamTheCoder GrahamTheCoder marked this pull request as ready for review December 22, 2021 19:54
@GrahamTheCoder GrahamTheCoder merged commit f24bff2 into master Dec 23, 2021
@GrahamTheCoder GrahamTheCoder deleted the issue/774 branch December 23, 2021 02:12
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

Successfully merging this pull request may close these issues.

VB -> C#: Missing event wiring for overridden members
1 participant