-
Notifications
You must be signed in to change notification settings - Fork 112
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
Overhaul internal representation, replacing NS…
with …Box
types
#19
Conversation
Codecov Report
@@ Coverage Diff @@
## master #19 +/- ##
==========================================
+ Coverage 39.36% 48.74% +9.37%
==========================================
Files 14 28 +14
Lines 1443 1629 +186
==========================================
+ Hits 568 794 +226
+ Misses 875 835 -40
Continue to review full report at Codecov.
|
…Box
types, replacing implicit use of NS…
…Box
types, replacing use of NS…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @regexident!
This is definitely a change in the right direction, but I think that we should use a Box
protocol instead of a Box
enum, which would remove quite a few switch
statements that delegate to implementations of the same shape anyway.
Also, I'm not quite sure why some of the new containers are reference types and not value types as standard collections. In fact, you probably could avoid introducing those collections at all by adding conformance to Box
protocol to standard Array
and Dictionary
if I convinced you that Box
protocol is a better approach.
I look forward to your feedback on my proposal with Box
protocol and hope that we can find the best solution that replaces legacy Foundation
types from Objective-C days.
…Box
types, replacing use of NS…
…Box
types, replacing use of NS…
The problems I see with turning The protocol(s) would have to look something like this to work:
But in the case of If Swift allowed for multiple protocol conformances we'd be fine. Alas it doesn't. Another benefit of using a enum is that we get a guarantee for exhaustive |
Also could Apple please get rid of the plague that is |
Great point, I think we should consider moving all custom settings to |
Commit 7fe7984 just removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, except the commented out code and use of internal
, where I think it's a good chance to clean it up in this PR with the changes touching relevant code
…Box
types, replacing use of NS…
NS…
with …Box
types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good stuff, but there are a few comments left with regards to test cases, at least Constructor
typealias was unused in one place and it also looked equivalent to FromXMLString
. It also took me some time to understand what FromXMLString
is for and I got some clarity only after I started reviewing the rest of the tests, so this testing approach needs to be documented or somehow simplified in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @regexident, this is great! @hodovani, do you have any questions or comments about this PR? Otherwise this can be merged when .xcodeproj
conflict is resolved.
…nsignedIntegerBox`
…g/decoding locig
aa25f45
Rebased onto |
Phew, this PR ended up quite bigger than anticipated, but it's worth it, I think. The separation and encapsulation, as well as addition of finely-grained unit tests should give us a good and solid foundation for future improvements and bug fixes. Thanks for your comments, @MaxDesiatov! |
Add benchmark baselines Pull in tests (CoreOffice#11) Add Decoding support for choice elements (CoreOffice#15) Fix indentation (CoreOffice#16) Replace usage of XCTUnrwap (CoreOffice#19) Add nested choice tests (CoreOffice#18) Add falsely passing double array roundtrip test (CoreOffice#17)
Add benchmark baselines Pull in tests (CoreOffice#11) Add Decoding support for choice elements (CoreOffice#15) Fix indentation (CoreOffice#16) Replace usage of XCTUnrwap (CoreOffice#19) Add nested choice tests (CoreOffice#18) Add falsely passing double array roundtrip test (CoreOffice#17)
This PR removes any remaining use of
NS…Array
/NS…Dictionary
/NSNumber
/NSDecimalNumber
/NSNull
/… (as storage) from the code-base.It introduces an internal type …
… as well as accompanying variant box types, replacing use of
Any
/NS…
.👷🏻♀️It improves type-safety by reducing use of
Any
(from 60 down to 19 occurrences) as well asNSObject
(from 37 down to 1 occurrence).🏗It further more levels the field for improvements/additions such as support for order-preserving elements & attributes.
💡Thanks to encapsulation we can now safely change the inner logic of
DictionaryBox
to retain insertion order.Edit:
We ended up replacing aforementioned
enum Box
with a protocol: