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

codegen: change static func names to avoid conflicts #86

Conversation

jagobagascon
Copy link
Contributor

@jagobagascon jagobagascon commented Mar 18, 2024

Static functions were generated as public functions using the method name found in the windows metadata. Since all static functions of a namespace are added to the same Go package, this could cause collisions when two classes had the same static method (FromBluetoothAddress for example can be found in both Bluetoothdevice and BluetoothLEDevice).

This commit changes the naming strategy to include the class name as a prefix of the static function names. And the existing methods will be kept for a while marked as deprecated to maintain backwards compatibility.

fixes #85

@jagobagascon jagobagascon force-pushed the feature/change-static-method-name-strategy-to-avoid-conflicts branch from f8ff369 to 6ca4178 Compare March 18, 2024 14:37
Copy link

@glerchundi glerchundi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra complexity added to keep backward compat and not knowing until when we should keep those one they land into the main branch inclines me to be much more drastic and allow ourselves to directly apply breaking changes. These kind of cases should be rare and quite easy to adapt once they bump from one version to another. So I would do the following:

  1. Add a note in the README about breaking changes and protect ourselves by explicitly allowing breaking changes although we know that there shouldn't be much more cases. I would use this PR as an example.
  2. Get rid of the extra complexity and just add a prefix to the types and regenerate those that are needed. We can also help tinygo/bluetooth by sending a bump and required changes.

WDYT?

This commit changes the naming strategy to include the class name as a
prefix of the static function names. Static functions were generated as
public functions using the method name found in the windows metadata.
Since all static functions of a namespace are added to the same Go
package, this could cause collisions when two classes had the same
static method (`FromBluetoothAddress` for example can be found in both
Bluetoothdevice and BluetoothLEDevice).

fixes #85
@jagobagascon jagobagascon force-pushed the feature/change-static-method-name-strategy-to-avoid-conflicts branch from 6ca4178 to 22784f4 Compare March 20, 2024 11:36
@jagobagascon
Copy link
Contributor Author

Considering that the change only involves renaming a few functions and the simpler code, I agree

@jagobagascon jagobagascon merged commit a2e4fc0 into main Mar 20, 2024
2 checks passed
@jagobagascon jagobagascon deleted the feature/change-static-method-name-strategy-to-avoid-conflicts branch March 20, 2024 11:39
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.

Static Function Name Collisions
2 participants