mono / dbus-sharp

DBus Sharp
http://mono.github.com/dbus-sharp
MIT License
76 stars 59 forks source link

Revert "Fixing Array Writing" #68

Open steffen-kiess opened 6 years ago

steffen-kiess commented 6 years ago

I think this change is broken:

When MessageWriter.Write(object) is called, a variant should be written (see also the comment above the method). If the object is an array, a variant containing the array should be written. A array which is not in a variant can be written using MessageWriter.Write(Type,object) or MessageWriter.WriteArray(T).

If the code somewhere calls MessageWriter.Write(object) when a plain array is needed, the caller should be fixed.

Currently, this change breaks returning an array as a variant, e.g. for the following service:

using System;
using DBus;
[Interface ("test.test")]
public interface TestInterface {
  object GetVal ();
}
public class Test : TestInterface {
  public object GetVal () { return new int[3] { 1, 2, 3 }; }
  public static void Main () {
    Bus bus = Bus.Session;
    bus.RequestName ("test.test");
    bus.Register (new ObjectPath ("/test/test"), new Test ());
    while (true)
      bus.Iterate ();
  }
}

Calling GetVal will disconnect the service:

qdbus --literal test.test /test/test test.test.GetVal
Error: org.freedesktop.DBus.Error.NoReply