You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
The text was updated successfully, but these errors were encountered:
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.
Consider the following example:
You have a model called
FooCollection
that you customize to make it inherit fromReadOnlyCollection<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 theFooCollection
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.The text was updated successfully, but these errors were encountered: