Repository navigation
Replies: 2 comments
|
Convert to issue to increase visibility |
|
This exists in the 2.0 release line and works very close to your attribute proposal. Add the [DataType(Namespace = "urn:mycompany:plc", DataTypeId = "i=3001",
BinaryEncodingId = "i=3002", XmlEncodingId = "i=3003")]
public partial class MyEncodeableObject
{
[DataTypeField(Order = 1, Name = "ErrorMessage")]
public string SomeText { get; set; }
[DataTypeField(Order = 2)]
public long BigNumber { get; set; }
}The generator implements Full reference: docs/SourceGeneratedDataTypes.md. Usage on the client together with server types is covered in docs/ComplexTypes.md. Closing, since the feature is available. Please open an issue for anything the generator doesn't handle for your types. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Right now I use Claude to generate the boiler plate involved in inherited from
EncodeableObject. It would be wonderful if there was a source generator that would handle, at least, overriding Decode, Encode, and IsEqual. I wouldn't mind if it was done by convention or through attributes (like the CommunityToolkit.Mvvm package does for view models). I could see it a couple of ways.Convention
And now the Attribute style of handling it (which might provide some more flexibility
Attributes
This would basically generate the same thing (adding the ExpandedNodeId properties that the other one wouldn't) but also use information in the attribute to know in what order to read from the decoder and write to the encoder. I can continue to use AI tools to do it but a source generator would be the superior method to handling the boiler plate in this case. I'd love to hear others' thoughts on this.
All reactions