affederaffe / Tmds.DBus.SourceGenerator

A roslyn source generator for creating proxies targeting the Tmds.DBus.Protocol API
MIT License
8 stars 5 forks source link

possible inconsistent use of Variant and VariantValue in proxy method signature #29

Open ash-microconnect opened 2 weeks ago

ash-microconnect commented 2 weeks ago

Please forgive me if there is a difference between Variant and VariantValue whose behaviour I am misunderstanding. I have observed that a method return type whose signature is a{sa{sv}} uses/maps to Variant for the "v" whereas a method accepting a parameter with the same signature uses Variant. This can be seen with the org.freedesktop.NetworkManager.Settings.Connection interface, where the GetSettings method returns connection properties and UpdateSettings is used to set connection properties. Their DBus definitions are:

GetSettings (OUT a{sa{sv}} settings); Update (IN a{sa{sv}} properties);

The generated proxy methods are:

public Task<Dictionary<string, Dictionary<string, VariantValue>>> GetSettingsAsync() public Task UpdateAsync(Dictionary<string, Dictionary<string, Variant>> properties)

This makes it difficult to modify a connection's properties (by first calling GetSettings, modifying the returned dictionary appropriately, then supplying that same modified dictionary to Update), as the two methods use dictionaries of differing types. Is there a technical reason why the different types are used? Could the same type be used for both input and output parameters?

Attached is the NetworkManager XML: NetworkManager-1.36.2-introspection.zip

affederaffe commented 1 week ago

The VariantValue type is optimized for reading, the Variant type exists for writing variants. These types are simply what is provided by Tmds.DBus.Protocol, see https://github.com/tmds/Tmds.DBus/blob/main/docs/protocol.md.

ash-microconnect commented 1 week ago

Thank you for directing me to that information. I have asked on that project about a method to translate from VariantValue to Variant (https://github.com/tmds/Tmds.DBus/issues/282).

ash-microconnect commented 1 week ago

FYI, https://github.com/tmds/Tmds.DBus/issues/303 tracks a change relevant to this discussion.