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

Build errors when attempting to generate proxy #2

Closed langebo closed 1 year ago

langebo commented 1 year ago

Hey affe,

i tried to use your source generator in order to publish a little project with native aot compilation. but upon adding the nuget package, the interface xml template and the project configuration i receive a ton of build errors:

/home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.ReaderExtensions.cs(16,44): error CS0122: 'Message' is inaccessible due to its protection level [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(111,54): error CS0122: 'MessageWriter' is inaccessible due to its protection level [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(111,28): error CS8337: The first parameter of a 'ref' extension method 'WriteDBusVariant' must be a value type or a generic type constrained to struct. [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(117,51): error CS0122: 'MessageWriter' is inaccessible due to its protection level [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(117,28): error CS8337: The first parameter of a 'ref' extension method 'WriteDBusItem' must be a value type or a generic type constrained to struct. [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(16,64): error CS0246: The type or namespace name 'Reader' could not be found (are you missing a using directive or an assembly reference?) [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(16,39): error CS8337: The first parameter of a 'ref' extension method 'ReadDBusVariant' must be a value type or a generic type constrained to struct. [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.SignalHelper.cs(16,86): error CS0246: The type or namespace name 'MatchRule' could not be found (are you missing a using directive or an assembly reference?) [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(25,73): error CS0246: The type or namespace name 'Reader' could not be found (are you missing a using directive or an assembly reference?) [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(25,88): error CS0246: The type or namespace name 'DBusType' could not be found (are you missing a using directive or an assembly reference?) [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(25,42): error CS8337: The first parameter of a 'ref' extension method 'ReadDBusBasicTypeItem' must be a value type or a generic type constrained to struct. [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(327,16): error CS0246: The type or namespace name 'DBusType' could not be found (are you missing a using directive or an assembly reference?) [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(43,55): error CS0246: The type or namespace name 'Reader' could not be found (are you missing a using directive or an assembly reference?) [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(43,70): error CS0246: The type or namespace name 'DBusType' could not be found (are you missing a using directive or an assembly reference?) [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(43,33): error CS8337: The first parameter of a 'ref' extension method 'ReadDBusItem' must be a value type or a generic type constrained to struct. [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.SignalHelper.cs(21,89): error CS0246: The type or namespace name 'MatchRule' could not be found (are you missing a using directive or an assembly reference?) [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.SignalHelper.cs(21,105): error CS0246: The type or namespace name 'MessageValueReader<>' could not be found (are you missing a using directive or an assembly reference?) [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.VariantExtensions.cs(321,30): error CS0246: The type or namespace name 'DBusType' could not be found (are you missing a using directive or an assembly reference?) [/home/fedora/Projects/priv/Tiler/Tiler.csproj] /home/fedora/Projects/priv/Tiler/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.SignalHelper.cs(26,152): error CS0246: The type or namespace name 'MessageValueReader<>' could not be found (are you missing a using directive or an assembly reference?) [/home/fedora/Projects/priv/Tiler/Tiler.csproj]

Same thing happens when cloning your project and adding it via project reference. I have the code pushed to a branch here: https://github.com/langebo/Tiler/tree/features/native-aot

The dbus windows interface I use comes from a gnome shell extension: https://extensions.gnome.org/extension/4724/window-calls/

Can you tell me what I am doing wrong? Thanks in advance

langebo commented 1 year ago

Update: By explicitly adding a package reference to Tmds.DBus.Protocol and removing the reference to Tmds.Dbus itself and also changing the DBusGeneratorMode to Proxy, the project now builds w/o errors and can be published with native aot compilation.

Maybe you could clarify that the source generator is based on the low-level Protocol library in your documentation ;)

Have a nice one