From cffb9627a0f7c835cb8dab31027bfd95c786c772 Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Tue, 12 May 2026 07:07:24 +0200 Subject: [PATCH] ProtocolGenerator: replace IReadableXxxProperties with unified IXxxProperties. Write-only properties are uncommon and having a separate IReadableXxxProperties interfaces makes (explicit interface) implementations more verbose. --- src/Tmds.DBus.Tool/ProtocolGenerator.cs | 76 ++++++++----------- ...fyGeneratedOutput_HandlerOnly.verified.txt | 34 ++++----- ...yAndHandlerDifferentNameSpace.verified.txt | 48 +++++------- ..._ProxyAndHandlerSameNamespace.verified.txt | 39 ++++------ ...rifyGeneratedOutput_ProxyOnly.verified.txt | 14 ++-- 5 files changed, 88 insertions(+), 123 deletions(-) diff --git a/src/Tmds.DBus.Tool/ProtocolGenerator.cs b/src/Tmds.DBus.Tool/ProtocolGenerator.cs index b308ccb..a3b9f2d 100644 --- a/src/Tmds.DBus.Tool/ProtocolGenerator.cs +++ b/src/Tmds.DBus.Tool/ProtocolGenerator.cs @@ -982,8 +982,7 @@ private void AppendHandlerTypesForInterface(string ns, string name, string handl AppendLine("MethodContext.ReplyError(\"org.freedesktop.DBus.Error.UnknownProperty\", $\"Unknown property: {Property}\");"); EndBlock(); - // Handle method that reads from IReadableXxxProperties - AppendLine($"public ValueTask Handle(IReadable{name}Properties properties)"); + AppendLine($"public ValueTask Handle(I{name}Properties properties)"); StartBlock(); AppendLine("switch (Property)"); StartBlock(); @@ -1018,8 +1017,7 @@ private void AppendHandlerTypesForInterface(string ns, string name, string handl AppendLine("public void Dispose() => MethodContext.Dispose();"); - // Handle method that reads all properties from IReadableXxxProperties - AppendLine($"public ValueTask Handle(IReadable{name}Properties properties)"); + AppendLine($"public ValueTask Handle(I{name}Properties properties)"); StartBlock(); AppendLine("var writer = MethodContext.CreateReplyWriter(\"a{sv}\");"); AppendLine("var dictStart = writer.WriteDictionaryStart();"); @@ -1171,9 +1169,27 @@ private void AppendPropertyTypes(string name, XElement interfaceXml, bool genera AppendPropertyEnum(name, readableProperties); } - if (readableProperties.Any()) + if (readableProperties.Any() || writableProperties.Any()) { - AppendReadableInterface($"IReadable{name}Properties", readableProperties); + AppendLine($"interface I{name}Properties"); + StartBlock(); + foreach (var property in readableProperties) + { + bool isWritable = writableProperties.Any(w => w.Name == property.Name); + if (isWritable) + { + AppendLine($"{property.DotnetReadType} {property.NameUpper} {{ get; set; }}"); + } + else + { + AppendLine($"{property.DotnetReadType} {property.NameUpper} {{ get; }}"); + } + } + foreach (var property in writeOnlyProperties) + { + AppendLine($"{property.DotnetReadType} {property.NameUpper} {{ set; }}"); + } + EndBlock(); } if (generateHandlers) @@ -1204,31 +1220,6 @@ private void AppendPropertyTypes(string name, XElement interfaceXml, bool genera } EndBlock(); } - - // IXxxProperties - if (readableProperties.Any() || writableProperties.Any()) - { - string propertiesInterfaceName = $"I{name}Properties"; - string baseInterface = readableProperties.Any() ? $" : IReadable{name}Properties" : ""; - AppendLine($"interface {propertiesInterfaceName}{baseInterface}"); - StartBlock(); - - foreach (var property in readableProperties) - { - bool isWritable = writableProperties.Any(w => w.Name == property.Name); - if (isWritable) - { - AppendLine($"new {property.DotnetReadType} {property.NameUpper} {{ get; set; }}"); - } - } - - foreach (var property in writeOnlyProperties) - { - AppendLine($"{property.DotnetReadType} {property.NameUpper} {{ set; }}"); - } - - EndBlock(); - } } if (generateProxies) @@ -1263,7 +1254,7 @@ private void AppendPropertyTypes(string name, XElement interfaceXml, bool genera } EndBlock(); - AppendLine($"sealed class {propertiesClassName} : {changedInterfaceName}, IReadable{name}Properties"); + AppendLine($"sealed class {propertiesClassName} : {changedInterfaceName}, I{name}Properties"); StartBlock(); string flagType = readableProperties.Length <= 32 ? "uint" : "ulong"; @@ -1413,6 +1404,11 @@ private void AppendPropertyTypes(string name, XElement interfaceXml, bool genera AppendLine("return props;"); EndBlock(); + foreach (var property in writeOnlyProperties) + { + AppendLine($"{property.DotnetReadType} I{name}Properties.{property.NameUpper} {{ set {{ }} }}"); + } + EndBlock(); } } @@ -1433,17 +1429,6 @@ private void AppendPropertyEnum(string name, Argument[] readableProperties) EndBlock(); } - private void AppendReadableInterface(string interfaceName, Argument[] readableProperties) - { - AppendLine($"interface {interfaceName}"); - StartBlock(); - foreach (var property in readableProperties) - { - AppendLine($"{property.DotnetReadType} {property.NameUpper} {{ get; }}"); - } - EndBlock(); - } - private void AppendSignalsClass(string name, XElement interfaceXml) { var signals = interfaceXml.Elements("signal").ToArray(); @@ -1491,8 +1476,7 @@ void AppendWriteSignalHeader() AppendLine($"writer.WriteString(\"{interfaceName}\");"); } - // Public overload: accepts IReadableXxxProperties with changed and invalidated spans - AppendLine($"public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, IReadable{name}Properties properties, ReadOnlySpan<{propertyEnumName}> changed, ReadOnlySpan<{propertyEnumName}> invalidated = default)"); + AppendLine($"public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, I{name}Properties properties, ReadOnlySpan<{propertyEnumName}> changed, ReadOnlySpan<{propertyEnumName}> invalidated = default)"); StartBlock(); AppendWriteSignalHeader(); @@ -1539,7 +1523,7 @@ void AppendWriteSignalHeader() EndBlock(); // Public overload: single changed property - AppendLine($"public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, IReadable{name}Properties properties, {propertyEnumName} changed)"); + AppendLine($"public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, I{name}Properties properties, {propertyEnumName} changed)"); StartBlock(); AppendLine("EmitPropertiesChanged(c, p, properties, stackalloc[] { changed }, default);"); EndBlock(); diff --git a/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_HandlerOnly.verified.txt b/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_HandlerOnly.verified.txt index 9f61478..ad99e92 100644 --- a/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_HandlerOnly.verified.txt +++ b/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_HandlerOnly.verified.txt @@ -16,22 +16,18 @@ namespace TestNamespace CurrentEntry = 3, IsActive = 4 } - interface IReadableCalculatorProperties + interface ICalculatorProperties { double LastResult { get; } ObjectPath CurrentPath { get; } (string, double) CurrentEntry { get; } - ValueTuple IsActive { get; } + ValueTuple IsActive { get; set; } } enum WritableCalculatorProperty { UnknownProperty = 0, IsActive = 4, } - interface ICalculatorProperties : IReadableCalculatorProperties - { - new ValueTuple IsActive { get; set; } - } interface ICalculatorHandler { internal static class Helper @@ -243,7 +239,7 @@ namespace TestNamespace { MethodContext.ReplyError("org.freedesktop.DBus.Error.UnknownProperty", $"Unknown property: {Property}"); } - public ValueTask Handle(IReadableCalculatorProperties properties) + public ValueTask Handle(ICalculatorProperties properties) { switch (Property) { @@ -274,7 +270,7 @@ namespace TestNamespace MethodContext = methodContext; } public void Dispose() => MethodContext.Dispose(); - public ValueTask Handle(IReadableCalculatorProperties properties) + public ValueTask Handle(ICalculatorProperties properties) { var writer = MethodContext.CreateReplyWriter("a{sv}"); var dictStart = writer.WriteDictionaryStart(); @@ -412,7 +408,7 @@ namespace TestNamespace writer.WriteDouble(result); c.TrySendMessage(writer.CreateMessage()); } - public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, IReadableCalculatorProperties properties, ReadOnlySpan changed, ReadOnlySpan invalidated = default) + public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, ICalculatorProperties properties, ReadOnlySpan changed, ReadOnlySpan invalidated = default) { var writer = c.GetMessageWriter(); writer.WriteSignalHeader( @@ -471,7 +467,7 @@ namespace TestNamespace writer.WriteArrayEnd(arrayStart); c.TrySendMessage(writer.CreateMessage()); } - public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, IReadableCalculatorProperties properties, CalculatorProperty changed) + public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, ICalculatorProperties properties, CalculatorProperty changed) { EmitPropertiesChanged(c, p, properties, stackalloc[] { changed }, default); } @@ -539,10 +535,11 @@ namespace TestNamespace Theme = 1, Language = 2 } - interface IReadableSettingsProperties + interface ISettingsProperties { string Theme { get; } - string Language { get; } + string Language { get; set; } + double Volume { set; } } enum WritableSettingsProperty { @@ -550,11 +547,6 @@ namespace TestNamespace Language = 2, Volume = 3 } - interface ISettingsProperties : IReadableSettingsProperties - { - new string Language { get; set; } - double Volume { set; } - } interface ISettingsHandler { internal static class Helper @@ -628,7 +620,7 @@ namespace TestNamespace { MethodContext.ReplyError("org.freedesktop.DBus.Error.UnknownProperty", $"Unknown property: {Property}"); } - public ValueTask Handle(IReadableSettingsProperties properties) + public ValueTask Handle(ISettingsProperties properties) { switch (Property) { @@ -653,7 +645,7 @@ namespace TestNamespace MethodContext = methodContext; } public void Dispose() => MethodContext.Dispose(); - public ValueTask Handle(IReadableSettingsProperties properties) + public ValueTask Handle(ISettingsProperties properties) { var writer = MethodContext.CreateReplyWriter("a{sv}"); var dictStart = writer.WriteDictionaryStart(); @@ -762,7 +754,7 @@ namespace TestNamespace member: "Changed"); c.TrySendMessage(writer.CreateMessage()); } - public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, IReadableSettingsProperties properties, ReadOnlySpan changed, ReadOnlySpan invalidated = default) + public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, ISettingsProperties properties, ReadOnlySpan changed, ReadOnlySpan invalidated = default) { var writer = c.GetMessageWriter(); writer.WriteSignalHeader( @@ -805,7 +797,7 @@ namespace TestNamespace writer.WriteArrayEnd(arrayStart); c.TrySendMessage(writer.CreateMessage()); } - public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, IReadableSettingsProperties properties, SettingsProperty changed) + public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, ISettingsProperties properties, SettingsProperty changed) { EmitPropertiesChanged(c, p, properties, stackalloc[] { changed }, default); } diff --git a/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_ProxyAndHandlerDifferentNameSpace.verified.txt b/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_ProxyAndHandlerDifferentNameSpace.verified.txt index 19a45cb..023f6ca 100644 --- a/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_ProxyAndHandlerDifferentNameSpace.verified.txt +++ b/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_ProxyAndHandlerDifferentNameSpace.verified.txt @@ -16,12 +16,12 @@ namespace ProxyNamespace CurrentEntry = 3, IsActive = 4 } - interface IReadableCalculatorProperties + interface ICalculatorProperties { double LastResult { get; } ObjectPath CurrentPath { get; } (string, double) CurrentEntry { get; } - ValueTuple IsActive { get; } + ValueTuple IsActive { get; set; } } interface INullableCalculatorProperties { @@ -39,7 +39,7 @@ namespace ProxyNamespace bool HasCurrentEntryChanged { get; } bool HasIsActiveChanged { get; } } - sealed class CalculatorProperties : IChangedCalculatorProperties, IReadableCalculatorProperties + sealed class CalculatorProperties : IChangedCalculatorProperties, ICalculatorProperties { private uint __set; private uint __invalidated; @@ -475,10 +475,11 @@ namespace ProxyNamespace Theme = 1, Language = 2 } - interface IReadableSettingsProperties + interface ISettingsProperties { string Theme { get; } - string Language { get; } + string Language { get; set; } + double Volume { set; } } interface INullableSettingsProperties { @@ -492,7 +493,7 @@ namespace ProxyNamespace bool HasThemeChanged { get; } bool HasLanguageChanged { get; } } - sealed class SettingsProperties : IChangedSettingsProperties, IReadableSettingsProperties + sealed class SettingsProperties : IChangedSettingsProperties, ISettingsProperties { private uint __set; private uint __invalidated; @@ -593,6 +594,7 @@ namespace ProxyNamespace } return props; } + double ISettingsProperties.Volume { set { } } } sealed partial class Settings : Tmds.DBus.Protocol.DBusObject { @@ -865,22 +867,18 @@ namespace HandlerNamespace CurrentEntry = 3, IsActive = 4 } - interface IReadableCalculatorProperties + interface ICalculatorProperties { double LastResult { get; } ObjectPath CurrentPath { get; } (string, double) CurrentEntry { get; } - ValueTuple IsActive { get; } + ValueTuple IsActive { get; set; } } enum WritableCalculatorProperty { UnknownProperty = 0, IsActive = 4, } - interface ICalculatorProperties : IReadableCalculatorProperties - { - new ValueTuple IsActive { get; set; } - } interface ICalculatorHandler { internal static class Helper @@ -1092,7 +1090,7 @@ namespace HandlerNamespace { MethodContext.ReplyError("org.freedesktop.DBus.Error.UnknownProperty", $"Unknown property: {Property}"); } - public ValueTask Handle(IReadableCalculatorProperties properties) + public ValueTask Handle(ICalculatorProperties properties) { switch (Property) { @@ -1123,7 +1121,7 @@ namespace HandlerNamespace MethodContext = methodContext; } public void Dispose() => MethodContext.Dispose(); - public ValueTask Handle(IReadableCalculatorProperties properties) + public ValueTask Handle(ICalculatorProperties properties) { var writer = MethodContext.CreateReplyWriter("a{sv}"); var dictStart = writer.WriteDictionaryStart(); @@ -1261,7 +1259,7 @@ namespace HandlerNamespace writer.WriteDouble(result); c.TrySendMessage(writer.CreateMessage()); } - public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, IReadableCalculatorProperties properties, ReadOnlySpan changed, ReadOnlySpan invalidated = default) + public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, ICalculatorProperties properties, ReadOnlySpan changed, ReadOnlySpan invalidated = default) { var writer = c.GetMessageWriter(); writer.WriteSignalHeader( @@ -1320,7 +1318,7 @@ namespace HandlerNamespace writer.WriteArrayEnd(arrayStart); c.TrySendMessage(writer.CreateMessage()); } - public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, IReadableCalculatorProperties properties, CalculatorProperty changed) + public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, ICalculatorProperties properties, CalculatorProperty changed) { EmitPropertiesChanged(c, p, properties, stackalloc[] { changed }, default); } @@ -1388,10 +1386,11 @@ namespace HandlerNamespace Theme = 1, Language = 2 } - interface IReadableSettingsProperties + interface ISettingsProperties { string Theme { get; } - string Language { get; } + string Language { get; set; } + double Volume { set; } } enum WritableSettingsProperty { @@ -1399,11 +1398,6 @@ namespace HandlerNamespace Language = 2, Volume = 3 } - interface ISettingsProperties : IReadableSettingsProperties - { - new string Language { get; set; } - double Volume { set; } - } interface ISettingsHandler { internal static class Helper @@ -1477,7 +1471,7 @@ namespace HandlerNamespace { MethodContext.ReplyError("org.freedesktop.DBus.Error.UnknownProperty", $"Unknown property: {Property}"); } - public ValueTask Handle(IReadableSettingsProperties properties) + public ValueTask Handle(ISettingsProperties properties) { switch (Property) { @@ -1502,7 +1496,7 @@ namespace HandlerNamespace MethodContext = methodContext; } public void Dispose() => MethodContext.Dispose(); - public ValueTask Handle(IReadableSettingsProperties properties) + public ValueTask Handle(ISettingsProperties properties) { var writer = MethodContext.CreateReplyWriter("a{sv}"); var dictStart = writer.WriteDictionaryStart(); @@ -1611,7 +1605,7 @@ namespace HandlerNamespace member: "Changed"); c.TrySendMessage(writer.CreateMessage()); } - public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, IReadableSettingsProperties properties, ReadOnlySpan changed, ReadOnlySpan invalidated = default) + public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, ISettingsProperties properties, ReadOnlySpan changed, ReadOnlySpan invalidated = default) { var writer = c.GetMessageWriter(); writer.WriteSignalHeader( @@ -1654,7 +1648,7 @@ namespace HandlerNamespace writer.WriteArrayEnd(arrayStart); c.TrySendMessage(writer.CreateMessage()); } - public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, IReadableSettingsProperties properties, SettingsProperty changed) + public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, ISettingsProperties properties, SettingsProperty changed) { EmitPropertiesChanged(c, p, properties, stackalloc[] { changed }, default); } diff --git a/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_ProxyAndHandlerSameNamespace.verified.txt b/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_ProxyAndHandlerSameNamespace.verified.txt index 4c2366b..7cd13f6 100644 --- a/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_ProxyAndHandlerSameNamespace.verified.txt +++ b/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_ProxyAndHandlerSameNamespace.verified.txt @@ -16,22 +16,18 @@ namespace TestNamespace CurrentEntry = 3, IsActive = 4 } - interface IReadableCalculatorProperties + interface ICalculatorProperties { double LastResult { get; } ObjectPath CurrentPath { get; } (string, double) CurrentEntry { get; } - ValueTuple IsActive { get; } + ValueTuple IsActive { get; set; } } enum WritableCalculatorProperty { UnknownProperty = 0, IsActive = 4, } - interface ICalculatorProperties : IReadableCalculatorProperties - { - new ValueTuple IsActive { get; set; } - } interface INullableCalculatorProperties { double? LastResult { get; } @@ -48,7 +44,7 @@ namespace TestNamespace bool HasCurrentEntryChanged { get; } bool HasIsActiveChanged { get; } } - sealed class CalculatorProperties : IChangedCalculatorProperties, IReadableCalculatorProperties + sealed class CalculatorProperties : IChangedCalculatorProperties, ICalculatorProperties { private uint __set; private uint __invalidated; @@ -689,7 +685,7 @@ namespace TestNamespace { MethodContext.ReplyError("org.freedesktop.DBus.Error.UnknownProperty", $"Unknown property: {Property}"); } - public ValueTask Handle(IReadableCalculatorProperties properties) + public ValueTask Handle(ICalculatorProperties properties) { switch (Property) { @@ -720,7 +716,7 @@ namespace TestNamespace MethodContext = methodContext; } public void Dispose() => MethodContext.Dispose(); - public ValueTask Handle(IReadableCalculatorProperties properties) + public ValueTask Handle(ICalculatorProperties properties) { var writer = MethodContext.CreateReplyWriter("a{sv}"); var dictStart = writer.WriteDictionaryStart(); @@ -858,7 +854,7 @@ namespace TestNamespace writer.WriteDouble(result); c.TrySendMessage(writer.CreateMessage()); } - public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, IReadableCalculatorProperties properties, ReadOnlySpan changed, ReadOnlySpan invalidated = default) + public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, ICalculatorProperties properties, ReadOnlySpan changed, ReadOnlySpan invalidated = default) { var writer = c.GetMessageWriter(); writer.WriteSignalHeader( @@ -917,7 +913,7 @@ namespace TestNamespace writer.WriteArrayEnd(arrayStart); c.TrySendMessage(writer.CreateMessage()); } - public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, IReadableCalculatorProperties properties, CalculatorProperty changed) + public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, ICalculatorProperties properties, CalculatorProperty changed) { EmitPropertiesChanged(c, p, properties, stackalloc[] { changed }, default); } @@ -985,10 +981,11 @@ namespace TestNamespace Theme = 1, Language = 2 } - interface IReadableSettingsProperties + interface ISettingsProperties { string Theme { get; } - string Language { get; } + string Language { get; set; } + double Volume { set; } } enum WritableSettingsProperty { @@ -996,11 +993,6 @@ namespace TestNamespace Language = 2, Volume = 3 } - interface ISettingsProperties : IReadableSettingsProperties - { - new string Language { get; set; } - double Volume { set; } - } interface INullableSettingsProperties { string? Theme { get; } @@ -1013,7 +1005,7 @@ namespace TestNamespace bool HasThemeChanged { get; } bool HasLanguageChanged { get; } } - sealed class SettingsProperties : IChangedSettingsProperties, IReadableSettingsProperties + sealed class SettingsProperties : IChangedSettingsProperties, ISettingsProperties { private uint __set; private uint __invalidated; @@ -1114,6 +1106,7 @@ namespace TestNamespace } return props; } + double ISettingsProperties.Volume { set { } } } sealed partial class Settings : Tmds.DBus.Protocol.DBusObject { @@ -1326,7 +1319,7 @@ namespace TestNamespace { MethodContext.ReplyError("org.freedesktop.DBus.Error.UnknownProperty", $"Unknown property: {Property}"); } - public ValueTask Handle(IReadableSettingsProperties properties) + public ValueTask Handle(ISettingsProperties properties) { switch (Property) { @@ -1351,7 +1344,7 @@ namespace TestNamespace MethodContext = methodContext; } public void Dispose() => MethodContext.Dispose(); - public ValueTask Handle(IReadableSettingsProperties properties) + public ValueTask Handle(ISettingsProperties properties) { var writer = MethodContext.CreateReplyWriter("a{sv}"); var dictStart = writer.WriteDictionaryStart(); @@ -1460,7 +1453,7 @@ namespace TestNamespace member: "Changed"); c.TrySendMessage(writer.CreateMessage()); } - public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, IReadableSettingsProperties properties, ReadOnlySpan changed, ReadOnlySpan invalidated = default) + public static void EmitPropertiesChanged(this DBusConnection c, ObjectPath p, ISettingsProperties properties, ReadOnlySpan changed, ReadOnlySpan invalidated = default) { var writer = c.GetMessageWriter(); writer.WriteSignalHeader( @@ -1503,7 +1496,7 @@ namespace TestNamespace writer.WriteArrayEnd(arrayStart); c.TrySendMessage(writer.CreateMessage()); } - public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, IReadableSettingsProperties properties, SettingsProperty changed) + public static void EmitPropertyChanged(this DBusConnection c, ObjectPath p, ISettingsProperties properties, SettingsProperty changed) { EmitPropertiesChanged(c, p, properties, stackalloc[] { changed }, default); } diff --git a/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_ProxyOnly.verified.txt b/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_ProxyOnly.verified.txt index 79c3e94..5bf9491 100644 --- a/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_ProxyOnly.verified.txt +++ b/test/Tmds.DBus.Generator.Tests/CodeGenerationTests.VerifyGeneratedOutput_ProxyOnly.verified.txt @@ -16,12 +16,12 @@ namespace TestNamespace CurrentEntry = 3, IsActive = 4 } - interface IReadableCalculatorProperties + interface ICalculatorProperties { double LastResult { get; } ObjectPath CurrentPath { get; } (string, double) CurrentEntry { get; } - ValueTuple IsActive { get; } + ValueTuple IsActive { get; set; } } interface INullableCalculatorProperties { @@ -39,7 +39,7 @@ namespace TestNamespace bool HasCurrentEntryChanged { get; } bool HasIsActiveChanged { get; } } - sealed class CalculatorProperties : IChangedCalculatorProperties, IReadableCalculatorProperties + sealed class CalculatorProperties : IChangedCalculatorProperties, ICalculatorProperties { private uint __set; private uint __invalidated; @@ -475,10 +475,11 @@ namespace TestNamespace Theme = 1, Language = 2 } - interface IReadableSettingsProperties + interface ISettingsProperties { string Theme { get; } - string Language { get; } + string Language { get; set; } + double Volume { set; } } interface INullableSettingsProperties { @@ -492,7 +493,7 @@ namespace TestNamespace bool HasThemeChanged { get; } bool HasLanguageChanged { get; } } - sealed class SettingsProperties : IChangedSettingsProperties, IReadableSettingsProperties + sealed class SettingsProperties : IChangedSettingsProperties, ISettingsProperties { private uint __set; private uint __invalidated; @@ -593,6 +594,7 @@ namespace TestNamespace } return props; } + double ISettingsProperties.Volume { set { } } } sealed partial class Settings : Tmds.DBus.Protocol.DBusObject {