Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of changes:
ModelManager
now discovers everything it needs to know about a type's properties when that type is registered, rather than when the type is first (de)serialized. Closes ModelManager caches should be populated at registration time #82GetProperties()
now returns a wrapper class forPropertyInfo
calledModelProperty
, which stores thePropertyInfo
as well as the serialized json key and whether the property should be ignored by default in serialization. This class is abstract and has two child classes:FieldModelProperty
andRelationshipModelProperty
. The latter tracks the cardinality of the relationship as well as the related type.GetPropertyForJsonKey()
returns aModelProperty
.GetJsonKeyForProperty
is gone fromIModelManager
. Any code that was using this can use the field onModelProperty
instead.[JsonProperty]
attribute. Closes Allow overriding a property's serialization json key #87[UseAsId]
to specify the id property no longer serialize the property both asid
and as the property's formatted name. I feel that this is a bad practice due to not being compatible with a 1:1 mapping of json key to property, and would require special handling to make work given these new changes. Furthermore, ember data would probably squawk if you change a regular field and the server's response comes back with a new id. If a user really wants this they can accomplish it by adding a surrogateId
field in their model class, removing[UseAsId]
, and ensuring that the two are the same.This PR should improve performance and make finding bugs in one's models easier, by moving several calculations to registration time that previously didn't happen until requests are made. It also puts the model manager in charge of some concerns that used to be in the formatter's domain, but really ought to be part of the registration process. Most significantly, the formatter no longer needs to figure out whether a property is for a field or a relationship every time that property has to be serialized.
@SphtKr Do you have any feedback before I merge? I have some more work I want to get in that depends on this, but I want to make sure this meets your approval first.