affederaffe / Tmds.DBus.SourceGenerator

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

Unable to set multiple sourcegen'd handlers in one path #17

Closed jmacato closed 3 months ago

jmacato commented 3 months ago

The Tmds.Dbus.Protocol.Connection class can only handle one MethodHandler at a time. Given that there are times that you need to provide multiple interfaces in the same path, is there any proper way of doing that with this sourcegen?

jmacato commented 3 months ago

@affederaffe I've tried to "fake" it with a "multiplexing" method handler but the lower-level protocol lib does some weird stuff on PathNodes and Introspection, any ideas on this perhaps?

affederaffe commented 3 months ago

I implemented something similar with https://github.com/affederaffe/Tmds.DBus.SourceGenerator/commit/3c240943e0f9d4a8925513d93cfaaea932f55391. The workflow for exposing handlers now is as follows:

var connection = new Connection(Address.Session);
await connection.ConnectAsync();
var pathHandler = new PathHandler("/path/to/interfaces");
pathHandler.Add(myImplementedHandler1);
pathHandler.Add(myImplementedHandler2);
connection.AddMethodHandler(pathHandler);

Everything compiles so far, but I haven't tested it completely yet. Is that something that would work for your use-case?

jmacato commented 3 months ago

@affederaffe awesome, i'll check that out now!

jmacato commented 3 months ago

Okay, im testing with Avalonia master atm and i've got these errors: errordump.log

im using the latest commit on main

jmacato commented 3 months ago

Okay, im testing with Avalonia master atm and i've got these errors: errordump.log

im using the latest commit on main

Caveat emptor: I've cherry picked the bumped versions of Tmds on avalonia (PR 15568)

affederaffe commented 3 months ago

Whoops, missed some using directives because implicit usings were on in my test project. I got Avalonia master with the changes of 15568 working (only minor changes).

jmacato commented 3 months ago

@affederaffe I believe it's working now! Thank you for swiftly implementing this!