-
Notifications
You must be signed in to change notification settings - Fork 138
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
Workflow improvement - Delete Bindings #53
Comments
Thank you for taking the time to write this up in such detail, and for the offer to create a PR to improve the project! There are three ways that you can do this right now, but none is ideal: Manual EditingThis approach solves the problem by manually editing the bindings. To add a new abstract method, property, or event:
To remove an existing abstract method, property, or event:
Temporary VirtualThis approach solves the problem by temporarily making the To add a new abstract method, property, or event:
{
"Name": "MyGame.AbstractBaseBallScript",
"BaseTypes": [
{
"BaseName": "MyGame.BaseBallScript",
"DerivedName": "MyGame.BallScript",
"OverrideMethods": [
{
"Name": "Foo",
"ParamTypes": []
}
]
}
]
}
To remove an existing abstract method, property, or event:
Delete and Re-createThis approach solves the problem by removing the bindings, making changes, then re-creating the bindings. To add a new abstract method, property, or event:
To remove an existing abstract method, property, or event:
ComparisonThis "Manual Editing" approach requires manual editing and temporarily shows a compiler error, but it's extremely quick to do and always guided by double-clicking the compile error. The "Temporary Virtual" approach requires no manual editing and never produces a compiler error. It does, however, involve more steps and a fair amount of typing into the JSON config for the addition part. These steps aren't guided by compiler errors and are likely harder to figure out for most users. The "Delete and Re-create" approach is simple and straightforward, but requires the user to perform the steps in the right order since they will not work (as you point out) after the compiler error is already present. It's not quite as guided as the "Manual Editing" approach. A New Way?Your "Delete Bindings" approach seems closest to the "Delete and Re-create" approach, except that it deletes all bindings. That's simpler, but may cause errors for code relying on other bindings being present. If that's the case, deleting all bindings will cause compiler errors and, ironically, prevent generating bindings. Let me know if you have any ideas for other approaches. I'll try to think of some, too. |
I have an idea but it makes the problem worse, but I'll post it anyways because maybe it might spark other ideas. Mono.CecilX construct dll's instead of generating readable code (Weaving). Just an idea, makes the problem worse as you can not read anything... --Edit-- |
The Issue
When you create a new Abstract type for example
AbstractBaseBallScript
and you generate the bindings you getBaseBallScript
In yourBindings.cs
. Switching back to unity editor triggers a compilation and no errors. Good.If you add some more abstract functions to your
AbstractBaseBallScript
and switch back to unity editor to re-build your bindings. Unity Editor will have some Errors for you, but this does not prevent you from clicking on Generate Bindings. If you do generate bindings againGenerateBindings
is accessing an older assembly without your changes toAbstractBaseBallScript
. ThusBindings.cs
will not have your new changes and will continue to give compilation errors.The only way to fix this is to manually clear out your
Bindings.cs
, compile your code with no errors, then clickGenerate Bindings
. This results with bindings that reflect your changes.One Potential Fix
The way I have fixed this currently is by adding a new editor option
NativeScript/Delete Bindings
. I callInjectBuilders
and have them clear out the bindings for me. Now I can delete the bindings and compile without errors. One problem that still persists is you still have to fix any other errors from referencing the bindings generated class from your code-base. In my case its just a factory function.I'm not sure if this is an already solved problem. I would like to know what your thoughts are on this.
If you think the Delete Bindings is a good idea I can create another pull request as well.
The text was updated successfully, but these errors were encountered: