-
-
Notifications
You must be signed in to change notification settings - Fork 158
Refactorings #1038
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
Refactorings #1038
Conversation
… to IImmutableSet
…y to IImmutableDictionary and fixed equality comparison to discard order
…tion to IImmutableList
…OnlyCollection to IImmutableList
…Children type from IReadOnlyCollection to IImmutableList
…yCollection to IReadOnlySet
…t instead of a list. Made ResourceContext sealed and immutable and implemented Equals/GetHashCode so it works with sets.
9f2780d
to
1c2726b
Compare
2e0deb0
to
4c5597c
Compare
4c5597c
to
031af89
Compare
Codecov Report
@@ Coverage Diff @@
## master #1038 +/- ##
==========================================
+ Coverage 91.35% 91.63% +0.28%
==========================================
Files 254 252 -2
Lines 6765 6777 +12
==========================================
+ Hits 6180 6210 +30
+ Misses 585 567 -18
Continue to review full report at Codecov.
|
… with injected service
…th injected service
69fb792
to
f23ab45
Compare
Fixes #1027.
Fixes #864.
Fixes #944.
Fixes #1033.
Motivation for (immutable) collection usage in expressions:
AnyExpression.Constants
: Set because the order is irrelevant and having duplicates is pointless.IncludeExpression.Elements
andIncludeElementExpression.Children
: List because order should be preserved. This order is used in rendered links, but more importantly, it determines the order in which related resources are written to the response body. Although JSON:API does not specify ordering forincluded[]
, API clients may have taken a dependency on the current ordering. It does not feel justified to break in this case, because there's no real benefit in doing so.LogicalExpression.Terms
: List because the terms are short-circuited, so order matters. For example, in "A and B" when A is false, B is never evaluated.PaginationQueryStringValueExpression.Elements
: List, because this expression type is close to the typed text in the query string. Moreover, making this a Set does not prevent duplicates, due to how equality on elements is defined. For example "articles:3" is not equal to "articles:8", so the set will contain both. Deduplication occurs when constraints are built (the last one wins).ResourceFieldChainExpression.Fields
: List because it represents an ordered chain. "Owner.LastName" is not the same as "LastName.Owner".SortExpression.Elements
: List because order determines sort-within-sort. For example, sort on Name first, then within that, on Age.SparseFieldSetExpression.Fields
: Set because the order is irrelevant (we emit fields in declaration order) and having duplicates is pointless.SparseFieldTableExpression.Table
: Dictionary, which it was already (mapping from resource type to sparse fieldset).Motivation for not using
IReadOnlySet<>
(instead ofISet<>
) in AddToToMany/RemoveFromToMany in pipeline:IResourceDefinition.On***RelationshipAsync
callbacks facilitate.QUALITY CHECKLIST