sindresorhus / sindresorhus/Defaults
Improve the API for choosing the type of serialization
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 2.5k
- Forks
- 163
- PR merge metrics
- No merged PRs in 30d
Description
Current:
extension Foo: Defaults.Serializable, Defaults.PreferRawRepresentable {}
I think this may be better:
extension Foo: Defaults.Serializable.RawRepresentable {}
This is shorter, but more importantly, it makes the choice explicit. Users should prefer this over Defaults.Serializable. Defaults.Serializable has a big flaw. For example, you have a struct X: Codable, Defaults.Serializable. You save data with it, but later on, you add a RawRepresentable conformance. The previous persisted version of the struct can no longer be loaded as it's saved using the Codable bridge, but now tries to load using the RawRepresentable bridge.
// @hank121314 Thoughts? Any better way to prevent this problem?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing Defaults.Serializable and Defaults.PreferRawRepresentable conformances and the serialization bridge they select. Define the intended explicit API for RawRepresentable types, then verify that adding such a conformance does not prevent previously persisted Codable data from loading.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100