Giter VIP home page Giter VIP logo

tmds.dbus.sourcegenerator's People

Contributors

17steen avatar affederaffe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tmds.dbus.sourcegenerator's Issues

[Proposal] Inline `BackingProperties`

Proposal

It would be nice to set properties on an object directly instead of using the BackingProperties property as a proxy.
To prevent conflicts, you could implement IMethodHandler explicitly.
This would have the added "benefit" of hiding the implementation detail of IMethodHandler.

Implications

Major breaking changes.

Generated code incorrect for DBus structs in 0.0.12

Hi, after upgrading from 0.0.11 to 0.0.12, I found that the generated code for structs seem to be incorrect. I've created a minimal repro here - master branch is on 0.0.11 and generator-0.0.12 branch on 0.0.12.

It seems to be missing out the last field in structs, like these methods from ReaderExtensions:

// Should be (ObjectPath, byte[], byte[], string)
public static (ObjectPath, byte[], byte[]) ReadStruct_roayaysz(this ref Reader reader)
{
    reader.AlignStruct();
    return ValueTuple.Create(reader.ReadObjectPath(), reader.ReadArray_ay(), reader.ReadArray_ay());
}

// Should be (ObjectPath, byte[], byte[])
public static (ObjectPath, byte[]) ReadStruct_roayayz(this ref Reader reader)
{
    reader.AlignStruct();
    return ValueTuple.Create(reader.ReadObjectPath(), reader.ReadArray_ay());
}

Add XML examples

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!

compile-error on handler generation for `Dictionary`

I'm trying to generate the handler code for the org.bluez.LEAdvertisement1 interface containing some dictionary properties.

This is a snipped of the generated code trying to access Key and Value from the ManufacturerData dictionary instance:

case "ManufacturerData":
{
    MessageWriter writer = context.CreateReplyWriter("v");
    writer.WriteDBusVariant(new DBusVariantItem("a{qv}", new DBusDictEntryItem(new DBusUInt16Item(BackingProperties.ManufacturerData.Key), new DBusVariantItem(BackingProperties.ManufacturerData.Value))));
    context.Reply(writer.CreateMessage());
    writer.Dispose();
    break;
}
Introspection LEAdvertisement1
<?xml version="1.0" encoding="utf-8" ?>
<node>
	<interface name="org.bluez.LEAdvertisement1">
		<method name="Release"/>
		<property name="Type" type="s" access="read"/>
		<property name="ServiceUUIDs" type="as" access="read"/>
		<property name="ManufacturerData" type="a{qv}" access="read"/>
		<property name="SolicitUUIDs" type="as" access="read"/>
		<property name="ServiceData" type="a{sv}" access="read"/>
		<property name="Includes" type="as" access="read"/>
		<property name="LocalName" type="s" access="read"/>
		<property name="Appearance" type="q" access="read"/>
		<property name="Duration" type="q" access="read"/>
		<property name="Timeout" type="q" access="read"/>
	</interface>
</node>

Btw: Very nice library! ❤️

Build errors when attempting to generate proxy

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

Generation from NetworkManager.xml results in duplicate GetDevicesAsync and GetAllDevicesAsync methods

Running the source generator against the NetworkManager introspection xml (https://github.com/NetworkManager/NetworkManager/blob/main/introspection/org.freedesktop.NetworkManager.xml) results in generated code that duplicates the GetDevicesAsync() and GetAllDevicesAsync() methods.

To recreate, add the specified org.freedesktop.NetworkManager.xml as an AdditionalItem to the project, then note the compile errors in the generated code.

Found against package version 0.0.6.

Generate changes the case of the interface methods

I have a method like this defined in my interface.xaml

  <method name="set_number">
   <arg type="d" name="number" direction="in"/>
  </method>

and the outputed dbus call is this:

                writer.WriteMethodCallHeader(_destination, _path, Interface, "SetNumber", "d");

Which is incorrect

Invalid code generated from mpris dbus interface (duplicate "Introspect" handlers)

I'm trying to generate a handler for these two interfaces:
org.mpris.MediaPlayer2
org.mpris.MediaPlayer2.Player

But for both of them, the generated code doesn't compile since it has several switch cases for Introspect:
Tmds.DBus.SourceGenerator.OrgMprisMediaPlayer2Player.g.cs lines 309-341:

                case "org.mpris.MediaPlayer2.Player":
                    switch (context.Request.MemberAsString, context.Request.SignatureAsString)
                    {
                        case ("Introspect", "" or null):
                        {
                            break;
                        }

                        case ("Introspect", "" or null):
                        {
                            break;
                        }

                        case ("Introspect", "" or null):
                        {
                            break;
                        }

                        case ("Introspect", "" or null):
                        {
                            break;
                        }

                        case ("Introspect", "" or null):
                        {
                            break;
                        }

                        case ("Introspect", "" or null):
                        {
                            break;
                        }
Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.OrgMprisMediaPlayer2Player.g.cs(317,30): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.

Issues when reading individual properties from generated proxy class

Hi, I've been using this source generator to write a wrapper over the D-Bus Secret Service API. I've run into an issue where reading individual properties (i.e. GetSomePropertyAsync) appears to be broken, but reading all properties at once (i.e. GetAllPropertiesAsync) works fine.

I've created a minimal repro here: https://github.com/Ace4896/SecretsTest

  • For bool and ulong values, the returned values seem to be incorrect
  • For string values, an IndexOutOfRangeException is thrown:
Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Tmds.DBus.Protocol.ThrowHelper.ThrowIndexOutOfRange()
   at Tmds.DBus.Protocol.Reader.ReadSpan(Int32 length)
   at Tmds.DBus.Protocol.Reader.ReadSpan()
   at Tmds.DBus.Protocol.Reader.ReadString()
   at Tmds.DBus.SourceGenerator.ReaderExtensions.ReadMessage_s(Message message, Object _) in /home/jpacheco/Documents/Repositories/Local/C#/SecretsTest/SecretsTest.Generated/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.ReaderExtensions.cs:line 111
   at Tmds.DBus.Protocol.DBusConnection.<>c__41`1.<CallMethodAsync>b__41_0(Exception exception, Message message, Object state1, Object state2, Object state3)
--- End of stack trace from previous location ---
   at Tmds.DBus.Protocol.DBusConnection.MyValueTaskSource`1.System.Threading.Tasks.Sources.IValueTaskSource<T>.GetResult(Int16 token)
   at Tmds.DBus.Protocol.DBusConnection.CallMethodAsync[T](MessageBuffer message, MessageValueReader`1 valueReader, Object state)
   at Tmds.DBus.Protocol.Connection.CallMethodAsync[T](MessageBuffer message, MessageValueReader`1 reader, Object readerState)
   at SecretsTest.Generated.Program.Main(String[] args) in /home/jpacheco/Documents/Repositories/Local/C#/SecretsTest/SecretsTest.Generated/Program.cs:line 35
   at SecretsTest.Generated.Program.<Main>(String[] args)
  • For an array of ObjectPath values, an ArgumentOutOfRangeException is thrown:
Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'count')
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument)
   at System.Buffers.SequenceReader`1.AdvanceToNextSpan(Int64 count)
   at Tmds.DBus.Protocol.Reader.ReadSpan(Int32 length)
   at Tmds.DBus.Protocol.Reader.ReadSpan()
   at Tmds.DBus.Protocol.Reader.ReadString()
   at Tmds.DBus.Protocol.Reader.ReadObjectPath()
   at Tmds.DBus.SourceGenerator.ReaderExtensions.ReadArray_ao(Reader& reader) in /home/jpacheco/Documents/Repositories/Local/C#/SecretsTest/SecretsTest.Generated/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.ReaderExtensions.cs:line 37
   at Tmds.DBus.SourceGenerator.ReaderExtensions.ReadMessage_ao(Message message, Object _) in /home/jpacheco/Documents/Repositories/Local/C#/SecretsTest/SecretsTest.Generated/Tmds.DBus.SourceGenerator/Tmds.DBus.SourceGenerator.DBusSourceGenerator/Tmds.DBus.SourceGenerator.ReaderExtensions.cs:line 96
   at Tmds.DBus.Protocol.DBusConnection.<>c__41`1.<CallMethodAsync>b__41_0(Exception exception, Message message, Object state1, Object state2, Object state3)
--- End of stack trace from previous location ---
   at Tmds.DBus.Protocol.DBusConnection.MyValueTaskSource`1.System.Threading.Tasks.Sources.IValueTaskSource<T>.GetResult(Int16 token)
   at Tmds.DBus.Protocol.DBusConnection.CallMethodAsync[T](MessageBuffer message, MessageValueReader`1 valueReader, Object state)
   at Tmds.DBus.Protocol.Connection.CallMethodAsync[T](MessageBuffer message, MessageValueReader`1 reader, Object readerState)
   at SecretsTest.Generated.Program.Main(String[] args) in /home/jpacheco/Documents/Repositories/Local/C#/SecretsTest/SecretsTest.Generated/Program.cs:line 38
   at SecretsTest.Generated.Program.<Main>(String[] args)

Based on the stack traces, I'm not sure if it's the protocol library or generated code that's causing the issue...

If it helps, I'm running Fedora 38, kernel 6.4.14-200, KDE 5.27.7.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.