-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dervived classes with optional fields generate invalid code #202
Comments
@opcfoundation-org This issue was introduced with the PR #193 and the relating issue #192. I currently don't have a solution and not the capacity to spend any time on that issue, thus I am writing the issue so it won't be forgotten. |
The EncodingMask is a property that has to be set before the Encode is called. |
Deleting Line 65 won't solve the issue, since the derived class might have optional fields as well and thus needs to contribute to the |
The derived class re-declares the enumeration but does not redeclare the property. |
How would the case be handled where the base class has no optional fields and thus no |
The enumeration for the fields is always re-declared for each subtype even if no new optional fields are added. |
I think we are talking about different things. Let me try to build an example. OPC-UA data type model:
In this case the |
The first Structure with optional fields must a direct subtype of Structure. See:
I realize now the text is ambiguous but the requirement 'Structure without optional fields' was supposed to imply it has to be true for all fields added by subtypes because this statement would no longer be true for the base type. |
I think this is an interesting way of interpreting that sentence in the specification. In my opinion viewing a type representing data through its basetype interface I have no way of knowing which fields are added through any types deriving from them, thus this statement would not be affected if a subtype adds any new values which might be optional. Another difficulty with this interpretation is that it differs from the behavior of the modeling tools around since they allow modeling structures this way. So nodesets with this type of modeling are around and should be correctly handled by the model compiler in my opinion. |
This needs to be discussed in the WG. While you are correct from a data modelling perspective. The absence of a clear statement one way or the other means different implementors will make different decisions. The WG needs to determine which clarification is the least likely to lead to IOP issues. |
Specification will be clarified: https://mantis.opcfoundation.org/view.php?id=10110 The ModelCompiler will allow this scenario. |
The template code of
DerivedClassWithOptionalFields.cs
is invalid since in the code from Line 60 to Line 82 theEncodingMask
is not correctly taken into account. In case the base class has fields that need to be serialized or deserialized theEncodingMask
has to be calculated and serialized/deserialized before any fields a serialized/deserialized. With the current template setup this is not possible.The order of the fields and encoding mask needs to be in valid order when generating code for derived classes with optional fields.
The text was updated successfully, but these errors were encountered: