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

Add XML examples #8

Open Bip901 opened 8 months ago

Bip901 commented 8 months ago

Hi! I'm new to this repo.

I've managed to find this example by searching through old issues, but some official examples of how the XML should look like would be highly appreciated!

softlion commented 6 months ago

you can generate the xml from whatever bluez service you want from linux.

For example:

busctl list
busctl tree org.bluez

busctl introspect org.bluez /org/bluez/hci0 --xml-interface

Then put that xml file into some folder of your project (dbus/org.bluez.xml in the below example), then modify your csproj:

    <ItemGroup>
      <PackageReference Include="Tmds.DBus.Protocol" Version="0.16.0" />
      <PackageReference Include="Tmds.DBus.SourceGenerator" Version="0.0.15" PrivateAssets="All">
        <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      </PackageReference>
    </ItemGroup>

    <ItemGroup>
      <AdditionalFiles Include="dbus/org.bluez.xml" DBusGeneratorMode="Proxy" />
    </ItemGroup>

Result:

image

DBusGeneratorMode affects the generated classes:

Bip901 commented 6 months ago

Cool! Consider including this generation command in the README.