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
All committers have signed the CLA.

@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 from 87c0363 to c3e90d9 Compare July 4, 2025 08:46
@larws larws force-pushed the issue/211-invalid-source branch from c3e90d9 to 80d533f Compare July 4, 2025 10:58
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