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

Fix JS prototype chain for exported .NET subclasses #368

Merged
merged 2 commits into from
Sep 1, 2024

Conversation

jasongin
Copy link
Member

@jasongin jasongin commented Aug 31, 2024

Fixes: #365

  • In the source generator, pass the base class to JSClassBuilder constructor baseClass parameter when defining a subclass.
    • This sets up the JS prototype chain correctly, enabling access to base members on the subclass and making JS instanceof work as expected for instances of the exported classes.
    • This required some significant refactoring in ModuleGenerator.cs to ensure the base class was separately declared as a variable before constructing the subclass. Previously the entire module was declared as one chained statement; now each type is declared and added in separate statements.
  • In the source generator, include base interface members in the generated interface proxy classes.
  • Change how the version.props file is generated by dotnet pack.
    • This isn't directly related to the above fixes, but it has been annoying me during development because the previous mechanism sometimes did not regenerate the version after switching git branches.

@jasongin jasongin requested a review from vmoroz August 31, 2024 21:27
@jasongin jasongin merged commit 81c928a into main Sep 1, 2024
24 checks passed
@jasongin jasongin deleted the dev/jasongin/subclass branch September 1, 2024 03:50
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.

Cannot use inherited properties in subclasses?
2 participants