This is an automated email from the ASF dual-hosted git repository. sruehl pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 4cc1e6414b7ca0b7ca5efcbcddfc9edbef849d67 Author: Sebastian Rühl <[email protected]> AuthorDate: Thu Mar 19 16:06:35 2026 +0100 fix(plc4go/codegen): consider length in bits of parent as parent Closes #2493 --- .../go/src/main/resources/templates/go/complex-type-template.go.ftlh | 4 ++++ plc4go/protocols/opcua/readwrite/model/ExtensionObjectWithMask.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/code-generation/language/go/src/main/resources/templates/go/complex-type-template.go.ftlh b/code-generation/language/go/src/main/resources/templates/go/complex-type-template.go.ftlh index 8192b1cba1..a61fd70b31 100644 --- a/code-generation/language/go/src/main/resources/templates/go/complex-type-template.go.ftlh +++ b/code-generation/language/go/src/main/resources/templates/go/complex-type-template.go.ftlh @@ -831,7 +831,11 @@ func (m *_${type.name}) GetLengthInBits(ctx context.Context) uint16 { <#if type.isDiscriminatedParentTypeDefinition()> func (m *_${type.name}) getLengthInBits(ctx context.Context) uint16 { + <#if type.parentType.isPresent()> + lengthInBits := uint16(m.${type.getParentType().orElseThrow().name}Contract.(*_${type.getParentType().orElseThrow().name}).getLengthInBits(ctx)) + <#else> lengthInBits := uint16(0) + </#if> <#list type.fields as field> <#switch field.typeName> <#case "array"> diff --git a/plc4go/protocols/opcua/readwrite/model/ExtensionObjectWithMask.go b/plc4go/protocols/opcua/readwrite/model/ExtensionObjectWithMask.go index 705ce79cff..7c53b42c0a 100644 --- a/plc4go/protocols/opcua/readwrite/model/ExtensionObjectWithMask.go +++ b/plc4go/protocols/opcua/readwrite/model/ExtensionObjectWithMask.go @@ -305,7 +305,7 @@ func (m *_ExtensionObjectWithMask) GetTypeName() string { } func (m *_ExtensionObjectWithMask) getLengthInBits(ctx context.Context) uint16 { - lengthInBits := uint16(0) + lengthInBits := uint16(m.ExtensionObjectContract.(*_ExtensionObject).getLengthInBits(ctx)) // Simple field (encodingMask) lengthInBits += m.EncodingMask.GetLengthInBits(ctx)
