-
Notifications
You must be signed in to change notification settings - Fork 16
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
SPM Prep – Rewrite RemoteBlogSettings
encoding and decoding in Swift
#780
base: trunk
Are you sure you want to change the base?
Conversation
e028eca
to
d2c4249
Compare
Generated by 🚫 Danger |
d2c4249
to
0ace60c
Compare
RemoteBlogSettings
encoding and decoding in SwiftRemoteBlogSettings
encoding and decoding in Swift
languageID = rawSettings.number(forKey: CodingKeys.languageID.rawValue) | ||
iconMediaID = rawSettings[CodingKeys.iconMediaID.rawValue] as? NSNumber | ||
// The value here can be a String, so we need a custom conversion | ||
gmtOffset = rawSettings.number(forKey: CodingKeys.gmtOffset.rawValue) |
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.
Maybe I worry too much, but do you think we should use number(forKey:)
to parse all properties instead of just these keys, because that's what the original Objective-C uses?.
We happen to know these weird cases, simply because we have one test json file for it. There is no indication in the original Objective-C code that these keys need special treatment. And, may be there are other keys needs a special "string" to "number" parsing, which is not detected by that one single test json file?
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.
Also, the string(forKey:)
parsing in the original Objective-C code can parse a number to a string, which we don't do here. So, maybe we should use string(forKey:)
and number(forKey:)
instead of type casting?
Description
The Objective-C
BlogServiceRemoteREST
object references the Swift typesRemoteBlog
andRemoteBlogSettings
.This Objective-C to Swift dependency is incompatible with the separation we require for the SPM setup.
The first step to address this is to move the custom encoding and decoding logic implemented within
BlogServiceRemoteREST
to Swift.I did this by first writing tests for the existing implementation and then moving it to Swift using those tests as a guideline.
Testing Details
See new tests in CI.
CHANGELOG.md
if necessary. — N.A.