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

[Bug] Methods using handles don't compile #15

Closed ShortDevelopment closed 3 months ago

ShortDevelopment commented 3 months ago

Issue

Methods using handles don't compile, as ReadHandle is generic and SafeHandle is abstract.

error CS0411: The type arguments for method 'Reader.ReadHandle<T>()' cannot be inferred from the usage. Try specifying the type arguments explicitly.

Reproduce

org.bluez.Profile1

<?xml version="1.0" encoding="utf-8" ?>
<node>
    <interface name="org.bluez.Profile1">
        <method name="NewConnection">
            <arg type="o" direction="in"/>
            <arg type="h" direction="in"/>
            <arg type="a{sv}" direction="in"/>
            <annotation name="org.qtproject.QtDBus.QtTypeName.In2" value="QVariantMap"/>
        </method>
        <method name="RequestDisconnection">
            <arg type="o" direction="in"/>
        </method>
        <method name="Release">
            <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
        </method>
    </interface>
</node>

Solution

Use SafeFileHandle https://github.com/affederaffe/Tmds.DBus.SourceGenerator/blob/42d16f485453e8182ce9fcf008f9b1844b3bf2f6/Tmds.DBus.SourceGenerator/DBusSourceGenerator.Parsing.cs#L196-L197

https://github.com/affederaffe/Tmds.DBus.SourceGenerator/blob/42d16f485453e8182ce9fcf008f9b1844b3bf2f6/Tmds.DBus.SourceGenerator/DBusSourceGenerator.Utils.cs#L117

affederaffe commented 3 months ago

Should be fixed with https://github.com/affederaffe/Tmds.DBus.SourceGenerator/commit/fcef8b51fdf2d20aebf79afb92ed20f6a0cde667. Do you mind trying the CI build and see if it fixes your issue?

ShortDevelopment commented 3 months ago

This fixed it, thanks!