diwic / dbus-rs

D-Bus binding for the Rust language
Other
591 stars 133 forks source link

Annotations on interfaces not shown in introspection #439

Closed rhbvkleef closed 1 year ago

rhbvkleef commented 1 year ago

When altering dbus-crossroads/test.rs the following way, the test fails, while it should succeed:

diff --git a/dbus-crossroads/src/test.rs b/dbus-crossroads/src/test.rs
index 2670afa..36963da 100644
--- a/dbus-crossroads/src/test.rs
+++ b/dbus-crossroads/src/test.rs
@@ -114,6 +114,7 @@ const INTROSPECT: &str = r###"<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS O
       <arg name="new_value" type="b"/>
     </signal>
     <property name="Bar" type="y" access="readwrite"/>
+    <annotation name="com.example.SampleAnnotation" value="TestValue"/>
   </interface>
   <interface name="org.freedesktop.DBus.Introspectable">
     <method name="Introspect">
@@ -163,6 +164,7 @@ fn introspect() {
         });
         b.signal::<(bool,), _>("Changed", ("new_value",));
         b.property("Bar").get(|_,_| Ok(0u8)).set(|_,_,_| Ok(None));
+        b.annotate("com.example.SampleAnnotation", "TestValue");
     });
     cr.insert("/com/example/sample_object0", &[token], ());
     cr.insert("/com/example/sample_object0/child_of_sample_object", &[], ());

This change fixes the problem:

diff --git a/dbus-crossroads/src/ifacedesc.rs b/dbus-crossroads/src/ifacedesc.rs
index ceb3142..f973853 100644
--- a/dbus-crossroads/src/ifacedesc.rs
+++ b/dbus-crossroads/src/ifacedesc.rs
@@ -116,7 +120,7 @@ impl Registry {
                     r += &format!(">\n{}    </property>\n",  x.annotations.introspect("      "));
                 }
             }
-            desc.annotations.introspect("    ");
+            r += &desc.annotations.introspect("    ");
             r += "  </interface>\n";
         };
         r