-
Notifications
You must be signed in to change notification settings - Fork 95
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
Question: Template Version2/DataTypes/ClassWithOptionalFields.cs generates invalid code with subtyped datatype #192
Comments
Can you attach your model file? |
Attached you can find a model file (model192.xml) which demonstrates the issue. I also attached the generated code for the data type classes. |
i looked at the code and the issue seems to be the subclass declares IsEqual as virtual instead of override. |
That's not the primary issue here, although that needs to be fixed as well, yes. The issue is caused by the template not supporting a custom base type and thus the resulting class with optional fields has The The result should look more like this. public partial class Student : Person
{
...
public override bool IsEqual(IEncodeable encodeable)
{
if (Object.ReferenceEquals(this, encodeable))
{
return true;
}
Student value = encodeable as Student;
if (value == null)
{
return false;
}
if (value.EncodingMask != this.EncodingMask) return false;
if (!base.IsEqual(encodeable)) return false;
if (!Utils.IsEqual(m_firstName, value.m_firstName)) return false;
if ((EncodingMask & StudentFields.University) != 0) if (!Utils.IsEqual(m_university, value.m_university)) return false;
return true;
}
...
} |
Hi everyone,
I am currently trying to generate code with a model that includes a structure with an optional field and is derived from another structure. This leads to the generation of code which does not compile, since it generates and
IsEqual(....)
implementation for the structure with the optional field wherebase.IsEqual(....)
is called. But the template doesn't contain a subtype which provides anIsEqual()
method.In case this is invalid modeling, although I could not find any indication for it in the specification, shouldn't the model compiler to stop with an error?
In case this is a valid model, shouldn't the the
ClassWithOptionalFields.cs
template be extended to support base types?Thanks in advance
The text was updated successfully, but these errors were encountered: