Skip to content
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

The _serializedAdditionalRawData field and its corresponding serialization logic is not generated when a model is customized to inherit from a framework class #4636

Open
joseharriaga opened this issue Apr 24, 2024 · 1 comment
Assignees

Comments

@joseharriaga
Copy link
Member

Consider the following example:
You have a model called FooCollection that you customize to make it inherit from ReadOnlyCollection<Foo>, which is a framework class (as opposed to another model class). If you re-generate the code, the _serializedAdditionalRawData field would be deleted from the FooCollection model, which is unexpected.

While I haven't been able to confirm it, I talked to Michael and the current theory is that this might be caused by the expectation that model classes would inherit from other model classes, and that the generator omits the _serializedAdditionalRawData field from the parent class assuming that the child class already has this field in order to avoid duplicating the deserialization logic.

@ArcturusZhang ArcturusZhang self-assigned this Apr 24, 2024
@ArcturusZhang
Copy link
Member

Hi @joseharriaga thanks for the feedback.
That might be the reason because we have some checks to know whether a generated model should have the raw data field, because it will inherit serialized raw data field from its parent class, and we are not making that check correct enough - now it inherits a framework type and it confuses the generator to imagine the model already have a inherited raw data.
I will take a look how to fix it.
because in a case of a lot of customization, it is more likely for the generator to go wrong, I lean towards a solution that requires explicity - if you want raw data field and the generator did not generate it, we introduce a way to let you explicitly tell the generator.
I probably will make it into the CodeGenSerializationAttribute
Feel free to let me know your thoughts on this.

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

No branches or pull requests

2 participants