-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
Name collisions in generated Proxy code when propery getter/setter exists as a method #231
Comments
Thanks for reporting this.
We already do have
Yeah but we could also make xmlgen smarter. :) |
Note that it's called |
In GitLab by @hansihe on Dec 25, 2021, 14:37 Ah! I must have missed that attribute somehow. Thanks for pointing me in the right direction! I guess this is now mainly an issue for making xmlgen smarter :) I'll update the issue text in a bit. |
Np. :)
Yeah, it's not super smart at the moment, unfortunately. |
No hurry. Happy holidays. :) |
I see several ways of preventing this issue:
|
Sure.
Yeah, that's not good.
Not sure I like this one. Ideally, the names should be natural derivatives of the underlying names. We should employ other methods (e.g suggestion #1). |
Hitting this now with Wouldn't solution # 1 cause end users of the autogenerated code to not know which of the underscored functions they should use? |
AFAICT this happens when there is a method that does the same as the property setter/getter so at least in most cases, this won't be an issue. The |
Hello, zbus version 5.0.1 Rename /// state method
#[zbus(name = "state")]
fn state_method(&self) -> zbus::Result<u32>; // <--- rename method
/// StateChanged signal
#[zbus(signal, name="StateChanged")] // <--- add name with member value i find in dbus-monitor
fn signal_state_changed(&self, state: u32) -> zbus::Result<()>; My function to listen NetworkManager.StateChanged become |
It's called a workaround. :) |
In GitLab by @hansihe on Dec 24, 2021, 19:44
There are several different variants of this, all of which I found in interfaces by
NetworkManager
.Case 1: Method collision with property
See the
org.freedesktop.NetworkManager
interface for an example.This interface has both a signal and a method named
State
:This will generate the following error when compiled:
Case 2: Method/property/signal collision with [signal]_changed function
See the
org.freedesktop.NetworkManager
interface for an example.The code generation will generate a function named
receive_state_changed
for both of these:This will generate the following error when compiled:
Thoughts
I imagine almost all of these can be solved by adding an argument to the
dbus_proxy
attribute like#[dbus_proxy(property, rename = "state_property"]
.While the XML code generator would still fail, the code would be fixable very easily.
As is today, unless I have missed something, cases like these are unrepresentable with
zbus_macros
.The text was updated successfully, but these errors were encountered: