Tmds.DBus.SourceGenerator 0.0.22
Tmds.DBus.SourceGenerator
A roslyn source generator targeting the Tmds.DBus.Protocol API
Introduction
This source generator eliminates the usage of reflection to be trimmer- and AOT-friendly. For further documentation of Tmds.DBus and DBus in general, see https://github.com/tmds/Tmds.DBus#readme.
Usage
Note
This Source Generator targets the
Tmds.DBus.ProtocolAPI, which means you have to explicitly install said package.
Either install the NuGet package Tmds.DBus.SourceGenerator or clone the git repository and add a project reference to
the source generator in your .csproj
<ItemGroup>
<ProjectReference Include="./Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<Import Project="./Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.props" />
Then add the XML definitions as AdditionalFiles to your project.
Depending on whether you want to generate a Proxy or a handler, set the DBusGeneratorMode to either Proxy or Handler, respectively.
<ItemGroup>
<AdditionalFiles Include="DBusXml/DBus.xml" DBusGeneratorMode="Proxy" />
<AdditionalFiles Include="DBusXml/StatusNotifierItem.xml" DBusGeneratorMode="Handler" />
</ItemGroup>
Now you can instantiate the generated proxy class and use it like with the traditional Tmds.DBus. For handlers, create a new class and inherit from the generated one and implement its abstract methods.
Examples
For example, you may take a look at some projects that use this source generator:
How to get DBus interface definitions
DBus interface definitions are written in XML. There are mainly two ways for getting those:
- Finding the source online somewhere... This could be a GitHub repo or some obscure website from the mid-2000s (at your own risk).
- Dumping the definition via introspection
If you have a service running on your system from which you want to extract the definition, you may use
busctl, e.g.:
To list available services:
To inspect the object tree of a service:busctl list
To dump the XML definition of the interface:busctl tree <service name>busctl introspect <service name> /path/to/object --xml-interface
Showing the top 20 packages that depend on Tmds.DBus.SourceGenerator.
| Packages | Downloads |
|---|---|
|
Avalonia.FreeDesktop
Avalonia is a cross-platform UI framework for .NET providing a flexible styling system and supporting a wide range of Operating Systems such as Windows, Linux, macOS and with experimental support for Android, iOS and WebAssembly.
|
24 |
| Version | Downloads | Last updated |
|---|---|---|
| 0.0.22 | 2 | 10/16/2025 |
| 0.0.21 | 16 | 03/12/2025 |
| 0.0.20 | 19 | 11/14/2024 |
| 0.0.19 | 21 | 11/14/2024 |
| 0.0.18 | 22 | 11/14/2024 |
| 0.0.17 | 19 | 11/14/2024 |
| 0.0.16 | 26 | 05/24/2024 |
| 0.0.15 | 16 | 05/24/2024 |
| 0.0.14 | 19 | 05/24/2024 |
| 0.0.13 | 20 | 05/24/2024 |
| 0.0.12 | 21 | 05/24/2024 |
| 0.0.11 | 22 | 05/24/2024 |
| 0.0.10 | 20 | 05/24/2024 |
| 0.0.8 | 20 | 05/24/2024 |
| 0.0.7 | 19 | 05/24/2024 |
| 0.0.6 | 23 | 05/24/2024 |
| 0.0.5 | 18 | 05/24/2024 |
| 0.0.4 | 23 | 05/24/2024 |
| 0.0.3 | 20 | 05/24/2024 |
| 0.0.2 | 22 | 05/24/2024 |