-
Notifications
You must be signed in to change notification settings - Fork 97
Expose internal/private platform specific fields #1028
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
base: main
Are you sure you want to change the base?
Conversation
…Bluetooth features after using Kable for discovery and/or connection
|
I'm very hesitant to expose these fields because they are serious footguns. Internally, Kable needs to keep state info for I/O and if a library consumer performs I/O directly w/ these exposed fields, then it will likely mess with the Kable machinery. I understand that there are definitely use-cases where these risks are fine, but I'm afraid of getting very misleading/confusing bug reports due to misuse of these exposed fields. I think it would be more appropriate to understand needed use-cases and implement the features that consumers needs vs. exposing this internal machinery. |
|
I understand and your hesitation makes sense, exposing internal fields is always a risk. I will keep working on the L2CAP PR. I'm working on it for a project and have a pretty clean Android implementation, but I still have to work on the iOS code and test both thoroughly. |
|
@twyatt how would you feel about an opt-in annotation like |
Ultimately, I want Kable to be useful for as many people as possible, so I would like to make fields available if they might help some consumers.
My only remaining concern would be getting bug reports after someone used an "internal" API. So maybe we log a very loud log statement upon first access of an "internal" API? That way when they share logs it becomes very apparent that their problems may be from the API usage vs. a Kable bug. 🤷 |
…ripheral as KableInternalApi
|
I have created an initial implementation of what the annotation could be like if that's the way you want to take it. I also added another commit with a possible implementation of the log warning. It's a bit messy, but I couldn't think of a way to only show the message once and to only show it when the property is accessed from outside the Kable library. If you like the way the log message was handled I could add it to the other places where @KableInternalApi is being used. I can also move the Logging to an object to have it a bit more organized instead of having a global variable and create a logger specifically for this so that you don't get the logger of the class you accessed it from, but instead something like "Kable/InternalApi" or whatever. |
|
I like this approach and appreciate the PR. I've been swamped with other projects at the moment, but hope to find some time to review this soon. |
…nd change annotation Retention to Binary
…nally so that internal usage doesn't trigger the InternalApi warning
|
I changed every usage of fields marked InternalApi so that it's easier to visualize what a more complete change might look like.
|
Expose platform specific fields to allow users to handle more advanced Bluetooth features after using Kable for discovery and/or connection
This change will allow users to implement their own advanced features, such as L2CAP, while the features are added to Kable, or even if the features are not added.
I haven't exposed JVM and JS fields because I'm not familiar with the platforms, and whether it is of interest. If it is I could research it and see what fields to expose, on JS it seems to be BluetoothDevice, but I haven't been able to figure it out at a quick glance for JVM (btleplug).