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

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

Closed ilya-zlobintsev closed 5 months ago

ilya-zlobintsev commented 5 months ago

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.
affederaffe commented 5 months ago

Thank you for the report! That's indeed a bug where methods with no parameters and no return value where simply ignored. This should work with https://github.com/affederaffe/Tmds.DBus.SourceGenerator/commit/8854fa8212b20881a020e40e635881d219b648fc, though the CI build currently fails because it depends on a nightly version of Tmds.DBus.Protocol. A new version will be released when the Tmds.DBus.Protocol package is uploaded to NuGet.

ilya-zlobintsev commented 5 months ago

Thanks, seems to work fine now