-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Improve c sharp binding generation #3261
base: master
Are you sure you want to change the base?
Conversation
- Enums of type byte were not implemented, only uint and ushort were recognised. - Added XML comments to the structs, and their fields. - Added default values to parameters - For the handles, it was not possible to have Invalid as a default parameter. Instead i emit another method without the argument, that calls the `extern` with an Invalid handle. This also required some overhauling for those structs, and i've also implemented some recommended fields to improve performance (https://learn.microsoft.com/en-us/visualstudio/ide/reference/generate-equals-structs?view=vs-2022).
There is one more change that i'd like to do, but wanted some feedback before attempting. The bindings are now generated from the C API, with explicit I would like to update the binding generator to add methods to the structs, rather than the current C-style API.
Would become private, and in VertexLayout a Likewise with init_ctor, which already caught me. |
This change makes all code managed only. bgfx in C# should be unmanaged. |
I'd gladly change the struct additions, i'm not very attached to them. However i dont believe this makes them unmanaged, if you are referring to the C# concept.
This is still satisfied since the only field is still an ushort. I'm not entirely sure how to test this, but for example the unmanaged generic type constraint is met. For the class, and a struct that fails above restrictions, it does not. It does however add a whole lot of noise. There is also an entirely different strategy possible, where there is only a single handle type.
This offers the same amount of type safety, a handle of one type cannot be used for another. |
These caused more friction than intended. Only the `Invalid` readonly field remains, and a constructor that includes the index parameter are additions.
My latest commit undid most of the struct changes. The only changes that remain there are the static Invalid field, and a constructor to pass along the index.
|
extern
with an Invalid handle. This also required some overhauling for those structs, and i've also implemented some recommended fields to improve performance (https://learn.microsoft.com/en-us/visualstudio/ide/reference/generate-equals-structs?view=vs-2022). This is an internal change, any existing project will still compile.