Skip to content

Conversation

@larws
Copy link
Contributor

@larws larws commented Apr 17, 2025

This fixes Issues #211 and #202

The dervied class with optional field(s) is now able to directly influence the creation of the encoding mask and it is guaranteed to happen at the beginning of the encoding and decoding.

Removed the invalid JSON encoding compatible methods for reading and writing an encoding mask since they were not correctly generated.

@CLAassistant
Copy link

CLAassistant commented Apr 17, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ larws
❌ opcfoundation-org
You have signed the CLA already but the status is still pending? Let us recheck it.

@opcfoundation-org
Copy link
Contributor

Update ModelCompiler to use SDK 1.05.376. Please verify.

@larws
Copy link
Contributor Author

larws commented Apr 24, 2025

It still generates invalid code in case of a complex data type with optional fields deriving from a data type without optional fields.

I think the current solution where the EncodingMask property is just a uint reduces the developer experience again, since the user is now forced to cast the generated flags herself. This could be avoided with the approach in this PR. If you agree with that I can incorporate the current changes to the master branch into the PR. If you don't think this is the right approach we can close the PR.

@larws larws force-pushed the issue/211-invalid-source branch 2 times, most recently from 5f2c2b9 to b163042 Compare April 24, 2025 15:35
@opcfoundation-org
Copy link
Contributor

The uint was used because casting was going to be needed if there was a subtype because the subtype declares a new enum with new fields.

The requirement to allow subtypes of StructureType=StructrureWithOptional field with the base type of StructureType=Structrure has been approved by the WG. It has not been implemented yet.

@larws
Copy link
Contributor Author

larws commented Apr 25, 2025

That issue should be addressed by the proposed change, since every generated subtype introduces its own EncodingMask property with its specific fields type. And if I understand the code under (https://github.com/OPCFoundation/UA-ModelCompiler/blob/20dbd73ecdf59223030dc032d1a8a6b2d0cc5ec9/Opc.Ua.ModelCompiler/ModelGenerator2.cs#L3758-L3789)[ModelGenerator2.cs#L3758-L3789] correctly the fields enum should include all optional fields within the type hierarchy.

With the hooks OnWriteEncodingMask and OnReadEncodingMask the encoding mask should always be correctly written.

@larws larws force-pushed the issue/211-invalid-source branch 2 times, most recently from c3e90d9 to 80d533f Compare July 4, 2025 10:58
@larws larws force-pushed the issue/211-invalid-source branch 2 times, most recently from 88f4c16 to 7f09eee Compare November 3, 2025 16:45
@opcfoundation-org opcfoundation-org merged commit 6ba561e into OPCFoundation:master Dec 18, 2025
0 of 4 checks passed
opcfoundation-org pushed a commit that referenced this pull request Dec 19, 2025
…current SDK release (#212)"

Does not work, breaks many things.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants